-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathconfig.cpp
More file actions
337 lines (269 loc) · 16.3 KB
/
Copy pathconfig.cpp
File metadata and controls
337 lines (269 loc) · 16.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#include "config.h"
#include <library/cpp/monlib/service/pages/templates.h>
#include <util/generic/size_literals.h>
#include <util/stream/str.h>
#include <chrono>
namespace NCloud::NFileStore {
using namespace std::chrono_literals;
namespace {
////////////////////////////////////////////////////////////////////////////////
#define FILESTORE_SERVICE_CONFIG(xxx) \
xxx(RootPath, TString, "./" )\
xxx(PathPrefix, TString, "nfs_" )\
xxx(DefaultPermissions, ui32, 0775 )\
xxx(IdleSessionTimeout, TDuration, 30s )\
xxx(NumThreads, ui32, 8 )\
xxx(StatePath, TString, "./" )\
xxx(MaxNodeCount, ui32, 1000000 )\
xxx(MaxHandlePerSessionCount, ui32, 10000 )\
xxx(DirectIoEnabled, bool, false )\
xxx(DirectIoAlign, ui32, 4_KB )\
xxx(GuestWriteBackCacheEnabled, bool, false )\
xxx(AsyncDestroyHandleEnabled, bool, false )\
xxx(AsyncDestroyReadOnlyHandleEnabled, bool, false )\
xxx(AsyncHandleOperationIdlePeriod, TDuration, 50ms )\
xxx(AsyncHandleOperationDrainPeriod, TDuration, 0ms )\
xxx(OpenNodeByHandleEnabled, bool, false )\
xxx(NodeCleanupBatchSize, ui32, 1000 )\
xxx(ZeroCopyEnabled, bool, false )\
xxx(GuestPageCacheDisabled, bool, false )\
xxx(ExtendedAttributesDisabled, bool, false )\
xxx(ServerWriteBackCacheEnabled, bool, false )\
xxx(DontPopulateNodeCacheWhenListingNodes, bool, false )\
xxx(GuestOnlyPermissionsCheckEnabled, bool, false )\
xxx(MaxResponseEntries, ui32, 10000 )\
xxx(MaxBackground, ui32, 0 )\
xxx(MaxFuseLoopThreads, ui32, 1 )\
xxx(FSyncQueueDisabled, bool, false )\
xxx(EntryTimeout, TDuration, TDuration::Seconds(15) )\
xxx(NegativeEntryTimeout, TDuration, TDuration::Zero() )\
xxx(AttrTimeout, TDuration, TDuration::Seconds(15) )\
xxx(XAttrCacheTimeout, TDuration, TDuration::Seconds(15) )\
xxx(DirectoryHandlesStorageEnabled, bool, false )\
xxx(DirectoryHandlesTableSize, ui64, 100'000 )\
xxx(DirectoryHandlesPersistentHandleMaxSize, ui64, 2_GB )\
xxx(GuestHandleKillPrivV2Enabled, bool, false )\
xxx(GuestPosixAclEnabled, bool, false )\
xxx(SnapshotsDirEnabled, bool, false )\
xxx(SnapshotsDirRefreshInterval, TDuration, TDuration::Seconds(5) )\
// FILESTORE_SERVICE_CONFIG
#define FILESTORE_SERVICE_NULL_FILE_IO_CONFIG(xxx) \
// FILESTORE_SERVICE_NULL_FILE_IO_CONFIG
#define FILESTORE_SERVICE_AIO_CONFIG(xxx) \
xxx(Entries, ui32, 1024 )\
// FILESTORE_SERVICE_AIO_CONFIG
#define FILESTORE_SERVICE_IO_URING_CONFIG(xxx) \
xxx(Entries, ui32, 1024 )\
xxx(ShareKernelWorkers, bool, false )\
xxx(MaxKernelWorkersCount, ui32, 0 )\
xxx(ForceAsyncIO, bool, false )\
xxx(PropagateAffinityToKernelWorkers, bool, false )\
xxx(SQKernelPollingEnabled, bool, false )\
// FILESTORE_SERVICE_IO_URING_CONFIG
#define FILESTORE_SERVICE_DECLARE_CONFIG(name, type, value) \
Y_DECLARE_UNUSED static const type Default##name = value; \
// FILESTORE_SERVICE_DECLARE_CONFIG
FILESTORE_SERVICE_CONFIG(FILESTORE_SERVICE_DECLARE_CONFIG)
#undef FILESTORE_SERVICE_DECLARE_CONFIG
#define FILESTORE_SERVICE_DECLARE_NULL_FILE_IO_CONFIG(name, type, value) \
Y_DECLARE_UNUSED static const type DefaultNullFileIO##name = value; \
// FILESTORE_SERVICE_DECLARE_NULL_FILE_IO_CONFIG
FILESTORE_SERVICE_NULL_FILE_IO_CONFIG(FILESTORE_SERVICE_DECLARE_NULL_FILE_IO_CONFIG)
#define FILESTORE_SERVICE_DECLARE_AIO_CONFIG(name, type, value) \
Y_DECLARE_UNUSED static const type DefaultAio##name = value; \
// FILESTORE_SERVICE_DECLARE_AIO_CONFIG
FILESTORE_SERVICE_AIO_CONFIG(FILESTORE_SERVICE_DECLARE_AIO_CONFIG)
#define FILESTORE_SERVICE_DECLARE_IO_URING_CONFIG(name, type, value) \
Y_DECLARE_UNUSED static const type DefaultIoUring##name = value; \
// FILESTORE_SERVICE_DECLARE_IO_URING_CONFIG
FILESTORE_SERVICE_IO_URING_CONFIG(FILESTORE_SERVICE_DECLARE_IO_URING_CONFIG)
////////////////////////////////////////////////////////////////////////////////
template <typename TTarget, typename TSource>
TTarget ConvertValue(const TSource& value)
{
return static_cast<TTarget>(value);
}
template <>
TDuration ConvertValue<TDuration, ui32>(const ui32& value)
{
return TDuration::MilliSeconds(value);
}
template <typename T>
bool IsEmpty(const T& t)
{
return !t;
}
template <typename T>
void DumpImpl(const T& t, IOutputStream& os)
{
os << t;
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
#define FILESTORE_CONFIG_GETTER(name, type, ...) \
type TLocalFileStoreConfig::Get##name() const \
{ \
if (ProtoConfig.Has##name()) { \
return ConvertValue<type>(ProtoConfig.Get##name()); \
} \
return Default##name; \
} \
// FILESTORE_CONFIG_GETTER
FILESTORE_SERVICE_CONFIG(FILESTORE_CONFIG_GETTER)
#undef FILESTORE_CONFIG_GETTER
#define FILESTORE_BINARY_FEATURES(xxx) \
xxx(DirectoryHandlesStorageEnabled) \
xxx(ExtendedAttributesDisabled) \
xxx(SnapshotsDirEnabled) \
xxx(GuestHandleKillPrivV2Enabled) \
xxx(GuestPosixAclEnabled) \
// FILESTORE_BINARY_FEATURES
#define FILESTORE_DURATION_FEATURES(xxx) \
xxx(EntryTimeout) \
xxx(NegativeEntryTimeout) \
xxx(AttrTimeout) \
xxx(XAttrCacheTimeout) \
// FILESTORE_DURATION_FEATURES
#define FILESTORE_BINARY_FEATURE_GETTER(name) \
bool TLocalFileStoreConfig::Get##name( \
const TString& cloudId, \
const TString& folderId, \
const TString& fsId) const \
{ \
if (!FeaturesConfig) { \
return Get##name(); \
} \
\
if (!FeaturesConfig->IsFeatureEnabled(cloudId, folderId, fsId, #name)) { \
return Get##name(); \
} \
\
auto val = FeaturesConfig->GetFeatureValue(cloudId, folderId, fsId, #name);\
val.to_lower(); \
return val != "false"; \
} \
// FILESTORE_BINARY_FEATURE_GETTER
FILESTORE_BINARY_FEATURES(FILESTORE_BINARY_FEATURE_GETTER)
#undef FILESTORE_BINARY_FEATURE_GETTER
#define FILESTORE_DURATION_FEATURE_GETTER(name) \
TDuration TLocalFileStoreConfig::Get##name( \
const TString& cloudId, \
const TString& folderId, \
const TString& fsId) const \
{ \
if (!FeaturesConfig) { \
return Get##name(); \
} \
\
auto val = FeaturesConfig->GetFeatureValue(cloudId, folderId, fsId, #name);\
if (!val) { \
return Get##name(); \
} \
\
TDuration res; \
if (!TDuration::TryParse(val, res)) { \
return Get##name(); \
} \
\
return res; \
} \
// FILESTORE_DURATION_FEATURE_GETTER
FILESTORE_DURATION_FEATURES(FILESTORE_DURATION_FEATURE_GETTER)
#undef FILESTORE_DURATION_FEATURE_GETTER
TFileIOConfig TLocalFileStoreConfig::GetFileIOConfig() const
{
using EFileIOConfigCase = NProto::TLocalServiceConfig::FileIOConfigCase;
switch (ProtoConfig.GetFileIOConfigCase()) {
case EFileIOConfigCase::kAioConfig:
return TAioConfig{ProtoConfig.GetAioConfig()};
case EFileIOConfigCase::kIoUringConfig:
return TIoUringConfig{ProtoConfig.GetIoUringConfig()};
case EFileIOConfigCase::kNullFileIOConfig:
return TNullFileIOConfig{ProtoConfig.GetNullFileIOConfig()};
default:
return TAioConfig{};
}
}
////////////////////////////////////////////////////////////////////////////////
void TLocalFileStoreConfig::Dump(IOutputStream& out) const
{
#define FILESTORE_CONFIG_DUMP(name, ...) \
out << #name << ": "; \
DumpImpl(Get##name(), out); \
out << Endl; \
// FILESTORE_CONFIG_DUMP
FILESTORE_SERVICE_CONFIG(FILESTORE_CONFIG_DUMP);
#undef FILESTORE_CONFIG_DUMP
}
TString TLocalFileStoreConfig::DumpStr() const
{
TStringStream ss;
#define FILESTORE_CONFIG_DUMP(name, ...) \
ss << #name << ": "; \
DumpImpl(Get##name(), ss); \
ss << ", "; \
// FILESTORE_CONFIG_DUMP
FILESTORE_SERVICE_CONFIG(FILESTORE_CONFIG_DUMP);
#undef FILESTORE_CONFIG_DUMP
ss.TStringOutput::Undo(2);
return ss.Str();
}
void TLocalFileStoreConfig::DumpHtml(IOutputStream& out) const
{
#define FILESTORE_CONFIG_DUMP(name, ...) \
TABLER() { \
TABLED() { out << #name; } \
TABLED() { DumpImpl(Get##name(), out); } \
} \
// FILESTORE_CONFIG_DUMP
HTML(out) {
TABLE_CLASS("table table-condensed") {
TABLEBODY() {
FILESTORE_SERVICE_CONFIG(FILESTORE_CONFIG_DUMP);
}
}
}
#undef FILESTORE_CONFIG_DUMP
}
void TLocalFileStoreConfig::SetFeaturesConfig(
NFeatures::TFeaturesConfigPtr featuresConfig)
{
FeaturesConfig = std::move(featuresConfig);
}
////////////////////////////////////////////////////////////////////////////////
#define FILESTORE_CONFIG_NULL_FILE_IO_GETTER(name, type, ...) \
type TNullFileIOConfig::Get##name() const \
{ \
if (Proto.Has##name()) { \
return ConvertValue<type>(Proto.Get##name()); \
} \
return DefaultNullFileIO##name; \
} \
// FILESTORE_CONFIG_AIO_GETTER
FILESTORE_SERVICE_NULL_FILE_IO_CONFIG(FILESTORE_CONFIG_NULL_FILE_IO_GETTER)
#undef FILESTORE_CONFIG_NULL_FILE_IO_GETTER
////////////////////////////////////////////////////////////////////////////////
#define FILESTORE_CONFIG_AIO_GETTER(name, type, ...) \
type TAioConfig::Get##name() const \
{ \
if (Proto.Has##name()) { \
return ConvertValue<type>(Proto.Get##name()); \
} \
return DefaultAio##name; \
} \
// FILESTORE_CONFIG_AIO_GETTER
FILESTORE_SERVICE_AIO_CONFIG(FILESTORE_CONFIG_AIO_GETTER)
#undef FILESTORE_CONFIG_AIO_GETTER
////////////////////////////////////////////////////////////////////////////////
#define FILESTORE_CONFIG_IO_URING_GETTER(name, type, ...) \
type TIoUringConfig::Get##name() const \
{ \
if (Proto.Has##name()) { \
return ConvertValue<type>(Proto.Get##name()); \
} \
return DefaultIoUring##name; \
} \
// FILESTORE_CONFIG_IO_URING_GETTER
FILESTORE_SERVICE_IO_URING_CONFIG(FILESTORE_CONFIG_IO_URING_GETTER)
#undef FILESTORE_CONFIG_IO_URING_GETTER
} // namespace NCloud::NFileStore