Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
* |
4 |
|
|
* Steers the booting of CernVM-FS repositories. |
5 |
|
|
*/ |
6 |
|
|
|
7 |
|
|
#ifndef CVMFS_MOUNTPOINT_H_ |
8 |
|
|
#define CVMFS_MOUNTPOINT_H_ |
9 |
|
|
|
10 |
|
|
#include <pthread.h> |
11 |
|
|
#include <sys/statvfs.h> |
12 |
|
|
#include <unistd.h> |
13 |
|
|
|
14 |
|
|
#include <ctime> |
15 |
|
|
#include <set> |
16 |
|
|
#include <string> |
17 |
|
|
#include <vector> |
18 |
|
|
|
19 |
|
|
#include "cache.h" |
20 |
|
|
#include "crypto/hash.h" |
21 |
|
|
#include "file_watcher.h" |
22 |
|
|
#include "gtest/gtest_prod.h" |
23 |
|
|
#include "loader.h" |
24 |
|
|
#include "magic_xattr.h" |
25 |
|
|
#include "util/algorithm.h" |
26 |
|
|
#include "util/pointer.h" |
27 |
|
|
|
28 |
|
|
class AuthzAttachment; |
29 |
|
|
class AuthzFetcher; |
30 |
|
|
class AuthzSessionManager; |
31 |
|
|
class BackoffThrottle; |
32 |
|
|
class CacheManager; |
33 |
|
|
namespace catalog { |
34 |
|
|
class ClientCatalogManager; |
35 |
|
|
class InodeAnnotation; |
36 |
|
|
} |
37 |
|
|
struct ChunkTables; |
38 |
|
|
namespace cvmfs { |
39 |
|
|
class Fetcher; |
40 |
|
|
class Uuid; |
41 |
|
|
} |
42 |
|
|
namespace download { |
43 |
|
|
class DownloadManager; |
44 |
|
|
} |
45 |
|
|
namespace glue { |
46 |
|
|
class InodeTracker; |
47 |
|
|
class DentryTracker; |
48 |
|
|
class PageCacheTracker; |
49 |
|
|
} |
50 |
|
|
namespace lru { |
51 |
|
|
class InodeCache; |
52 |
|
|
class Md5PathCache; |
53 |
|
|
class PathCache; |
54 |
|
|
} |
55 |
|
|
class NfsMaps; |
56 |
|
|
class OptionsManager; |
57 |
|
|
namespace perf { |
58 |
|
|
class Counter; |
59 |
|
|
class Statistics; |
60 |
|
|
class TelemetryAggregator; |
61 |
|
|
} |
62 |
|
|
namespace signature { |
63 |
|
|
class SignatureManager; |
64 |
|
|
} |
65 |
|
|
class SimpleChunkTables; |
66 |
|
|
class Tracer; |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
/** |
70 |
|
|
* Construction of FileSystem and MountPoint can go wrong. In this case, we'd |
71 |
|
|
* like to know why. This is a base class for both FileSystem and MountPoint. |
72 |
|
|
*/ |
73 |
|
|
class BootFactory { |
74 |
|
|
public: |
75 |
|
116 |
BootFactory() : boot_status_(loader::kFailUnknown) { } |
76 |
|
4 |
bool IsValid() { return boot_status_ == loader::kFailOk; } |
77 |
|
98 |
loader::Failures boot_status() { return boot_status_; } |
78 |
|
3 |
std::string boot_error() { return boot_error_; } |
79 |
|
|
|
80 |
|
|
/** |
81 |
|
|
* Used in the fuse module to artificially set boot errors that are specific |
82 |
|
|
* to the fuse boot procedure. |
83 |
|
|
*/ |
84 |
|
✗ |
void set_boot_status(loader::Failures code) { boot_status_ = code; } |
85 |
|
|
|
86 |
|
|
protected: |
87 |
|
|
loader::Failures boot_status_; |
88 |
|
|
std::string boot_error_; |
89 |
|
|
}; |
90 |
|
|
|
91 |
|
|
|
92 |
|
|
/** |
93 |
|
|
* The FileSystem object initializes cvmfs' global state. It sets up sqlite and |
94 |
|
|
* the cache directory and it can contain multiple mount points. It currently |
95 |
|
|
* does so only for libcvmfs; the cvmfs fuse module has exactly one FileSystem |
96 |
|
|
* object and one MountPoint object. |
97 |
|
|
*/ |
98 |
|
|
class FileSystem : SingleCopy, public BootFactory { |
99 |
|
|
FRIEND_TEST(T_MountPoint, MkCacheParm); |
100 |
|
|
FRIEND_TEST(T_MountPoint, CacheSettings); |
101 |
|
|
FRIEND_TEST(T_MountPoint, CheckInstanceName); |
102 |
|
|
FRIEND_TEST(T_MountPoint, CheckPosixCacheSettings); |
103 |
|
|
|
104 |
|
|
public: |
105 |
|
|
enum Type { |
106 |
|
|
kFsFuse = 0, |
107 |
|
|
kFsLibrary |
108 |
|
|
}; |
109 |
|
|
|
110 |
|
|
struct FileSystemInfo { |
111 |
|
50 |
FileSystemInfo() |
112 |
|
100 |
: type(kFsFuse) |
113 |
|
50 |
, options_mgr(NULL) |
114 |
|
50 |
, wait_workspace(false) |
115 |
|
50 |
, foreground(false) { } |
116 |
|
|
/** |
117 |
|
|
* Name can is used to identify this particular instance of cvmfs in the |
118 |
|
|
* cache (directory). Normally it is the fully qualified repository name. |
119 |
|
|
* For libcvmfs and in other special mount conditions, it can be something |
120 |
|
|
* else. Only file systems with different names can share a cache because |
121 |
|
|
* the name is part of a lock file. |
122 |
|
|
*/ |
123 |
|
|
std::string name; |
124 |
|
|
|
125 |
|
|
/** |
126 |
|
|
* Used to fork & execve into different flavors of the binary, e.g. the |
127 |
|
|
* quota manager. |
128 |
|
|
*/ |
129 |
|
|
std::string exe_path; |
130 |
|
|
|
131 |
|
|
/** |
132 |
|
|
* Fuse mount point or libcvmfs. |
133 |
|
|
*/ |
134 |
|
|
Type type; |
135 |
|
|
|
136 |
|
|
/** |
137 |
|
|
* All further configuration has to be present in the options manager. |
138 |
|
|
*/ |
139 |
|
|
OptionsManager *options_mgr; |
140 |
|
|
|
141 |
|
|
/** |
142 |
|
|
* Decides if FileSystem construction should block if the workspace is |
143 |
|
|
* currently taken. This is used to coordinate fuse mounts where the next |
144 |
|
|
* mount happens while the previous fuse module is not yet fully cleaned |
145 |
|
|
* up. |
146 |
|
|
*/ |
147 |
|
|
bool wait_workspace; |
148 |
|
|
/** |
149 |
|
|
* The fuse module should not daemonize. That means the quota manager |
150 |
|
|
* should not daemonize, too, but print debug messages to stdout. |
151 |
|
|
*/ |
152 |
|
|
bool foreground; |
153 |
|
|
}; |
154 |
|
|
|
155 |
|
|
/** |
156 |
|
|
* Keeps information about I/O errors, e.g. writing local files, permanent |
157 |
|
|
* network errors, etc. It counts the number of errors and the timestamp |
158 |
|
|
* of the latest errors for consumption by monitoring tools such as Nagios |
159 |
|
|
*/ |
160 |
|
|
class IoErrorInfo { |
161 |
|
|
public: |
162 |
|
|
IoErrorInfo(); |
163 |
|
|
|
164 |
|
|
void Reset(); |
165 |
|
|
void AddIoError(); |
166 |
|
|
void SetCounter(perf::Counter *c); |
167 |
|
|
int64_t count(); |
168 |
|
|
time_t timestamp_last(); |
169 |
|
|
|
170 |
|
|
private: |
171 |
|
|
perf::Counter *counter_; |
172 |
|
|
time_t timestamp_last_; |
173 |
|
|
}; |
174 |
|
|
|
175 |
|
|
/** |
176 |
|
|
* No NFS maps. |
177 |
|
|
*/ |
178 |
|
|
static const unsigned kNfsNone = 0x00; |
179 |
|
|
/** |
180 |
|
|
* Normal NFS maps by leveldb |
181 |
|
|
*/ |
182 |
|
|
static const unsigned kNfsMaps = 0x01; |
183 |
|
|
/** |
184 |
|
|
* NFS maps maintained by sqlite so that they can reside on an NFS mount |
185 |
|
|
*/ |
186 |
|
|
static const unsigned kNfsMapsHa = 0x02; |
187 |
|
|
|
188 |
|
|
static FileSystem *Create(const FileSystemInfo &fs_info); |
189 |
|
|
~FileSystem(); |
190 |
|
|
|
191 |
|
|
// Used to setup logging before the file system object is created |
192 |
|
|
static void SetupLoggingStandalone( |
193 |
|
|
const OptionsManager &options_mgr, const std::string &prefix); |
194 |
|
|
|
195 |
|
49 |
bool IsNfsSource() { return nfs_mode_ & kNfsMaps; } |
196 |
|
1 |
bool IsHaNfsSource() { return nfs_mode_ & kNfsMapsHa; } |
197 |
|
|
void ResetErrorCounters(); |
198 |
|
|
void TearDown2ReadOnly(); |
199 |
|
|
void RemapCatalogFd(int from, int to); |
200 |
|
|
|
201 |
|
|
// Used in cvmfs' RestoreState to prevent change of cache manager type |
202 |
|
|
// during reload |
203 |
|
|
void ReplaceCacheManager(CacheManager *new_cache_mgr); |
204 |
|
|
|
205 |
|
110 |
CacheManager *cache_mgr() { return cache_mgr_; } |
206 |
|
6 |
std::string cache_mgr_instance() { return cache_mgr_instance_; } |
207 |
|
|
std::string exe_path() { return exe_path_; } |
208 |
|
2 |
bool found_previous_crash() { return found_previous_crash_; } |
209 |
|
✗ |
Log2Histogram *hist_fs_lookup() { return hist_fs_lookup_; } |
210 |
|
✗ |
Log2Histogram *hist_fs_forget() { return hist_fs_forget_; } |
211 |
|
✗ |
Log2Histogram *hist_fs_forget_multi() { return hist_fs_forget_multi_; } |
212 |
|
✗ |
Log2Histogram *hist_fs_getattr() { return hist_fs_getattr_; } |
213 |
|
✗ |
Log2Histogram *hist_fs_readlink() { return hist_fs_readlink_; } |
214 |
|
✗ |
Log2Histogram *hist_fs_opendir() { return hist_fs_opendir_; } |
215 |
|
✗ |
Log2Histogram *hist_fs_releasedir() { return hist_fs_releasedir_; } |
216 |
|
✗ |
Log2Histogram *hist_fs_readdir() { return hist_fs_readdir_; } |
217 |
|
✗ |
Log2Histogram *hist_fs_open() { return hist_fs_open_; } |
218 |
|
✗ |
Log2Histogram *hist_fs_read() { return hist_fs_read_; } |
219 |
|
✗ |
Log2Histogram *hist_fs_release() { return hist_fs_release_; } |
220 |
|
|
|
221 |
|
✗ |
perf::Counter *n_fs_dir_open() { return n_fs_dir_open_; } |
222 |
|
✗ |
perf::Counter *n_fs_forget() { return n_fs_forget_; } |
223 |
|
✗ |
perf::Counter *n_fs_inode_replace() { return n_fs_inode_replace_; } |
224 |
|
✗ |
perf::Counter *n_fs_lookup() { return n_fs_lookup_; } |
225 |
|
✗ |
perf::Counter *n_fs_lookup_negative() { return n_fs_lookup_negative_; } |
226 |
|
✗ |
perf::Counter *n_fs_open() { return n_fs_open_; } |
227 |
|
✗ |
perf::Counter *n_fs_read() { return n_fs_read_; } |
228 |
|
✗ |
perf::Counter *n_fs_readlink() { return n_fs_readlink_; } |
229 |
|
24 |
perf::Counter *n_fs_stat() { return n_fs_stat_; } |
230 |
|
✗ |
perf::Counter *n_fs_stat_stale() { return n_fs_stat_stale_; } |
231 |
|
✗ |
perf::Counter *n_fs_statfs() { return n_fs_statfs_; } |
232 |
|
✗ |
perf::Counter *n_fs_statfs_cached() { return n_fs_statfs_cached_; } |
233 |
|
✗ |
IoErrorInfo *io_error_info() { return &io_error_info_; } |
234 |
|
39 |
std::string name() { return name_; } |
235 |
|
✗ |
NfsMaps *nfs_maps() { return nfs_maps_; } |
236 |
|
✗ |
perf::Counter *no_open_dirs() { return no_open_dirs_; } |
237 |
|
✗ |
perf::Counter *no_open_files() { return no_open_files_; } |
238 |
|
✗ |
perf::Counter *n_eio_total() { return n_eio_total_; } |
239 |
|
✗ |
perf::Counter *n_eio_01() { return n_eio_01_; } |
240 |
|
✗ |
perf::Counter *n_eio_02() { return n_eio_02_; } |
241 |
|
✗ |
perf::Counter *n_eio_03() { return n_eio_03_; } |
242 |
|
✗ |
perf::Counter *n_eio_04() { return n_eio_04_; } |
243 |
|
✗ |
perf::Counter *n_eio_05() { return n_eio_05_; } |
244 |
|
✗ |
perf::Counter *n_eio_06() { return n_eio_06_; } |
245 |
|
✗ |
perf::Counter *n_eio_07() { return n_eio_07_; } |
246 |
|
✗ |
perf::Counter *n_eio_08() { return n_eio_08_; } |
247 |
|
✗ |
perf::Counter *n_emfile() { return n_emfile_; } |
248 |
|
104 |
OptionsManager *options_mgr() { return options_mgr_; } |
249 |
|
40 |
perf::Statistics *statistics() { return statistics_; } |
250 |
|
95 |
Type type() { return type_; } |
251 |
|
41 |
cvmfs::Uuid *uuid_cache() { return uuid_cache_; } |
252 |
|
74 |
std::string workspace() { return workspace_; } |
253 |
|
|
|
254 |
|
|
private: |
255 |
|
|
/** |
256 |
|
|
* Only one instance may be alive at any given time |
257 |
|
|
*/ |
258 |
|
|
static bool g_alive; |
259 |
|
|
static const char *kDefaultCacheBase; // /var/lib/cvmfs |
260 |
|
|
static const unsigned kDefaultQuotaLimit = 1024 * 1024 * 1024; // 1GB |
261 |
|
|
static const unsigned kDefaultNfiles = 8192; // if CVMFS_NFILES is unset |
262 |
|
|
static const char *kDefaultCacheMgrInstance; // "default" |
263 |
|
|
|
264 |
|
|
struct PosixCacheSettings { |
265 |
|
66 |
PosixCacheSettings() : |
266 |
|
66 |
is_shared(false), is_alien(false), is_managed(false), |
267 |
|
66 |
avoid_rename(false), cache_base_defined(false), cache_dir_defined(false), |
268 |
|
66 |
quota_limit(0), do_refcount(true) |
269 |
|
66 |
{ } |
270 |
|
|
bool is_shared; |
271 |
|
|
bool is_alien; |
272 |
|
|
bool is_managed; |
273 |
|
|
bool avoid_rename; |
274 |
|
|
bool cache_base_defined; |
275 |
|
|
bool cache_dir_defined; |
276 |
|
|
/** |
277 |
|
|
* Soft limit in bytes for the cache. The quota manager removes half the |
278 |
|
|
* cache when the limit is exceeded. |
279 |
|
|
*/ |
280 |
|
|
int64_t quota_limit; |
281 |
|
|
bool do_refcount; |
282 |
|
|
std::string cache_path; |
283 |
|
|
/** |
284 |
|
|
* Different from cache_path only if CVMFS_WORKSPACE or |
285 |
|
|
* CVMFS_CACHE_WORKSPACE is set. |
286 |
|
|
*/ |
287 |
|
|
std::string workspace; |
288 |
|
|
}; |
289 |
|
|
|
290 |
|
|
static void LogSqliteError(void *user_data __attribute__((unused)), |
291 |
|
|
int sqlite_extended_error, |
292 |
|
|
const char *message); |
293 |
|
|
|
294 |
|
|
explicit FileSystem(const FileSystemInfo &fs_info); |
295 |
|
|
|
296 |
|
|
static void SetupGlobalEnvironmentParams(); |
297 |
|
|
void SetupLogging(); |
298 |
|
|
void CreateStatistics(); |
299 |
|
|
void SetupSqlite(); |
300 |
|
|
bool DetermineNfsMode(); |
301 |
|
|
bool SetupWorkspace(); |
302 |
|
|
bool SetupCwd(); |
303 |
|
|
bool LockWorkspace(); |
304 |
|
|
bool SetupCrashGuard(); |
305 |
|
|
bool SetupNfsMaps(); |
306 |
|
|
void SetupUuid(); |
307 |
|
|
|
308 |
|
|
std::string MkCacheParm(const std::string &generic_parameter, |
309 |
|
|
const std::string &instance); |
310 |
|
|
bool CheckInstanceName(const std::string &instance); |
311 |
|
|
bool TriageCacheMgr(); |
312 |
|
|
CacheManager *SetupCacheMgr(const std::string &instance); |
313 |
|
|
CacheManager *SetupPosixCacheMgr(const std::string &instance); |
314 |
|
|
CacheManager *SetupRamCacheMgr(const std::string &instance); |
315 |
|
|
CacheManager *SetupTieredCacheMgr(const std::string &instance); |
316 |
|
|
CacheManager *SetupExternalCacheMgr(const std::string &instance); |
317 |
|
|
PosixCacheSettings DeterminePosixCacheSettings(const std::string &instance); |
318 |
|
|
bool CheckPosixCacheSettings(const PosixCacheSettings &settings); |
319 |
|
|
bool SetupPosixQuotaMgr(const PosixCacheSettings &settings, |
320 |
|
|
CacheManager *cache_mgr); |
321 |
|
|
|
322 |
|
|
// See FileSystemInfo for the following fields |
323 |
|
|
std::string name_; |
324 |
|
|
std::string exe_path_; |
325 |
|
|
Type type_; |
326 |
|
|
/** |
327 |
|
|
* Not owned by the FileSystem object |
328 |
|
|
*/ |
329 |
|
|
OptionsManager *options_mgr_; |
330 |
|
|
bool wait_workspace_; |
331 |
|
|
bool foreground_; |
332 |
|
|
|
333 |
|
|
perf::Counter *n_fs_open_; |
334 |
|
|
perf::Counter *n_fs_dir_open_; |
335 |
|
|
perf::Counter *n_fs_lookup_; |
336 |
|
|
perf::Counter *n_fs_lookup_negative_; |
337 |
|
|
perf::Counter *n_fs_stat_; |
338 |
|
|
perf::Counter *n_fs_stat_stale_; |
339 |
|
|
perf::Counter *n_fs_statfs_; |
340 |
|
|
perf::Counter *n_fs_statfs_cached_; |
341 |
|
|
perf::Counter *n_fs_read_; |
342 |
|
|
perf::Counter *n_fs_readlink_; |
343 |
|
|
perf::Counter *n_fs_forget_; |
344 |
|
|
perf::Counter *n_fs_inode_replace_; |
345 |
|
|
perf::Counter *no_open_files_; |
346 |
|
|
perf::Counter *no_open_dirs_; |
347 |
|
|
perf::Counter *n_eio_total_; |
348 |
|
|
perf::Counter *n_eio_01_; |
349 |
|
|
perf::Counter *n_eio_02_; |
350 |
|
|
perf::Counter *n_eio_03_; |
351 |
|
|
perf::Counter *n_eio_04_; |
352 |
|
|
perf::Counter *n_eio_05_; |
353 |
|
|
perf::Counter *n_eio_06_; |
354 |
|
|
perf::Counter *n_eio_07_; |
355 |
|
|
perf::Counter *n_eio_08_; |
356 |
|
|
perf::Counter *n_emfile_; |
357 |
|
|
IoErrorInfo io_error_info_; |
358 |
|
|
perf::Statistics *statistics_; |
359 |
|
|
|
360 |
|
|
Log2Histogram *hist_fs_lookup_; |
361 |
|
|
Log2Histogram *hist_fs_forget_; |
362 |
|
|
Log2Histogram *hist_fs_forget_multi_; |
363 |
|
|
Log2Histogram *hist_fs_getattr_; |
364 |
|
|
Log2Histogram *hist_fs_readlink_; |
365 |
|
|
Log2Histogram *hist_fs_opendir_; |
366 |
|
|
Log2Histogram *hist_fs_releasedir_; |
367 |
|
|
Log2Histogram *hist_fs_readdir_; |
368 |
|
|
Log2Histogram *hist_fs_open_; |
369 |
|
|
Log2Histogram *hist_fs_read_; |
370 |
|
|
Log2Histogram *hist_fs_release_; |
371 |
|
|
|
372 |
|
|
/** |
373 |
|
|
* A writeable local directory. Only small amounts of data (few bytes) will |
374 |
|
|
* be stored here. Needed because the cache can be read-only. The workspace |
375 |
|
|
* and the cache directory can be identical. A workspace can be shared among |
376 |
|
|
* FileSystem instances if their name is different. |
377 |
|
|
*/ |
378 |
|
|
std::string workspace_; |
379 |
|
|
/** |
380 |
|
|
* During setup, the fuse module changes its working directory to workspace. |
381 |
|
|
* Afterwards, workspace_ is ".". Store the original one in |
382 |
|
|
* workspace_fullpath_ |
383 |
|
|
*/ |
384 |
|
|
std::string workspace_fullpath_; |
385 |
|
|
int fd_workspace_lock_; |
386 |
|
|
std::string path_workspace_lock_; |
387 |
|
|
|
388 |
|
|
/** |
389 |
|
|
* An empty file that is removed on proper shutdown. |
390 |
|
|
*/ |
391 |
|
|
std::string path_crash_guard_; |
392 |
|
|
|
393 |
|
|
/** |
394 |
|
|
* A crash guard was found, thus we assume the file system was not shutdown |
395 |
|
|
* properly last time. |
396 |
|
|
*/ |
397 |
|
|
bool found_previous_crash_; |
398 |
|
|
|
399 |
|
|
/** |
400 |
|
|
* Only needed for fuse to detect and prevent double mounting at the same |
401 |
|
|
* location. |
402 |
|
|
*/ |
403 |
|
|
std::string mountpoint_; |
404 |
|
|
/** |
405 |
|
|
* The user-provided name of the parimay cache manager or 'default' if none |
406 |
|
|
* is specified. |
407 |
|
|
*/ |
408 |
|
|
std::string cache_mgr_instance_; |
409 |
|
|
/** |
410 |
|
|
* Keep track of all the cache instances to detect circular definitions with |
411 |
|
|
* the tiered cache. |
412 |
|
|
*/ |
413 |
|
|
std::set<std::string> constructed_instances_; |
414 |
|
|
std::string nfs_maps_dir_; |
415 |
|
|
/** |
416 |
|
|
* Combination of kNfs... flags |
417 |
|
|
*/ |
418 |
|
|
unsigned nfs_mode_; |
419 |
|
|
CacheManager *cache_mgr_; |
420 |
|
|
/** |
421 |
|
|
* Persistent for the cache directory + name combination. It is used in the |
422 |
|
|
* Geo-API to allow for per-client responses when no proxy is used. |
423 |
|
|
*/ |
424 |
|
|
cvmfs::Uuid *uuid_cache_; |
425 |
|
|
|
426 |
|
|
/** |
427 |
|
|
* TODO(jblomer): Move to MountPoint. Tricky because of the sqlite maps |
428 |
|
|
* and the sqlite configuration done for the file catalogs. |
429 |
|
|
*/ |
430 |
|
|
NfsMaps *nfs_maps_; |
431 |
|
|
/** |
432 |
|
|
* Used internally to remember if the Sqlite memory manager need to be shut |
433 |
|
|
* down. |
434 |
|
|
*/ |
435 |
|
|
bool has_custom_sqlitevfs_; |
436 |
|
|
}; |
437 |
|
|
|
438 |
|
|
/** |
439 |
|
|
* The StatfsCache class is a class purely designed as "struct" (= holding |
440 |
|
|
* object for all its parameters). |
441 |
|
|
* All its logic, including the locking mechanism, is implemented in the |
442 |
|
|
* function cvmfs_statfs in cvmfs.cc |
443 |
|
|
*/ |
444 |
|
|
class StatfsCache : SingleCopy { |
445 |
|
|
public: |
446 |
|
46 |
explicit StatfsCache(uint64_t cacheValid) : expiry_deadline_(0), |
447 |
|
23 |
cache_timeout_(cacheValid) { |
448 |
|
23 |
memset(&info_, 0, sizeof(info_)); |
449 |
|
23 |
lock_ = |
450 |
|
23 |
reinterpret_cast<pthread_mutex_t *>(smalloc(sizeof(pthread_mutex_t))); |
451 |
|
23 |
int retval = pthread_mutex_init(lock_, NULL); |
452 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 |
assert(retval == 0); |
453 |
|
23 |
} |
454 |
|
23 |
~StatfsCache() { |
455 |
|
23 |
pthread_mutex_destroy(lock_); |
456 |
|
23 |
free(lock_); |
457 |
|
23 |
} |
458 |
|
✗ |
uint64_t *expiry_deadline() { return &expiry_deadline_; } |
459 |
|
✗ |
const uint64_t cache_timeout() { return cache_timeout_; } |
460 |
|
✗ |
struct statvfs *info() { return &info_; } |
461 |
|
✗ |
pthread_mutex_t *lock() { return lock_; } |
462 |
|
|
|
463 |
|
|
private: |
464 |
|
|
pthread_mutex_t *lock_; |
465 |
|
|
// Timestamp/deadline when the currently cached statvfs info_ becomes invalid |
466 |
|
|
uint64_t expiry_deadline_; |
467 |
|
|
// Time in seconds how long statvfs info_ should be cached |
468 |
|
|
uint64_t cache_timeout_; |
469 |
|
|
struct statvfs info_; |
470 |
|
|
}; |
471 |
|
|
|
472 |
|
|
/** |
473 |
|
|
* A MountPoint provides a clip around all the different *Manager objects that |
474 |
|
|
* in combination represent a mounted cvmfs repository. Its main purpose is |
475 |
|
|
* the controlled construction and deconstruction of the involved ensemble of |
476 |
|
|
* classes based on the information passed from an options manager. |
477 |
|
|
* |
478 |
|
|
* A MountPoint is constructed on top of a successfully constructed FileSystem. |
479 |
|
|
* |
480 |
|
|
* We use pointers to manager classes to make the order of construction and |
481 |
|
|
* destruction explicit and also to keep the include list for this header small. |
482 |
|
|
*/ |
483 |
|
|
class MountPoint : SingleCopy, public BootFactory { |
484 |
|
|
public: |
485 |
|
|
/** |
486 |
|
|
* If catalog reload fails, try again in 3 minutes |
487 |
|
|
*/ |
488 |
|
|
static const unsigned kShortTermTTL = 180; |
489 |
|
|
static const time_t kIndefiniteDeadline = time_t(-1); |
490 |
|
|
|
491 |
|
|
static MountPoint *Create(const std::string &fqrn, |
492 |
|
|
FileSystem *file_system, |
493 |
|
|
OptionsManager *options_mgr = NULL); |
494 |
|
|
~MountPoint(); |
495 |
|
|
|
496 |
|
|
unsigned GetMaxTtlMn(); |
497 |
|
|
unsigned GetEffectiveTtlSec(); |
498 |
|
|
void SetMaxTtlMn(unsigned value_minutes); |
499 |
|
|
void ReEvaluateAuthz(); |
500 |
|
|
|
501 |
|
✗ |
AuthzSessionManager *authz_session_mgr() { return authz_session_mgr_; } |
502 |
|
✗ |
BackoffThrottle *backoff_throttle() { return backoff_throttle_; } |
503 |
|
56 |
catalog::ClientCatalogManager *catalog_mgr() { return catalog_mgr_; } |
504 |
|
✗ |
ChunkTables *chunk_tables() { return chunk_tables_; } |
505 |
|
5 |
download::DownloadManager *download_mgr() { return download_mgr_; } |
506 |
|
4 |
download::DownloadManager *external_download_mgr() { |
507 |
|
4 |
return external_download_mgr_; |
508 |
|
|
} |
509 |
|
✗ |
file_watcher::FileWatcher* resolv_conf_watcher() { |
510 |
|
✗ |
return resolv_conf_watcher_; |
511 |
|
|
} |
512 |
|
32 |
cvmfs::Fetcher *fetcher() { return fetcher_; } |
513 |
|
✗ |
bool fixed_catalog() { return fixed_catalog_; } |
514 |
|
34 |
std::string fqrn() const { return fqrn_; } |
515 |
|
|
// TODO(jblomer): use only a singler fetcher object |
516 |
|
✗ |
cvmfs::Fetcher *external_fetcher() { return external_fetcher_; } |
517 |
|
32 |
FileSystem *file_system() { return file_system_; } |
518 |
|
✗ |
MagicXattrManager *magic_xattr_mgr() { return magic_xattr_mgr_; } |
519 |
|
1 |
bool has_membership_req() { return has_membership_req_; } |
520 |
|
✗ |
bool enforce_acls() { return enforce_acls_; } |
521 |
|
✗ |
bool cache_symlinks() { return cache_symlinks_; } |
522 |
|
✗ |
bool fuse_expire_entry() { return fuse_expire_entry_; } |
523 |
|
✗ |
catalog::InodeAnnotation *inode_annotation() { |
524 |
|
✗ |
return inode_annotation_; |
525 |
|
|
} |
526 |
|
✗ |
glue::InodeTracker *inode_tracker() { return inode_tracker_; } |
527 |
|
✗ |
lru::InodeCache *inode_cache() { return inode_cache_; } |
528 |
|
✗ |
double kcache_timeout_sec() { return kcache_timeout_sec_; } |
529 |
|
46 |
lru::Md5PathCache *md5path_cache() { return md5path_cache_; } |
530 |
|
✗ |
std::string membership_req() { return membership_req_; } |
531 |
|
✗ |
glue::DentryTracker *dentry_tracker() { return dentry_tracker_; } |
532 |
|
✗ |
glue::PageCacheTracker *page_cache_tracker() { return page_cache_tracker_; } |
533 |
|
✗ |
lru::PathCache *path_cache() { return path_cache_; } |
534 |
|
✗ |
std::string repository_tag() { return repository_tag_; } |
535 |
|
✗ |
SimpleChunkTables *simple_chunk_tables() { return simple_chunk_tables_; } |
536 |
|
96 |
perf::Statistics *statistics() { return statistics_; } |
537 |
|
✗ |
perf::TelemetryAggregator *telemetry_aggr() { return telemetry_aggr_; } |
538 |
|
32 |
signature::SignatureManager *signature_mgr() { return signature_mgr_; } |
539 |
|
✗ |
uid_t talk_socket_uid() { return talk_socket_uid_; } |
540 |
|
✗ |
gid_t talk_socket_gid() { return talk_socket_gid_; } |
541 |
|
✗ |
std::string talk_socket_path() { return talk_socket_path_; } |
542 |
|
✗ |
Tracer *tracer() { return tracer_; } |
543 |
|
✗ |
cvmfs::Uuid *uuid() { return uuid_; } |
544 |
|
✗ |
StatfsCache *statfs_cache() { return statfs_cache_; } |
545 |
|
|
|
546 |
|
|
bool ReloadBlacklists(); |
547 |
|
|
void DisableCacheSymlinks(); |
548 |
|
|
void EnableFuseExpireEntry(); |
549 |
|
|
|
550 |
|
|
private: |
551 |
|
|
/** |
552 |
|
|
* The maximum TTL can be used to cap a root catalogs registered ttl. By |
553 |
|
|
* default this is disabled (= 0). |
554 |
|
|
*/ |
555 |
|
|
static const unsigned kDefaultMaxTtlSec = 0; |
556 |
|
|
/** |
557 |
|
|
* Let fuse cache dentries for 1 minute. |
558 |
|
|
*/ |
559 |
|
|
static const unsigned kDefaultKCacheTtlSec = 60; |
560 |
|
|
/** |
561 |
|
|
* Number of Md5Path entries in the libcvmfs cache. |
562 |
|
|
*/ |
563 |
|
|
static const unsigned kLibPathCacheSize = 32000; |
564 |
|
|
/** |
565 |
|
|
* Cache seven times more md5 paths than inodes in the fuse module. |
566 |
|
|
*/ |
567 |
|
|
static const unsigned kInodeCacheFactor = 7; |
568 |
|
|
/** |
569 |
|
|
* Default to 16M RAM for meta-data caches; does not include the inode tracker |
570 |
|
|
*/ |
571 |
|
|
static const unsigned kDefaultMemcacheSize = 16 * 1024 * 1024; |
572 |
|
|
/** |
573 |
|
|
* Where to look for external authz helpers. |
574 |
|
|
*/ |
575 |
|
|
static const char *kDefaultAuthzSearchPath; // "/usr/libexec/cvmfs/authz" |
576 |
|
|
/** |
577 |
|
|
* Maximum number of concurrent HTTP connections. |
578 |
|
|
*/ |
579 |
|
|
static const unsigned kDefaultNumConnections = 16; |
580 |
|
|
/** |
581 |
|
|
* Default network timeout |
582 |
|
|
*/ |
583 |
|
|
static const unsigned kDefaultTimeoutSec = 5; |
584 |
|
|
static const unsigned kDefaultRetries = 1; |
585 |
|
|
static const unsigned kDefaultBackoffInitMs = 2000; |
586 |
|
|
static const unsigned kDefaultBackoffMaxMs = 10000; |
587 |
|
|
/** |
588 |
|
|
* Memory buffer sizes for an activated tracer |
589 |
|
|
*/ |
590 |
|
|
static const unsigned kTracerBufferSize = 8192; |
591 |
|
|
static const unsigned kTracerFlushThreshold = 7000; |
592 |
|
|
static const char *kDefaultBlacklist; // "/etc/cvmfs/blacklist" |
593 |
|
|
/** |
594 |
|
|
* Default values for telemetry aggregator |
595 |
|
|
*/ |
596 |
|
|
static const int kDefaultTelemetrySendRateSec = 5 * 60; // 5min |
597 |
|
|
static const int kMinimumTelemetrySendRateSec = 5; // 5sec |
598 |
|
|
|
599 |
|
|
MountPoint(const std::string &fqrn, |
600 |
|
|
FileSystem *file_system, |
601 |
|
|
OptionsManager *options_mgr); |
602 |
|
|
|
603 |
|
|
void CreateStatistics(); |
604 |
|
|
void CreateAuthz(); |
605 |
|
|
bool CreateSignatureManager(); |
606 |
|
|
bool CheckBlacklists(); |
607 |
|
|
bool CreateDownloadManagers(); |
608 |
|
|
bool CreateResolvConfWatcher(); |
609 |
|
|
void CreateFetchers(); |
610 |
|
|
bool CreateCatalogManager(); |
611 |
|
|
void CreateTables(); |
612 |
|
|
bool CreateTracer(); |
613 |
|
|
bool SetupBehavior(); |
614 |
|
|
void SetupDnsTuning(download::DownloadManager *manager); |
615 |
|
|
void SetupHttpTuning(); |
616 |
|
|
bool SetupExternalDownloadMgr(bool dogeosort); |
617 |
|
|
void SetupInodeAnnotation(); |
618 |
|
|
bool SetupOwnerMaps(); |
619 |
|
|
bool DetermineRootHash(shash::Any *root_hash); |
620 |
|
|
bool FetchHistory(std::string *history_path); |
621 |
|
|
std::string ReplaceHosts(std::string hosts); |
622 |
|
|
std::string GetUniqFileSuffix(); |
623 |
|
|
|
624 |
|
|
std::string fqrn_; |
625 |
|
|
cvmfs::Uuid *uuid_; |
626 |
|
|
/** |
627 |
|
|
* In contrast to the manager objects, the FileSystem is not owned. |
628 |
|
|
*/ |
629 |
|
|
FileSystem *file_system_; |
630 |
|
|
/** |
631 |
|
|
* The options manager is not owned. |
632 |
|
|
*/ |
633 |
|
|
OptionsManager *options_mgr_; |
634 |
|
|
|
635 |
|
|
perf::Statistics *statistics_; |
636 |
|
|
perf::TelemetryAggregator *telemetry_aggr_; |
637 |
|
|
AuthzFetcher *authz_fetcher_; |
638 |
|
|
AuthzSessionManager *authz_session_mgr_; |
639 |
|
|
AuthzAttachment *authz_attachment_; |
640 |
|
|
BackoffThrottle *backoff_throttle_; |
641 |
|
|
signature::SignatureManager *signature_mgr_; |
642 |
|
|
download::DownloadManager *download_mgr_; |
643 |
|
|
download::DownloadManager *external_download_mgr_; |
644 |
|
|
cvmfs::Fetcher *fetcher_; |
645 |
|
|
cvmfs::Fetcher *external_fetcher_; |
646 |
|
|
catalog::InodeAnnotation *inode_annotation_; |
647 |
|
|
catalog::ClientCatalogManager *catalog_mgr_; |
648 |
|
|
ChunkTables *chunk_tables_; |
649 |
|
|
SimpleChunkTables *simple_chunk_tables_; |
650 |
|
|
lru::InodeCache *inode_cache_; |
651 |
|
|
lru::PathCache *path_cache_; |
652 |
|
|
lru::Md5PathCache *md5path_cache_; |
653 |
|
|
Tracer *tracer_; |
654 |
|
|
glue::InodeTracker *inode_tracker_; |
655 |
|
|
glue::DentryTracker *dentry_tracker_; |
656 |
|
|
glue::PageCacheTracker *page_cache_tracker_; |
657 |
|
|
MagicXattrManager *magic_xattr_mgr_; |
658 |
|
|
StatfsCache *statfs_cache_; |
659 |
|
|
|
660 |
|
|
file_watcher::FileWatcher* resolv_conf_watcher_; |
661 |
|
|
|
662 |
|
|
unsigned max_ttl_sec_; |
663 |
|
|
pthread_mutex_t lock_max_ttl_; |
664 |
|
|
double kcache_timeout_sec_; |
665 |
|
|
bool fixed_catalog_; |
666 |
|
|
bool enforce_acls_; |
667 |
|
|
bool cache_symlinks_; |
668 |
|
|
bool fuse_expire_entry_; |
669 |
|
|
std::string repository_tag_; |
670 |
|
|
std::vector<std::string> blacklist_paths_; |
671 |
|
|
|
672 |
|
|
// TODO(jblomer): this should go in the catalog manager |
673 |
|
|
std::string membership_req_; |
674 |
|
|
bool has_membership_req_; |
675 |
|
|
|
676 |
|
|
std::string talk_socket_path_; |
677 |
|
|
uid_t talk_socket_uid_; |
678 |
|
|
gid_t talk_socket_gid_; |
679 |
|
|
}; // class MointPoint |
680 |
|
|
|
681 |
|
|
#endif // CVMFS_MOUNTPOINT_H_ |
682 |
|
|
|