| Directory: | cvmfs/ |
|---|---|
| File: | cvmfs/mountpoint.cc |
| Date: | 2025-11-30 02:35:17 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 954 | 1351 | 70.6% |
| Branches: | 1221 | 3030 | 40.3% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * This file is part of the CernVM File System. | ||
| 3 | */ | ||
| 4 | |||
| 5 | #include "mountpoint.h" | ||
| 6 | |||
| 7 | #include <errno.h> | ||
| 8 | #include <fcntl.h> | ||
| 9 | #include <inttypes.h> | ||
| 10 | #include <stdint.h> | ||
| 11 | #include <unistd.h> | ||
| 12 | |||
| 13 | #include <algorithm> | ||
| 14 | #include <cassert> | ||
| 15 | #include <climits> | ||
| 16 | #include <cstring> | ||
| 17 | #include <vector> | ||
| 18 | |||
| 19 | #include "duplex_fuse.h" // NOLINT | ||
| 20 | |||
| 21 | #ifndef CVMFS_LIBCVMFS | ||
| 22 | #ifdef FUSE_CAP_EXPORT_SUPPORT | ||
| 23 | #define CVMFS_NFS_SUPPORT | ||
| 24 | #else | ||
| 25 | #warning "No NFS support, Fuse too old" | ||
| 26 | #endif | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #include "authz/authz_curl.h" | ||
| 30 | #include "authz/authz_fetch.h" | ||
| 31 | #include "authz/authz_session.h" | ||
| 32 | #include "backoff.h" | ||
| 33 | #include "cache.h" | ||
| 34 | #include "cache_extern.h" | ||
| 35 | #include "cache_posix.h" | ||
| 36 | #include "cache_ram.h" | ||
| 37 | #include "cache_stream.h" | ||
| 38 | #include "cache_tiered.h" | ||
| 39 | #include "catalog.h" | ||
| 40 | #include "catalog_mgr_client.h" | ||
| 41 | #include "clientctx.h" | ||
| 42 | #include "crypto/signature.h" | ||
| 43 | #include "duplex_sqlite3.h" | ||
| 44 | #include "fetch.h" | ||
| 45 | #include "file_chunk.h" | ||
| 46 | #include "globals.h" | ||
| 47 | #include "glue_buffer.h" | ||
| 48 | #include "google/protobuf/stubs/common.h" | ||
| 49 | #include "history.h" | ||
| 50 | #include "history_sqlite.h" | ||
| 51 | #include "lru_md.h" | ||
| 52 | #include "manifest.h" | ||
| 53 | #include "manifest_fetch.h" | ||
| 54 | #include "network/download.h" | ||
| 55 | #include "nfs_maps.h" | ||
| 56 | #ifdef CVMFS_NFS_SUPPORT | ||
| 57 | #include "nfs_maps_leveldb.h" | ||
| 58 | #include "nfs_maps_sqlite.h" | ||
| 59 | #endif | ||
| 60 | #include "options.h" | ||
| 61 | #include "quota_posix.h" | ||
| 62 | #include "resolv_conf_event_handler.h" | ||
| 63 | #include "sqlitemem.h" | ||
| 64 | #include "sqlitevfs.h" | ||
| 65 | #include "statistics.h" | ||
| 66 | #include "telemetry_aggregator.h" | ||
| 67 | #include "tracer.h" | ||
| 68 | #include "util/concurrency.h" | ||
| 69 | #include "util/logging.h" | ||
| 70 | #include "util/platform.h" | ||
| 71 | #include "util/pointer.h" | ||
| 72 | #include "util/posix.h" | ||
| 73 | #include "util/string.h" | ||
| 74 | #include "util/uuid.h" | ||
| 75 | #include "wpad.h" | ||
| 76 | |||
| 77 | using namespace std; // NOLINT | ||
| 78 | |||
| 79 | |||
| 80 | bool FileSystem::g_alive = false; | ||
| 81 | const char *FileSystem::kDefaultCacheBase = "/var/lib/cvmfs"; | ||
| 82 | const char *FileSystem::kDefaultCacheMgrInstance = "default"; | ||
| 83 | |||
| 84 | |||
| 85 | 913 | FileSystem::IoErrorInfo::IoErrorInfo() : counter_(NULL), timestamp_last_(0) { } | |
| 86 | |||
| 87 | ✗ | void FileSystem::IoErrorInfo::Reset() { | |
| 88 | ✗ | counter_->Set(0); | |
| 89 | ✗ | timestamp_last_ = 0; | |
| 90 | } | ||
| 91 | |||
| 92 | ✗ | void FileSystem::IoErrorInfo::AddIoError() { | |
| 93 | ✗ | perf::Inc(counter_); | |
| 94 | ✗ | timestamp_last_ = time(NULL); | |
| 95 | } | ||
| 96 | |||
| 97 | 913 | void FileSystem::IoErrorInfo::SetCounter(perf::Counter *c) { counter_ = c; } | |
| 98 | |||
| 99 | ✗ | int64_t FileSystem::IoErrorInfo::count() { return counter_->Get(); } | |
| 100 | |||
| 101 | ✗ | time_t FileSystem::IoErrorInfo::timestamp_last() { return timestamp_last_; } | |
| 102 | |||
| 103 | |||
| 104 | /** | ||
| 105 | * A cache instance name is part of a bash parameter and can only contain | ||
| 106 | * certain characters. | ||
| 107 | */ | ||
| 108 | 240 | bool FileSystem::CheckInstanceName(const std::string &instance) { | |
| 109 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 2 taken 225 times.
|
240 | if (instance.length() > 24) |
| 110 | 15 | return false; | |
| 111 |
1/2✓ Branch 1 taken 225 times.
✗ Branch 2 not taken.
|
225 | const sanitizer::CacheInstanceSanitizer instance_sanitizer; |
| 112 |
3/4✓ Branch 1 taken 225 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 195 times.
|
225 | if (!instance_sanitizer.IsValid(instance)) { |
| 113 |
2/4✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
|
60 | boot_error_ = "invalid instance name (" + instance + "), " |
| 114 |
1/2✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
|
30 | + "only characters a-z, A-Z, 0-9, _ are allowed"; |
| 115 | 30 | boot_status_ = loader::kFailCacheDir; | |
| 116 | 30 | return false; | |
| 117 | } | ||
| 118 | 195 | return true; | |
| 119 | 225 | } | |
| 120 | |||
| 121 | |||
| 122 | /** | ||
| 123 | * Not all possible combinations of cache flags / modes are valid. | ||
| 124 | */ | ||
| 125 | 895 | bool FileSystem::CheckPosixCacheSettings( | |
| 126 | const FileSystem::PosixCacheSettings &settings) { | ||
| 127 |
4/4✓ Branch 0 taken 141 times.
✓ Branch 1 taken 754 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 96 times.
|
895 | if (settings.is_alien && settings.is_shared) { |
| 128 | boot_error_ = "Failure: shared local disk cache and alien cache mutually " | ||
| 129 | 45 | "exclusive. Please turn off shared local disk cache."; | |
| 130 | 45 | boot_status_ = loader::kFailOptions; | |
| 131 | 45 | return false; | |
| 132 | } | ||
| 133 |
4/4✓ Branch 0 taken 96 times.
✓ Branch 1 taken 754 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 66 times.
|
850 | if (settings.is_alien && settings.is_managed) { |
| 134 | boot_error_ = "Failure: quota management and alien cache mutually " | ||
| 135 | 30 | "exclusive. Please turn off quota limit."; | |
| 136 | 30 | boot_status_ = loader::kFailOptions; | |
| 137 | 30 | return false; | |
| 138 | } | ||
| 139 | |||
| 140 |
2/2✓ Branch 0 taken 66 times.
✓ Branch 1 taken 754 times.
|
820 | if (type_ == kFsLibrary) { |
| 141 |
3/4✓ Branch 0 taken 51 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
|
66 | if (settings.is_shared || settings.is_managed) { |
| 142 | boot_error_ = "Failure: libcvmfs supports only unmanaged exclusive cache " | ||
| 143 | 15 | "or alien cache."; | |
| 144 | 15 | boot_status_ = loader::kFailOptions; | |
| 145 | 15 | return false; | |
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 |
4/4✓ Branch 0 taken 709 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 694 times.
|
805 | if (settings.cache_base_defined && settings.cache_dir_defined) { |
| 150 | boot_error_ = "'CVMFS_CACHE_BASE' and 'CVMFS_CACHE_DIR' are mutually " | ||
| 151 | 15 | "exclusive"; | |
| 152 | 15 | boot_status_ = loader::kFailOptions; | |
| 153 | 15 | return false; | |
| 154 | } | ||
| 155 | |||
| 156 | 790 | return true; | |
| 157 | } | ||
| 158 | |||
| 159 | |||
| 160 | /** | ||
| 161 | * Creation of state and manager classes. The destructor should mirror this | ||
| 162 | * method. | ||
| 163 | */ | ||
| 164 | 913 | FileSystem *FileSystem::Create(const FileSystem::FileSystemInfo &fs_info) { | |
| 165 |
3/6✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 913 times.
✗ Branch 8 not taken.
|
913 | UniquePtr<FileSystem> file_system(new FileSystem(fs_info)); |
| 166 | |||
| 167 |
1/2✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
|
913 | file_system->SetupLogging(); |
| 168 |
1/2✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
|
913 | LogCvmfs(kLogCvmfs, kLogDebug, "Options:\n%s", |
| 169 |
1/2✓ Branch 3 taken 913 times.
✗ Branch 4 not taken.
|
1826 | file_system->options_mgr()->Dump().c_str()); |
| 170 | |||
| 171 |
1/2✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
|
913 | file_system->CreateStatistics(); |
| 172 |
1/2✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
|
913 | file_system->SetupSqlite(); |
| 173 |
2/4✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 913 times.
|
913 | if (!file_system->DetermineNfsMode()) |
| 174 | ✗ | return file_system.Release(); | |
| 175 |
3/4✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 895 times.
|
913 | if (!file_system->SetupWorkspace()) |
| 176 | 18 | return file_system.Release(); | |
| 177 | |||
| 178 | // Redirect SQlite temp directory to workspace (global variable) | ||
| 179 | 895 | const unsigned length_tempdir = file_system->workspace_.length() + 1; | |
| 180 |
1/2✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
|
895 | sqlite3_temp_directory = static_cast<char *>(sqlite3_malloc(length_tempdir)); |
| 181 | 895 | snprintf(sqlite3_temp_directory, | |
| 182 | length_tempdir, | ||
| 183 | "%s", | ||
| 184 | 895 | file_system->workspace_.c_str()); | |
| 185 | |||
| 186 |
3/4✓ Branch 2 taken 895 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✓ Branch 5 taken 760 times.
|
895 | if (!file_system->TriageCacheMgr()) |
| 187 | 135 | return file_system.Release(); | |
| 188 |
1/2✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
|
760 | file_system->SetupUuid(); |
| 189 |
1/4✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
760 | if (!file_system->SetupNfsMaps()) |
| 190 | ✗ | return file_system.Release(); | |
| 191 |
1/2✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
|
760 | const bool retval = sqlite::RegisterVfsRdOnly(file_system->cache_mgr_, |
| 192 | 760 | file_system->statistics_, | |
| 193 | sqlite::kVfsOptDefault); | ||
| 194 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
|
760 | assert(retval); |
| 195 | 760 | file_system->has_custom_sqlitevfs_ = true; | |
| 196 | |||
| 197 |
1/2✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
|
760 | ClientCtx::GetInstance(); |
| 198 | |||
| 199 | 760 | file_system->boot_status_ = loader::kFailOk; | |
| 200 | 760 | return file_system.Release(); | |
| 201 | 913 | } | |
| 202 | |||
| 203 | |||
| 204 | 913 | void FileSystem::CreateStatistics() { | |
| 205 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | statistics_ = new perf::Statistics(); |
| 206 | |||
| 207 | // Register the ShortString's static counters | ||
| 208 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | statistics_->Register("pathstring.n_instances", "Number of instances"); |
| 209 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | statistics_->Register("pathstring.n_overflows", "Number of overflows"); |
| 210 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | statistics_->Register("namestring.n_instances", "Number of instances"); |
| 211 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | statistics_->Register("namestring.n_overflows", "Number of overflows"); |
| 212 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | statistics_->Register("linkstring.n_instances", "Number of instances"); |
| 213 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | statistics_->Register("linkstring.n_overflows", "Number of overflows"); |
| 214 | |||
| 215 | // Callback counters | ||
| 216 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_open_ = statistics_->Register("cvmfs.n_fs_open", |
| 217 | "Overall number of file open operations"); | ||
| 218 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_dir_open_ = statistics_->Register( |
| 219 | "cvmfs.n_fs_dir_open", "Overall number of directory open operations"); | ||
| 220 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_lookup_ = statistics_->Register("cvmfs.n_fs_lookup", |
| 221 | "Number of lookups"); | ||
| 222 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_lookup_negative_ = statistics_->Register("cvmfs.n_fs_lookup_negative", |
| 223 | "Number of negative lookups"); | ||
| 224 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_stat_ = statistics_->Register("cvmfs.n_fs_stat", "Number of stats"); |
| 225 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_stat_stale_ = statistics_->Register( |
| 226 | "cvmfs.n_fs_stat_stale", | ||
| 227 | "Number of stats for stale (open, meanwhile changed) regular files"); | ||
| 228 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_statfs_ = statistics_->Register("cvmfs.n_fs_statfs", |
| 229 | "Overall number of statsfs calls"); | ||
| 230 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_statfs_cached_ = statistics_->Register( |
| 231 | "cvmfs.n_fs_statfs_cached", | ||
| 232 | "Number of statsfs calls that accessed the cached statfs info"); | ||
| 233 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_read_ = statistics_->Register("cvmfs.n_fs_read", "Number of files read"); |
| 234 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_readlink_ = statistics_->Register("cvmfs.n_fs_readlink", |
| 235 | "Number of links read"); | ||
| 236 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_forget_ = statistics_->Register("cvmfs.n_fs_forget", |
| 237 | "Number of inode forgets"); | ||
| 238 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_fs_inode_replace_ = statistics_->Register( |
| 239 | "cvmfs.n_fs_inode_replace", | ||
| 240 | "Number of stale inodes that got replaced by an up-to-date version"); | ||
| 241 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | no_open_files_ = statistics_->Register("cvmfs.no_open_files", |
| 242 | "Number of currently opened files"); | ||
| 243 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | no_open_dirs_ = statistics_->Register( |
| 244 | "cvmfs.no_open_dirs", "Number of currently opened directories"); | ||
| 245 |
3/6✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 913 times.
✗ Branch 9 not taken.
|
913 | io_error_info_.SetCounter( |
| 246 | 913 | statistics_->Register("cvmfs.n_io_error", "Number of I/O errors")); | |
| 247 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_total_ = statistics_->Register( |
| 248 | "eio.total", | ||
| 249 | "EIO returned to calling process. Sum of individual eio counters"); | ||
| 250 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_01_ = statistics_->Register( |
| 251 | "eio.01", "EIO returned by cvmfs.cc:cvmfs_lookup() - lookup failed"); | ||
| 252 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_02_ = statistics_->Register("eio.02", |
| 253 | "EIO returned by cvmfs.cc:ReplyNegative() " | ||
| 254 | "- CVMFS-specific metadata not found"); | ||
| 255 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_03_ = statistics_->Register( |
| 256 | "eio.03", | ||
| 257 | "EIO returned by cvmfs.cc:cvmfs_opendir() - failed to open directory "); | ||
| 258 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_04_ = statistics_->Register("eio.04", |
| 259 | "EIO returned by cvmfs.cc:cvmfs_open() " | ||
| 260 | "- chunked file does not have any chunks"); | ||
| 261 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_05_ = statistics_->Register( |
| 262 | "eio.05", | ||
| 263 | "EIO returned by cvmfs.cc:cvmfs_read() - failed to fetch chunk"); | ||
| 264 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_06_ = statistics_->Register( |
| 265 | "eio.06", "EIO returned by cvmfs.cc:cvmfs_open() - failed to open file"); | ||
| 266 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_07_ = statistics_->Register( |
| 267 | "eio.07", "EIO returned by cvmfs.cc:cvmfs_read() - failed to read chunk"); | ||
| 268 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_eio_08_ = statistics_->Register( |
| 269 | "eio.08", "EIO returned by cvmfs.cc:cvmfs_read() - failed to read file"); | ||
| 270 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 913 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 913 times.
✗ Branch 10 not taken.
|
913 | n_emfile_ = statistics_->Register( |
| 271 | "eio.emfile", | ||
| 272 | "EMFILE returned by cvmfs.cc:cvmfs_read(): too many open files"); | ||
| 273 | |||
| 274 | 913 | string optarg; | |
| 275 |
3/10✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 913 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1826 | if (options_mgr_->GetValue("CVMFS_INSTRUMENT_FUSE", &optarg) |
| 276 |
3/10✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 913 times.
✗ Branch 12 not taken.
|
1826 | && options_mgr_->IsOn(optarg)) { |
| 277 | ✗ | HighPrecisionTimer::g_is_enabled = true; | |
| 278 | } | ||
| 279 | |||
| 280 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_lookup_ = new Log2Histogram(30); |
| 281 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_forget_ = new Log2Histogram(30); |
| 282 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_forget_multi_ = new Log2Histogram(30); |
| 283 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_getattr_ = new Log2Histogram(30); |
| 284 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_readlink_ = new Log2Histogram(30); |
| 285 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_opendir_ = new Log2Histogram(30); |
| 286 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_releasedir_ = new Log2Histogram(30); |
| 287 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_readdir_ = new Log2Histogram(30); |
| 288 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_open_ = new Log2Histogram(30); |
| 289 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_read_ = new Log2Histogram(30); |
| 290 |
2/4✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
|
913 | hist_fs_release_ = new Log2Histogram(30); |
| 291 | 913 | } | |
| 292 | |||
| 293 | |||
| 294 | /** | ||
| 295 | * Figure out mode of operation and cache directory. Checking options for | ||
| 296 | * sanity is in a separate method. | ||
| 297 | */ | ||
| 298 | 775 | FileSystem::PosixCacheSettings FileSystem::DeterminePosixCacheSettings( | |
| 299 | const string &instance) { | ||
| 300 | 775 | string optarg; | |
| 301 | 775 | PosixCacheSettings settings; | |
| 302 | |||
| 303 |
5/16✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 775 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 775 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 775 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 775 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1550 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_REFCOUNT", instance), |
| 304 | &optarg) | ||
| 305 |
3/10✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 775 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 775 times.
✗ Branch 12 not taken.
|
1550 | && options_mgr_->IsOff(optarg)) { |
| 306 | ✗ | settings.do_refcount = false; | |
| 307 | } | ||
| 308 | |||
| 309 | 3100 | if (options_mgr_->GetValue( | |
| 310 |
5/16✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 775 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 775 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 775 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 775 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1550 | MkCacheParm("CVMFS_CACHE_CLEANUP_NONOPENLRU", instance), &optarg) |
| 311 |
3/10✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 775 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 775 times.
✗ Branch 12 not taken.
|
1550 | && options_mgr_->IsOn(optarg)) { |
| 312 | // Enable this policy only in a refcounted cache. | ||
| 313 | // Because it's the reference counter who will say if a file is open. | ||
| 314 | ✗ | settings.cleanup_unused_first = settings.do_refcount; | |
| 315 | } | ||
| 316 | |||
| 317 |
6/16✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 775 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 775 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 775 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 30 times.
✓ Branch 14 taken 745 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1550 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SHARED", instance), |
| 318 | &optarg) | ||
| 319 |
7/10✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 649 times.
✓ Branch 5 taken 126 times.
✓ Branch 7 taken 649 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 30 times.
✓ Branch 10 taken 619 times.
✓ Branch 11 taken 775 times.
✗ Branch 12 not taken.
|
1550 | && options_mgr_->IsOn(optarg)) { |
| 320 | 30 | settings.is_shared = true; | |
| 321 | } | ||
| 322 |
5/16✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 775 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 775 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 775 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 775 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1550 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SERVER_MODE", instance), |
| 323 | &optarg) | ||
| 324 |
3/10✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 775 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 775 times.
✗ Branch 12 not taken.
|
1550 | && options_mgr_->IsOn(optarg)) { |
| 325 | ✗ | settings.avoid_rename = true; | |
| 326 | } | ||
| 327 | |||
| 328 |
2/2✓ Branch 0 taken 709 times.
✓ Branch 1 taken 66 times.
|
775 | if (type_ == kFsFuse) |
| 329 | 709 | settings.quota_limit = kDefaultQuotaLimit; | |
| 330 |
5/8✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 775 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 775 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 165 times.
✓ Branch 14 taken 610 times.
|
775 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_QUOTA_LIMIT", instance), |
| 331 | &optarg)) { | ||
| 332 |
1/2✓ Branch 1 taken 165 times.
✗ Branch 2 not taken.
|
165 | settings.quota_limit = String2Int64(optarg) * 1024 * 1024; |
| 333 | } | ||
| 334 |
2/2✓ Branch 0 taken 589 times.
✓ Branch 1 taken 186 times.
|
775 | if (settings.quota_limit > 0) |
| 335 | 589 | settings.is_managed = true; | |
| 336 | |||
| 337 |
1/2✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
|
775 | settings.cache_path = kDefaultCacheBase; |
| 338 |
5/8✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 775 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 775 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 724 times.
✓ Branch 14 taken 51 times.
|
775 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_BASE", instance), |
| 339 | &optarg)) { | ||
| 340 |
1/2✓ Branch 1 taken 724 times.
✗ Branch 2 not taken.
|
724 | settings.cache_path = MakeCanonicalPath(optarg); |
| 341 | 724 | settings.cache_base_defined = true; | |
| 342 | } | ||
| 343 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 745 times.
|
775 | if (settings.is_shared) { |
| 344 |
1/2✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
|
30 | settings.cache_path += "/shared"; |
| 345 | } else { | ||
| 346 |
2/4✓ Branch 1 taken 745 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 745 times.
✗ Branch 5 not taken.
|
745 | settings.cache_path += "/" + name_; |
| 347 | } | ||
| 348 | |||
| 349 | // CheckCacheMode makes sure that CVMFS_CACHE_DIR and CVMFS_CACHE_BASE are | ||
| 350 | // not set at the same time. | ||
| 351 |
5/8✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 775 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 775 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 51 times.
✓ Branch 14 taken 724 times.
|
775 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_DIR", instance), |
| 352 | &optarg)) { | ||
| 353 | 51 | settings.cache_dir_defined = true; | |
| 354 |
1/2✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
|
51 | settings.cache_path = optarg; |
| 355 | } | ||
| 356 |
5/8✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 775 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 775 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 96 times.
✓ Branch 14 taken 679 times.
|
775 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_ALIEN", instance), |
| 357 | &optarg)) { | ||
| 358 | 96 | settings.is_alien = true; | |
| 359 |
1/2✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
|
96 | settings.cache_path = optarg; |
| 360 | } | ||
| 361 | // We already changed the cwd to the workspace | ||
| 362 | // Which is only done if using FUSE | ||
| 363 |
6/6✓ Branch 0 taken 709 times.
✓ Branch 1 taken 66 times.
✓ Branch 3 taken 619 times.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 619 times.
✓ Branch 6 taken 156 times.
|
775 | if ((type_ == kFsFuse) && (settings.cache_path == workspace_fullpath_)) { |
| 364 |
1/2✓ Branch 1 taken 619 times.
✗ Branch 2 not taken.
|
619 | settings.cache_path = "."; |
| 365 | } | ||
| 366 | |||
| 367 | // The cache workspace usually is the cache directory, unless explicitly | ||
| 368 | // set otherwise | ||
| 369 |
1/2✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
|
775 | settings.workspace = settings.cache_path; |
| 370 |
6/16✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 775 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 775 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 775 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 33 times.
✓ Branch 14 taken 742 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1550 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_WORKSPACE", instance), |
| 371 | &optarg) | ||
| 372 |
9/20✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 775 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 775 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 775 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 33 times.
✓ Branch 14 taken 742 times.
✓ Branch 15 taken 775 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 775 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 775 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
1550 | || options_mgr_->GetValue("CVMFS_WORKSPACE", &optarg)) { |
| 373 | // Used for the shared quota manager | ||
| 374 |
1/2✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
|
33 | settings.workspace = optarg; |
| 375 | } | ||
| 376 | |||
| 377 | 1550 | return settings; | |
| 378 | 775 | } | |
| 379 | |||
| 380 | |||
| 381 | 913 | bool FileSystem::DetermineNfsMode() { | |
| 382 | 913 | string optarg; | |
| 383 | |||
| 384 |
4/10✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 60 times.
✓ Branch 8 taken 853 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1826 | if (options_mgr_->GetValue("CVMFS_NFS_SOURCE", &optarg) |
| 385 |
6/10✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✓ Branch 5 taken 853 times.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 60 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 913 times.
✗ Branch 12 not taken.
|
1826 | && options_mgr_->IsOn(optarg)) { |
| 386 | 60 | nfs_mode_ |= kNfsMaps; | |
| 387 |
4/6✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 60 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 45 times.
✓ Branch 10 taken 15 times.
|
60 | if (options_mgr_->GetValue("CVMFS_NFS_SHARED", &optarg)) { |
| 388 | 45 | nfs_mode_ |= kNfsMapsHa; | |
| 389 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | nfs_maps_dir_ = optarg; |
| 390 | } | ||
| 391 | } | ||
| 392 | |||
| 393 |
3/4✓ Branch 0 taken 68 times.
✓ Branch 1 taken 845 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
|
913 | if ((type_ == kFsLibrary) && (nfs_mode_ != kNfsNone)) { |
| 394 | ✗ | boot_error_ = "Failure: libcvmfs does not support NFS export."; | |
| 395 | ✗ | boot_status_ = loader::kFailOptions; | |
| 396 | ✗ | return false; | |
| 397 | } | ||
| 398 | 913 | return true; | |
| 399 | 913 | } | |
| 400 | |||
| 401 | |||
| 402 | 913 | FileSystem::FileSystem(const FileSystem::FileSystemInfo &fs_info) | |
| 403 |
1/2✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
|
913 | : name_(fs_info.name) |
| 404 |
1/2✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
|
913 | , exe_path_(fs_info.exe_path) |
| 405 | 913 | , type_(fs_info.type) | |
| 406 | 913 | , options_mgr_(fs_info.options_mgr) | |
| 407 | 913 | , wait_workspace_(fs_info.wait_workspace) | |
| 408 | 913 | , foreground_(fs_info.foreground) | |
| 409 | 913 | , n_fs_open_(NULL) | |
| 410 | 913 | , n_fs_dir_open_(NULL) | |
| 411 | 913 | , n_fs_lookup_(NULL) | |
| 412 | 913 | , n_fs_lookup_negative_(NULL) | |
| 413 | 913 | , n_fs_stat_(NULL) | |
| 414 | 913 | , n_fs_stat_stale_(NULL) | |
| 415 | 913 | , n_fs_statfs_(NULL) | |
| 416 | 913 | , n_fs_statfs_cached_(NULL) | |
| 417 | 913 | , n_fs_read_(NULL) | |
| 418 | 913 | , n_fs_readlink_(NULL) | |
| 419 | 913 | , n_fs_forget_(NULL) | |
| 420 | 913 | , n_fs_inode_replace_(NULL) | |
| 421 | 913 | , no_open_files_(NULL) | |
| 422 | 913 | , no_open_dirs_(NULL) | |
| 423 | 913 | , n_eio_total_(NULL) | |
| 424 | 913 | , n_eio_01_(NULL) | |
| 425 | 913 | , n_eio_02_(NULL) | |
| 426 | 913 | , n_eio_03_(NULL) | |
| 427 | 913 | , n_eio_04_(NULL) | |
| 428 | 913 | , n_eio_05_(NULL) | |
| 429 | 913 | , n_eio_06_(NULL) | |
| 430 | 913 | , n_eio_07_(NULL) | |
| 431 | 913 | , n_eio_08_(NULL) | |
| 432 | 913 | , n_emfile_(NULL) | |
| 433 | 913 | , statistics_(NULL) | |
| 434 | 913 | , fd_workspace_lock_(-1) | |
| 435 | 913 | , found_previous_crash_(false) | |
| 436 | 913 | , nfs_mode_(kNfsNone) | |
| 437 | 913 | , cache_mgr_(NULL) | |
| 438 | 913 | , uuid_cache_(NULL) | |
| 439 | 913 | , nfs_maps_(NULL) | |
| 440 | 1826 | , has_custom_sqlitevfs_(false) { | |
| 441 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 913 times.
|
913 | assert(!g_alive); |
| 442 | 913 | g_alive = true; | |
| 443 | 913 | g_uid = geteuid(); | |
| 444 | 913 | g_gid = getegid(); | |
| 445 | |||
| 446 | 913 | string optarg; | |
| 447 | 3652 | if (options_mgr_->GetValue( | |
| 448 |
8/26✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 913 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 913 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 913 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 913 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 913 times.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 913 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
|
1826 | MkCacheParm("CVMFS_CACHE_SERVER_MODE", kDefaultCacheMgrInstance), |
| 449 | &optarg) | ||
| 450 |
3/10✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 913 times.
✗ Branch 12 not taken.
|
1826 | && options_mgr_->IsOn(optarg)) { |
| 451 | ✗ | g_raw_symlinks = true; | |
| 452 | } | ||
| 453 | 913 | } | |
| 454 | |||
| 455 | |||
| 456 | 909 | FileSystem::~FileSystem() { | |
| 457 | 909 | ClientCtx::CleanupInstance(); | |
| 458 | |||
| 459 |
2/2✓ Branch 0 taken 757 times.
✓ Branch 1 taken 152 times.
|
909 | if (has_custom_sqlitevfs_) |
| 460 | 757 | sqlite::UnregisterVfsRdOnly(); | |
| 461 | |||
| 462 |
2/2✓ Branch 0 taken 757 times.
✓ Branch 1 taken 152 times.
|
909 | delete uuid_cache_; |
| 463 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
|
909 | delete nfs_maps_; |
| 464 |
2/2✓ Branch 0 taken 757 times.
✓ Branch 1 taken 152 times.
|
909 | delete cache_mgr_; |
| 465 | |||
| 466 |
2/2✓ Branch 0 taken 892 times.
✓ Branch 1 taken 17 times.
|
909 | if (sqlite3_temp_directory) { |
| 467 | 892 | sqlite3_free(sqlite3_temp_directory); | |
| 468 | 892 | sqlite3_temp_directory = NULL; | |
| 469 | } | ||
| 470 | |||
| 471 |
2/2✓ Branch 1 taken 892 times.
✓ Branch 2 taken 17 times.
|
909 | if (!path_crash_guard_.empty()) |
| 472 | 892 | unlink(path_crash_guard_.c_str()); | |
| 473 |
2/2✓ Branch 1 taken 892 times.
✓ Branch 2 taken 17 times.
|
909 | if (!path_workspace_lock_.empty()) |
| 474 | 892 | unlink(path_workspace_lock_.c_str()); | |
| 475 |
2/2✓ Branch 0 taken 892 times.
✓ Branch 1 taken 17 times.
|
909 | if (fd_workspace_lock_ >= 0) |
| 476 | 892 | UnlockFile(fd_workspace_lock_); | |
| 477 | |||
| 478 | 909 | sqlite3_shutdown(); | |
| 479 | 909 | SqliteMemoryManager::CleanupInstance(); | |
| 480 | |||
| 481 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_lookup_; |
| 482 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_forget_multi_; |
| 483 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_forget_; |
| 484 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_getattr_; |
| 485 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_readlink_; |
| 486 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_opendir_; |
| 487 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_releasedir_; |
| 488 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_readdir_; |
| 489 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_open_; |
| 490 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_read_; |
| 491 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete hist_fs_release_; |
| 492 |
1/2✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
|
909 | delete statistics_; |
| 493 | |||
| 494 | 909 | SetLogSyslogPrefix(""); | |
| 495 | 909 | SetLogMicroSyslog(""); | |
| 496 | 909 | SetLogDebugFile(""); | |
| 497 | 909 | google::protobuf::ShutdownProtobufLibrary(); | |
| 498 | 909 | g_alive = false; | |
| 499 | 909 | } | |
| 500 | |||
| 501 | |||
| 502 | 896 | bool FileSystem::LockWorkspace() { | |
| 503 |
1/2✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
|
896 | path_workspace_lock_ = workspace_ + "/lock." + name_; |
| 504 | 896 | fd_workspace_lock_ = TryLockFile(path_workspace_lock_); | |
| 505 |
2/2✓ Branch 0 taken 895 times.
✓ Branch 1 taken 1 times.
|
896 | if (fd_workspace_lock_ >= 0) |
| 506 | 895 | return true; | |
| 507 | |||
| 508 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (fd_workspace_lock_ == -1) { |
| 509 | ✗ | boot_error_ = "could not acquire workspace lock (" + StringifyInt(errno) | |
| 510 | ✗ | + ")"; | |
| 511 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 512 | ✗ | return false; | |
| 513 | } | ||
| 514 | |||
| 515 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert(fd_workspace_lock_ == -2); |
| 516 | |||
| 517 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (!wait_workspace_) { |
| 518 | 1 | boot_status_ = loader::kFailLockWorkspace; | |
| 519 | 1 | return false; | |
| 520 | } | ||
| 521 | |||
| 522 | ✗ | fd_workspace_lock_ = LockFile(path_workspace_lock_); | |
| 523 | ✗ | if (fd_workspace_lock_ < 0) { | |
| 524 | ✗ | boot_error_ = "could not acquire workspace lock (" + StringifyInt(errno) | |
| 525 | ✗ | + ")"; | |
| 526 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 527 | ✗ | return false; | |
| 528 | } | ||
| 529 | ✗ | return true; | |
| 530 | } | ||
| 531 | |||
| 532 | |||
| 533 | 1827 | void FileSystem::LogSqliteError(void *user_data __attribute__((unused)), | |
| 534 | int sqlite_extended_error, | ||
| 535 | const char *message) { | ||
| 536 | 1827 | int log_dest = kLogDebug; | |
| 537 | 1827 | const int sqlite_error = sqlite_extended_error & 0xFF; | |
| 538 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1805 times.
|
1827 | switch (sqlite_error) { |
| 539 | 22 | case SQLITE_INTERNAL: | |
| 540 | case SQLITE_PERM: | ||
| 541 | case SQLITE_NOMEM: | ||
| 542 | case SQLITE_IOERR: | ||
| 543 | case SQLITE_CORRUPT: | ||
| 544 | case SQLITE_FULL: | ||
| 545 | case SQLITE_CANTOPEN: | ||
| 546 | case SQLITE_MISUSE: | ||
| 547 | case SQLITE_FORMAT: | ||
| 548 | case SQLITE_NOTADB: | ||
| 549 | 22 | log_dest |= kLogSyslogErr; | |
| 550 | 22 | break; | |
| 551 | 1805 | case SQLITE_WARNING: | |
| 552 | case SQLITE_NOTICE: | ||
| 553 | default: | ||
| 554 | 1805 | break; | |
| 555 | } | ||
| 556 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1827 | LogCvmfs(kLogCvmfs, log_dest, "SQlite3: %s (%d)", message, |
| 557 | sqlite_extended_error); | ||
| 558 | 1827 | } | |
| 559 | |||
| 560 | |||
| 561 | /** | ||
| 562 | * Creates the cache parameter for a specific instance of the cache. Injects | ||
| 563 | * the instance name such that CVMFS_CACHE_FOO_BAR becomes | ||
| 564 | * CVMFS_CACHE_<INSTANCE>_FOO_BAR | ||
| 565 | */ | ||
| 566 | 8893 | string FileSystem::MkCacheParm(const string &generic_parameter, | |
| 567 | const string &instance) { | ||
| 568 |
3/6✓ Branch 2 taken 8893 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8893 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 8893 times.
|
8893 | assert(HasPrefix(generic_parameter, "CVMFS_CACHE_", false)); |
| 569 | |||
| 570 |
2/2✓ Branch 1 taken 7498 times.
✓ Branch 2 taken 1395 times.
|
8893 | if (instance == kDefaultCacheMgrInstance) { |
| 571 | // Compatibility parameter names | ||
| 572 | 7498 | if ((generic_parameter == "CVMFS_CACHE_SHARED") | |
| 573 |
5/6✓ Branch 0 taken 730 times.
✓ Branch 1 taken 6768 times.
✓ Branch 3 taken 730 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 730 times.
✓ Branch 6 taken 6768 times.
|
7498 | && !options_mgr_->IsDefined(generic_parameter)) { |
| 574 |
1/2✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
|
730 | return "CVMFS_SHARED_CACHE"; |
| 575 | } | ||
| 576 | 6768 | if ((generic_parameter == "CVMFS_CACHE_ALIEN") | |
| 577 |
5/6✓ Branch 0 taken 730 times.
✓ Branch 1 taken 6038 times.
✓ Branch 3 taken 730 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 730 times.
✓ Branch 6 taken 6038 times.
|
6768 | && !options_mgr_->IsDefined(generic_parameter)) { |
| 578 |
1/2✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
|
730 | return "CVMFS_ALIEN_CACHE"; |
| 579 | } | ||
| 580 | 6038 | if ((generic_parameter == "CVMFS_CACHE_SERVER_MODE") | |
| 581 |
5/6✓ Branch 0 taken 1643 times.
✓ Branch 1 taken 4395 times.
✓ Branch 3 taken 1643 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1643 times.
✓ Branch 6 taken 4395 times.
|
6038 | && !options_mgr_->IsDefined(generic_parameter)) { |
| 582 |
1/2✓ Branch 2 taken 1643 times.
✗ Branch 3 not taken.
|
1643 | return "CVMFS_SERVER_CACHE_MODE"; |
| 583 | } | ||
| 584 | 4395 | if ((generic_parameter == "CVMFS_CACHE_QUOTA_LIMIT") | |
| 585 |
5/6✓ Branch 0 taken 730 times.
✓ Branch 1 taken 3665 times.
✓ Branch 3 taken 730 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 730 times.
✓ Branch 6 taken 3665 times.
|
4395 | && !options_mgr_->IsDefined(generic_parameter)) { |
| 586 |
1/2✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
|
730 | return "CVMFS_QUOTA_LIMIT"; |
| 587 | } | ||
| 588 | 3665 | return generic_parameter; | |
| 589 | } | ||
| 590 | |||
| 591 |
3/6✓ Branch 2 taken 1395 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1395 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1395 times.
✗ Branch 9 not taken.
|
2790 | return "CVMFS_CACHE_" + instance + "_" + generic_parameter.substr(12); |
| 592 | } | ||
| 593 | |||
| 594 | |||
| 595 | ✗ | void FileSystem::ResetErrorCounters() { | |
| 596 | ✗ | io_error_info_.Reset(); | |
| 597 | ✗ | n_eio_total_->Set(0); | |
| 598 | ✗ | n_eio_01_->Set(0); | |
| 599 | ✗ | n_eio_02_->Set(0); | |
| 600 | ✗ | n_eio_03_->Set(0); | |
| 601 | ✗ | n_eio_04_->Set(0); | |
| 602 | ✗ | n_eio_05_->Set(0); | |
| 603 | ✗ | n_eio_06_->Set(0); | |
| 604 | ✗ | n_eio_07_->Set(0); | |
| 605 | ✗ | n_eio_08_->Set(0); | |
| 606 | ✗ | n_emfile_->Set(0); | |
| 607 | } | ||
| 608 | |||
| 609 | |||
| 610 | /** | ||
| 611 | * Can be recursive for the tiered cache manager. | ||
| 612 | */ | ||
| 613 | 1075 | CacheManager *FileSystem::SetupCacheMgr(const string &instance) { | |
| 614 |
3/4✓ Branch 2 taken 1075 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 1060 times.
|
1075 | if (constructed_instances_.find(instance) != constructed_instances_.end()) { |
| 615 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | boot_error_ = "circular cache definition: " + instance; |
| 616 | 15 | boot_status_ = loader::kFailCacheDir; | |
| 617 | 15 | return NULL; | |
| 618 | } | ||
| 619 |
1/2✓ Branch 1 taken 1060 times.
✗ Branch 2 not taken.
|
1060 | constructed_instances_.insert(instance); |
| 620 | |||
| 621 |
1/2✓ Branch 2 taken 1060 times.
✗ Branch 3 not taken.
|
1060 | LogCvmfs(kLogCvmfs, kLogDebug, "setting up cache manager instance %s", |
| 622 | instance.c_str()); | ||
| 623 | 1060 | string instance_type; | |
| 624 |
2/2✓ Branch 1 taken 730 times.
✓ Branch 2 taken 330 times.
|
1060 | if (instance == kDefaultCacheMgrInstance) { |
| 625 |
1/2✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
|
730 | instance_type = "posix"; |
| 626 | } else { | ||
| 627 |
3/6✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 330 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
|
330 | options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_TYPE", instance), |
| 628 | &instance_type); | ||
| 629 | } | ||
| 630 |
2/2✓ Branch 1 taken 775 times.
✓ Branch 2 taken 285 times.
|
1060 | if (instance_type == "posix") { |
| 631 |
1/2✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
|
775 | return SetupPosixCacheMgr(instance); |
| 632 |
2/2✓ Branch 1 taken 150 times.
✓ Branch 2 taken 135 times.
|
285 | } else if (instance_type == "ram") { |
| 633 |
1/2✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
|
150 | return SetupRamCacheMgr(instance); |
| 634 |
2/2✓ Branch 1 taken 120 times.
✓ Branch 2 taken 15 times.
|
135 | } else if (instance_type == "tiered") { |
| 635 |
1/2✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
|
120 | return SetupTieredCacheMgr(instance); |
| 636 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | } else if (instance_type == "external") { |
| 637 | ✗ | return SetupExternalCacheMgr(instance); | |
| 638 | } else { | ||
| 639 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | boot_error_ = "invalid cache manager type for '" + instance |
| 640 |
2/4✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
|
15 | + "':" + instance_type; |
| 641 | 15 | boot_status_ = loader::kFailCacheDir; | |
| 642 | 15 | return NULL; | |
| 643 | } | ||
| 644 | 1060 | } | |
| 645 | |||
| 646 | |||
| 647 | ✗ | CacheManager *FileSystem::SetupExternalCacheMgr(const string &instance) { | |
| 648 | ✗ | string optarg; | |
| 649 | ✗ | unsigned nfiles = kDefaultNfiles; | |
| 650 | ✗ | if (options_mgr_->GetValue("CVMFS_NFILES", &optarg)) | |
| 651 | ✗ | nfiles = String2Uint64(optarg); | |
| 652 | ✗ | vector<string> cmd_line; | |
| 653 | ✗ | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_CMDLINE", instance), | |
| 654 | &optarg)) { | ||
| 655 | ✗ | cmd_line = SplitString(optarg, ','); | |
| 656 | } | ||
| 657 | |||
| 658 | ✗ | if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_LOCATOR", instance), | |
| 659 | &optarg)) { | ||
| 660 | ✗ | boot_error_ = MkCacheParm("CVMFS_CACHE_LOCATOR", instance) + " missing"; | |
| 661 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 662 | ✗ | return NULL; | |
| 663 | } | ||
| 664 | |||
| 665 | const UniquePtr<ExternalCacheManager::PluginHandle> plugin_handle( | ||
| 666 | ✗ | ExternalCacheManager::CreatePlugin(optarg, cmd_line)); | |
| 667 | ✗ | if (!plugin_handle->IsValid()) { | |
| 668 | ✗ | boot_error_ = plugin_handle->error_msg(); | |
| 669 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 670 | ✗ | return NULL; | |
| 671 | } | ||
| 672 | ✗ | ExternalCacheManager *cache_mgr = ExternalCacheManager::Create( | |
| 673 | ✗ | plugin_handle->fd_connection(), nfiles, name_ + ":" + instance); | |
| 674 | ✗ | if (cache_mgr == NULL) { | |
| 675 | ✗ | boot_error_ = "failed to create external cache manager for " + instance; | |
| 676 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 677 | ✗ | return NULL; | |
| 678 | } | ||
| 679 | ✗ | cache_mgr->AcquireQuotaManager(ExternalQuotaManager::Create(cache_mgr)); | |
| 680 | ✗ | return cache_mgr; | |
| 681 | } | ||
| 682 | |||
| 683 | |||
| 684 | 775 | CacheManager *FileSystem::SetupPosixCacheMgr(const string &instance) { | |
| 685 |
1/2✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
|
775 | const PosixCacheSettings settings = DeterminePosixCacheSettings(instance); |
| 686 |
3/4✓ Branch 1 taken 775 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 730 times.
|
775 | if (!CheckPosixCacheSettings(settings)) |
| 687 | 45 | return NULL; | |
| 688 | UniquePtr<PosixCacheManager> cache_mgr(PosixCacheManager::Create( | ||
| 689 | 730 | settings.cache_path, settings.is_alien, | |
| 690 | 730 | settings.avoid_rename ? PosixCacheManager::kRenameLink | |
| 691 | : PosixCacheManager::kRenameNormal, | ||
| 692 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✓ Branch 3 taken 730 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 730 times.
✗ Branch 7 not taken.
|
730 | settings.do_refcount, settings.cleanup_unused_first)); |
| 693 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
|
730 | if (!cache_mgr.IsValid()) { |
| 694 | ✗ | boot_error_ = "Failed to setup posix cache '" + instance + "' in " | |
| 695 | ✗ | + settings.cache_path + ": " + strerror(errno); | |
| 696 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 697 | ✗ | return NULL; | |
| 698 | } | ||
| 699 | |||
| 700 | // Sentinel file for future use | ||
| 701 | // Might be a read-only cache | ||
| 702 | 730 | const bool ignore_failure = settings.is_alien; | |
| 703 |
2/4✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 730 times.
✗ Branch 5 not taken.
|
730 | CreateFile(settings.cache_path + "/.cvmfscache", 0600, ignore_failure); |
| 704 | |||
| 705 |
2/2✓ Branch 0 taken 574 times.
✓ Branch 1 taken 156 times.
|
730 | if (settings.is_managed) { |
| 706 |
2/4✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 574 times.
|
574 | if (!SetupPosixQuotaMgr(settings, cache_mgr.weak_ref())) |
| 707 | ✗ | return NULL; | |
| 708 | } | ||
| 709 | 730 | return cache_mgr.Release(); | |
| 710 | 775 | } | |
| 711 | |||
| 712 | |||
| 713 | 150 | CacheManager *FileSystem::SetupRamCacheMgr(const string &instance) { | |
| 714 | 150 | string optarg; | |
| 715 | 150 | unsigned nfiles = kDefaultNfiles; | |
| 716 |
3/6✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 150 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 150 times.
|
150 | if (options_mgr_->GetValue("CVMFS_NFILES", &optarg)) { |
| 717 | ✗ | nfiles = String2Uint64(optarg); | |
| 718 | } | ||
| 719 | uint64_t sz_cache_bytes; | ||
| 720 |
4/8✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 150 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 150 times.
✗ Branch 14 not taken.
|
150 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SIZE", instance), |
| 721 | &optarg)) { | ||
| 722 |
3/6✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 150 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 150 times.
|
150 | if (HasSuffix(optarg, "%", false)) { |
| 723 | ✗ | sz_cache_bytes = platform_memsize() * String2Uint64(optarg) / 100; | |
| 724 | } else { | ||
| 725 |
1/2✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
|
150 | sz_cache_bytes = String2Uint64(optarg) * 1024 * 1024; |
| 726 | } | ||
| 727 | } else { | ||
| 728 | ✗ | sz_cache_bytes = platform_memsize() >> 5; // ~3% | |
| 729 | } | ||
| 730 | 150 | MemoryKvStore::MemoryAllocator alloc = MemoryKvStore::kMallocHeap; | |
| 731 |
5/8✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 150 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 30 times.
✓ Branch 14 taken 120 times.
|
150 | if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_MALLOC", instance), |
| 732 | &optarg)) { | ||
| 733 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 2 taken 15 times.
|
30 | if (optarg == "libc") { |
| 734 | 15 | alloc = MemoryKvStore::kMallocLibc; | |
| 735 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | } else if (optarg == "heap") { |
| 736 | ✗ | alloc = MemoryKvStore::kMallocHeap; | |
| 737 | } else { | ||
| 738 | boot_error_ = "Failure: unknown malloc " | ||
| 739 |
4/8✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 15 times.
✗ Branch 12 not taken.
|
30 | + MkCacheParm("CVMFS_CACHE_MALLOC", instance) + "=" |
| 740 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | + optarg; |
| 741 | 15 | boot_status_ = loader::kFailOptions; | |
| 742 | 15 | return NULL; | |
| 743 | } | ||
| 744 | } | ||
| 745 | 135 | sz_cache_bytes = RoundUp8( | |
| 746 | 135 | std::max(static_cast<uint64_t>(40 * 1024 * 1024), sz_cache_bytes)); | |
| 747 | RamCacheManager *cache_mgr = new RamCacheManager( | ||
| 748 | sz_cache_bytes, | ||
| 749 | nfiles, | ||
| 750 | alloc, | ||
| 751 |
4/8✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 135 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 135 times.
✗ Branch 11 not taken.
|
135 | perf::StatisticsTemplate("cache." + instance, statistics_)); |
| 752 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
|
135 | if (cache_mgr == NULL) { |
| 753 | ✗ | boot_error_ = "failed to create ram cache manager for " + instance; | |
| 754 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 755 | ✗ | return NULL; | |
| 756 | } | ||
| 757 |
3/6✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 135 times.
✗ Branch 8 not taken.
|
135 | cache_mgr->AcquireQuotaManager(new NoopQuotaManager()); |
| 758 | 135 | return cache_mgr; | |
| 759 | 150 | } | |
| 760 | |||
| 761 | |||
| 762 | 120 | CacheManager *FileSystem::SetupTieredCacheMgr(const string &instance) { | |
| 763 | 120 | string optarg; | |
| 764 |
5/8✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 120 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 105 times.
|
120 | if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_UPPER", instance), |
| 765 | &optarg)) { | ||
| 766 |
3/6✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
|
15 | boot_error_ = MkCacheParm("CVMFS_CACHE_UPPER", instance) + " missing"; |
| 767 | 15 | boot_status_ = loader::kFailOptions; | |
| 768 | 15 | return NULL; | |
| 769 | } | ||
| 770 |
2/4✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
|
105 | UniquePtr<CacheManager> upper(SetupCacheMgr(optarg)); |
| 771 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
|
105 | if (!upper.IsValid()) |
| 772 | ✗ | return NULL; | |
| 773 | |||
| 774 |
5/8✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 105 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 105 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 90 times.
|
105 | if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_LOWER", instance), |
| 775 | &optarg)) { | ||
| 776 |
3/6✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
|
15 | boot_error_ = MkCacheParm("CVMFS_CACHE_LOWER", instance) + " missing"; |
| 777 | 15 | boot_status_ = loader::kFailOptions; | |
| 778 | 15 | return NULL; | |
| 779 | } | ||
| 780 |
2/4✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
|
90 | UniquePtr<CacheManager> lower(SetupCacheMgr(optarg)); |
| 781 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 2 taken 75 times.
|
90 | if (!lower.IsValid()) |
| 782 | 15 | return NULL; | |
| 783 | |||
| 784 |
1/2✓ Branch 3 taken 75 times.
✗ Branch 4 not taken.
|
75 | CacheManager *tiered = TieredCacheManager::Create(upper.Release(), |
| 785 | lower.Release()); | ||
| 786 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
|
75 | if (tiered == NULL) { |
| 787 | ✗ | boot_error_ = "Failed to setup tiered cache manager " + instance; | |
| 788 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 789 | ✗ | return NULL; | |
| 790 | } | ||
| 791 | 300 | if (options_mgr_->GetValue( | |
| 792 |
5/16✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 75 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 75 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 75 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
150 | MkCacheParm("CVMFS_CACHE_LOWER_READONLY", instance), &optarg) |
| 793 |
3/10✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 75 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 75 times.
✗ Branch 12 not taken.
|
150 | && options_mgr_->IsOn(optarg)) { |
| 794 | ✗ | static_cast<TieredCacheManager *>(tiered)->SetLowerReadOnly(); | |
| 795 | } | ||
| 796 | 75 | return tiered; | |
| 797 | 120 | } | |
| 798 | |||
| 799 | |||
| 800 | 895 | bool FileSystem::SetupCrashGuard() { | |
| 801 |
2/4✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 895 times.
✗ Branch 5 not taken.
|
895 | path_crash_guard_ = workspace_ + "/running." + name_; |
| 802 | platform_stat64 info; | ||
| 803 | 895 | int retval = platform_stat(path_crash_guard_.c_str(), &info); | |
| 804 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 880 times.
|
895 | if (retval == 0) { |
| 805 | 15 | found_previous_crash_ = true; | |
| 806 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogWarn, |
| 807 | "looks like cvmfs has been crashed previously"); | ||
| 808 | } | ||
| 809 |
1/2✓ Branch 2 taken 895 times.
✗ Branch 3 not taken.
|
895 | retval = open(path_crash_guard_.c_str(), O_RDONLY | O_CREAT, 0600); |
| 810 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 895 times.
|
895 | if (retval < 0) { |
| 811 | ✗ | boot_error_ = "could not open running sentinel (" + StringifyInt(errno) | |
| 812 | ✗ | + ")"; | |
| 813 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 814 | ✗ | return false; | |
| 815 | } | ||
| 816 |
1/2✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
|
895 | close(retval); |
| 817 | 895 | return true; | |
| 818 | } | ||
| 819 | |||
| 820 | |||
| 821 | 895 | bool FileSystem::SetupCwd() { | |
| 822 |
2/2✓ Branch 0 taken 829 times.
✓ Branch 1 taken 66 times.
|
895 | if (type_ == kFsFuse) { |
| 823 | // Try to jump to workspace / cache directory. This tests, if it is | ||
| 824 | // accessible and it brings speed later on. | ||
| 825 | 829 | const int retval = chdir(workspace_.c_str()); | |
| 826 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
|
829 | if (retval != 0) { |
| 827 | ✗ | boot_error_ = "workspace " + workspace_ + " is unavailable"; | |
| 828 | ✗ | boot_status_ = loader::kFailCacheDir; | |
| 829 | ✗ | return false; | |
| 830 | } | ||
| 831 | 829 | workspace_ = "."; | |
| 832 | 829 | return true; | |
| 833 | } | ||
| 834 | |||
| 835 | // Note: as of version 2.4 support for CVMFS_CWD_CACHE is dropped due to | ||
| 836 | // disproportionate large complexity to configure correctly. This affects | ||
| 837 | // only libcvmfs, mostly the legacy part. | ||
| 838 | // string optarg; | ||
| 839 | // if (options_mgr_->GetValue("CVMFS_CWD_CACHE", &optarg) && | ||
| 840 | // options_mgr_->IsOn(optarg)) | ||
| 841 | // { | ||
| 842 | // ... | ||
| 843 | // } | ||
| 844 | 66 | return true; | |
| 845 | } | ||
| 846 | |||
| 847 | |||
| 848 | 913 | void FileSystem::SetupLoggingStandalone(const OptionsManager &options_mgr, | |
| 849 | const std::string &prefix) { | ||
| 850 | 913 | string optarg; | |
| 851 |
4/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 893 times.
|
913 | if (options_mgr.GetValue("CVMFS_SYSLOG_LEVEL", &optarg)) |
| 852 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
20 | SetLogSyslogLevel(String2Uint64(optarg)); |
| 853 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 913 times.
|
913 | if (options_mgr.GetValue("CVMFS_SYSLOG_FACILITY", &optarg)) |
| 854 | ✗ | SetLogSyslogFacility(String2Int64(optarg)); | |
| 855 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 913 times.
|
913 | if (options_mgr.GetValue("CVMFS_USYSLOG", &optarg)) |
| 856 | ✗ | SetLogMicroSyslog(optarg); | |
| 857 |
3/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 913 times.
|
913 | if (options_mgr.GetValue("CVMFS_DEBUGLOG", &optarg)) |
| 858 | ✗ | SetLogDebugFile(optarg); | |
| 859 |
4/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 907 times.
|
913 | if (options_mgr.GetValue("CVMFS_SYSLOG_PREFIX", &optarg)) { |
| 860 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | SetLogSyslogPrefix(optarg); |
| 861 | } else { | ||
| 862 |
1/2✓ Branch 1 taken 907 times.
✗ Branch 2 not taken.
|
907 | SetLogSyslogPrefix(prefix); |
| 863 | } | ||
| 864 | 913 | } | |
| 865 | |||
| 866 | |||
| 867 | 913 | void FileSystem::SetupLogging() { | |
| 868 | 913 | SetupLoggingStandalone(*options_mgr_, name_); | |
| 869 | 913 | } | |
| 870 | |||
| 871 | |||
| 872 | 760 | bool FileSystem::SetupNfsMaps() { | |
| 873 | #ifdef CVMFS_NFS_SUPPORT | ||
| 874 | ✗ | if (!IsHaNfsSource()) | |
| 875 | ✗ | nfs_maps_dir_ = workspace_; | |
| 876 | |||
| 877 | ✗ | string no_nfs_sentinel; | |
| 878 | ✗ | if (cache_mgr_->id() == kPosixCacheManager) { | |
| 879 | ✗ | PosixCacheManager *posix_cache_mgr = reinterpret_cast<PosixCacheManager *>( | |
| 880 | cache_mgr_); | ||
| 881 | ✗ | no_nfs_sentinel = posix_cache_mgr->cache_path() + "/no_nfs_maps." + name_; | |
| 882 | ✗ | if (!IsNfsSource()) { | |
| 883 | // Might be a read-only cache | ||
| 884 | ✗ | const bool ignore_failure = posix_cache_mgr->alien_cache(); | |
| 885 | ✗ | CreateFile(no_nfs_sentinel, 0600, ignore_failure); | |
| 886 | ✗ | return true; | |
| 887 | } | ||
| 888 | } else { | ||
| 889 | ✗ | if (IsNfsSource()) { | |
| 890 | ✗ | boot_error_ = "NFS source only works with POSIX cache manager."; | |
| 891 | ✗ | boot_status_ = loader::kFailNfsMaps; | |
| 892 | ✗ | return false; | |
| 893 | } | ||
| 894 | ✗ | return true; | |
| 895 | } | ||
| 896 | |||
| 897 | ✗ | assert(cache_mgr_->id() == kPosixCacheManager); | |
| 898 | ✗ | assert(IsNfsSource()); | |
| 899 | ✗ | if (!no_nfs_sentinel.empty() && FileExists(no_nfs_sentinel)) { | |
| 900 | boot_error_ = "Cache was used without NFS maps before. " | ||
| 901 | ✗ | "It has to be wiped out."; | |
| 902 | ✗ | boot_status_ = loader::kFailNfsMaps; | |
| 903 | ✗ | return false; | |
| 904 | } | ||
| 905 | |||
| 906 | // nfs maps need to be protected by workspace lock | ||
| 907 | ✗ | PosixCacheManager *posix_cache_mgr = reinterpret_cast<PosixCacheManager *>( | |
| 908 | cache_mgr_); | ||
| 909 | ✗ | if (posix_cache_mgr->cache_path() != workspace_) { | |
| 910 | boot_error_ = "Cache directory and workspace must be identical for " | ||
| 911 | ✗ | "NFS export"; | |
| 912 | ✗ | boot_status_ = loader::kFailNfsMaps; | |
| 913 | ✗ | return false; | |
| 914 | } | ||
| 915 | |||
| 916 | ✗ | const string inode_cache_dir = nfs_maps_dir_ + "/nfs_maps." + name_; | |
| 917 | ✗ | if (!MkdirDeep(inode_cache_dir, 0700)) { | |
| 918 | ✗ | boot_error_ = "Failed to initialize NFS maps"; | |
| 919 | ✗ | boot_status_ = loader::kFailNfsMaps; | |
| 920 | ✗ | return false; | |
| 921 | } | ||
| 922 | |||
| 923 | // TODO(jblomer): make this a manager class | ||
| 924 | ✗ | if (IsHaNfsSource()) { | |
| 925 | ✗ | nfs_maps_ = NfsMapsSqlite::Create( | |
| 926 | inode_cache_dir, | ||
| 927 | catalog::ClientCatalogManager::kInodeOffset + 1, | ||
| 928 | ✗ | found_previous_crash_, | |
| 929 | statistics_); | ||
| 930 | } else { | ||
| 931 | ✗ | nfs_maps_ = NfsMapsLeveldb::Create( | |
| 932 | inode_cache_dir, | ||
| 933 | catalog::ClientCatalogManager::kInodeOffset + 1, | ||
| 934 | ✗ | found_previous_crash_, | |
| 935 | statistics_); | ||
| 936 | } | ||
| 937 | |||
| 938 | ✗ | if (nfs_maps_ == NULL) { | |
| 939 | ✗ | boot_error_ = "Failed to initialize NFS maps"; | |
| 940 | ✗ | boot_status_ = loader::kFailNfsMaps; | |
| 941 | ✗ | return false; | |
| 942 | } | ||
| 943 | |||
| 944 | ✗ | string optarg; | |
| 945 | ✗ | if (options_mgr_->GetValue("CVMFS_NFS_INTERLEAVED_INODES", &optarg)) { | |
| 946 | ✗ | vector<string> tokens = SplitString(optarg, '%'); | |
| 947 | ✗ | if (tokens.size() != 2) { | |
| 948 | boot_error_ = "invalid format for CVMFS_NFS_INTERLEAVED_INODES: " | ||
| 949 | ✗ | + optarg; | |
| 950 | ✗ | boot_status_ = loader::kFailNfsMaps; | |
| 951 | ✗ | return false; | |
| 952 | } | ||
| 953 | ✗ | nfs_maps_->SetInodeResidue(String2Uint64(tokens[1]), | |
| 954 | ✗ | String2Uint64(tokens[0])); | |
| 955 | } | ||
| 956 | |||
| 957 | ✗ | return true; | |
| 958 | |||
| 959 | #else | ||
| 960 | 760 | return true; | |
| 961 | #endif | ||
| 962 | } | ||
| 963 | |||
| 964 | |||
| 965 | 574 | bool FileSystem::SetupPosixQuotaMgr( | |
| 966 | const FileSystem::PosixCacheSettings &settings, CacheManager *cache_mgr) { | ||
| 967 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | assert(settings.quota_limit >= 0); |
| 968 | 574 | const int64_t quota_threshold = settings.quota_limit / 2; | |
| 969 |
1/2✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
|
574 | string cache_workspace = settings.cache_path; |
| 970 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 574 times.
|
574 | if (settings.cache_path != settings.workspace) { |
| 971 | ✗ | LogCvmfs(kLogQuota, kLogDebug | kLogSyslog, | |
| 972 | "using workspace %s to protect cache database in %s", | ||
| 973 | settings.workspace.c_str(), settings.cache_path.c_str()); | ||
| 974 | ✗ | cache_workspace += ":" + settings.workspace; | |
| 975 | } | ||
| 976 | PosixQuotaManager *quota_mgr; | ||
| 977 | |||
| 978 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | if (settings.is_shared) { |
| 979 | ✗ | quota_mgr = PosixQuotaManager::CreateShared(exe_path_, | |
| 980 | cache_workspace, | ||
| 981 | ✗ | settings.quota_limit, | |
| 982 | quota_threshold, | ||
| 983 | ✗ | foreground_); | |
| 984 | ✗ | if (quota_mgr == NULL) { | |
| 985 | ✗ | boot_error_ = "Failed to initialize shared lru cache"; | |
| 986 | ✗ | boot_status_ = loader::kFailQuota; | |
| 987 | ✗ | return false; | |
| 988 | } | ||
| 989 | } else { | ||
| 990 | 1148 | quota_mgr = PosixQuotaManager::Create(cache_workspace, | |
| 991 | 574 | settings.quota_limit, | |
| 992 | quota_threshold, | ||
| 993 |
1/2✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
|
574 | found_previous_crash_); |
| 994 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | if (quota_mgr == NULL) { |
| 995 | ✗ | boot_error_ = "Failed to initialize lru cache"; | |
| 996 | ✗ | boot_status_ = loader::kFailQuota; | |
| 997 | ✗ | return false; | |
| 998 | } | ||
| 999 | } | ||
| 1000 | |||
| 1001 |
3/6✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 574 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 574 times.
|
574 | if (quota_mgr->GetSize() > quota_mgr->GetCapacity()) { |
| 1002 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslog, | |
| 1003 | "cache is already beyond quota size " | ||
| 1004 | "(size: %" PRId64 ", capacity: %" PRId64 "), cleaning up", | ||
| 1005 | ✗ | quota_mgr->GetSize(), quota_mgr->GetCapacity()); | |
| 1006 | ✗ | if (!quota_mgr->Cleanup(quota_threshold)) { | |
| 1007 | ✗ | delete quota_mgr; | |
| 1008 | ✗ | boot_error_ = "Failed to clean up cache"; | |
| 1009 | ✗ | boot_status_ = loader::kFailQuota; | |
| 1010 | ✗ | return false; | |
| 1011 | } | ||
| 1012 | } | ||
| 1013 |
1/2✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
|
574 | quota_mgr->SetCleanupPolicy(settings.cleanup_unused_first); |
| 1014 | |||
| 1015 |
1/2✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
|
574 | const int retval = cache_mgr->AcquireQuotaManager(quota_mgr); |
| 1016 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | assert(retval); |
| 1017 | 574 | LogCvmfs(kLogCvmfs, kLogDebug, | |
| 1018 | "CernVM-FS: quota initialized, current size %luMB", | ||
| 1019 |
2/4✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 574 times.
✗ Branch 5 not taken.
|
574 | quota_mgr->GetSize() / (1024 * 1024)); |
| 1020 | 574 | return true; | |
| 1021 | 574 | } | |
| 1022 | |||
| 1023 | |||
| 1024 | 913 | void FileSystem::SetupSqlite() { | |
| 1025 | // Make sure SQlite starts clean after initialization | ||
| 1026 | 913 | sqlite3_shutdown(); | |
| 1027 | |||
| 1028 | int retval; | ||
| 1029 | 913 | retval = sqlite3_config(SQLITE_CONFIG_LOG, FileSystem::LogSqliteError, NULL); | |
| 1030 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 913 times.
|
913 | assert(retval == SQLITE_OK); |
| 1031 | 913 | retval = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); | |
| 1032 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 913 times.
|
913 | assert(retval == SQLITE_OK); |
| 1033 | 913 | SqliteMemoryManager::GetInstance()->AssignGlobalArenas(); | |
| 1034 | |||
| 1035 | // Disable SQlite3 file locking | ||
| 1036 | 913 | retval = sqlite3_vfs_register(sqlite3_vfs_find("unix-none"), 1); | |
| 1037 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 913 times.
|
913 | assert(retval == SQLITE_OK); |
| 1038 | 913 | } | |
| 1039 | |||
| 1040 | |||
| 1041 | 913 | bool FileSystem::SetupWorkspace() { | |
| 1042 | 913 | string optarg; | |
| 1043 | // This is very similar to "determine cache dir". It's for backward | ||
| 1044 | // compatibility with classic cache configuration where there was no | ||
| 1045 | // distinction between workspace and cache. | ||
| 1046 | // Complicated cache configurations should explicitly set CVMFS_WORKSPACE. | ||
| 1047 |
1/2✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
|
913 | workspace_ = kDefaultCacheBase; |
| 1048 |
4/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 860 times.
✓ Branch 10 taken 53 times.
|
913 | if (options_mgr_->GetValue("CVMFS_CACHE_BASE", &optarg)) |
| 1049 |
1/2✓ Branch 1 taken 860 times.
✗ Branch 2 not taken.
|
860 | workspace_ = MakeCanonicalPath(optarg); |
| 1050 |
4/10✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 913 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 883 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1826 | if (options_mgr_->GetValue("CVMFS_SHARED_CACHE", &optarg) |
| 1051 |
7/10✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 770 times.
✓ Branch 5 taken 143 times.
✓ Branch 7 taken 770 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 30 times.
✓ Branch 10 taken 740 times.
✓ Branch 11 taken 913 times.
✗ Branch 12 not taken.
|
1826 | && options_mgr_->IsOn(optarg)) { |
| 1052 |
1/2✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
|
30 | workspace_ += "/shared"; |
| 1053 | } else { | ||
| 1054 |
2/4✓ Branch 1 taken 883 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 883 times.
✗ Branch 5 not taken.
|
883 | workspace_ += "/" + name_; |
| 1055 | } | ||
| 1056 |
4/6✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 913 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 68 times.
✓ Branch 10 taken 845 times.
|
913 | if (options_mgr_->GetValue("CVMFS_CACHE_DIR", &optarg)) { |
| 1057 |
4/6✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 53 times.
|
68 | if (options_mgr_->IsDefined("CVMFS_CACHE_BASE")) { |
| 1058 | boot_error_ = "'CVMFS_CACHE_BASE' and 'CVMFS_CACHE_DIR' are mutually " | ||
| 1059 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | "exclusive"; |
| 1060 | 15 | boot_status_ = loader::kFailOptions; | |
| 1061 | 15 | return false; | |
| 1062 | } | ||
| 1063 |
1/2✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
|
53 | workspace_ = optarg; |
| 1064 | } | ||
| 1065 |
4/6✓ Branch 2 taken 898 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 898 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 880 times.
|
898 | if (options_mgr_->GetValue("CVMFS_WORKSPACE", &optarg)) |
| 1066 |
1/2✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
|
18 | workspace_ = optarg; |
| 1067 |
1/2✓ Branch 1 taken 898 times.
✗ Branch 2 not taken.
|
898 | workspace_fullpath_ = workspace_; |
| 1068 | |||
| 1069 | // If workspace and alien cache are the same directory, we need to open | ||
| 1070 | // permission now to 0770 to avoid a race when fixing it later | ||
| 1071 | 898 | const int mode = 0770; | |
| 1072 |
3/4✓ Branch 1 taken 898 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 896 times.
|
898 | if (!MkdirDeep(workspace_, mode, false)) { |
| 1073 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | boot_error_ = "cannot create workspace directory " + workspace_; |
| 1074 | 2 | boot_status_ = loader::kFailCacheDir; | |
| 1075 | 2 | return false; | |
| 1076 | } | ||
| 1077 | |||
| 1078 |
3/4✓ Branch 1 taken 896 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 895 times.
|
896 | if (!LockWorkspace()) |
| 1079 | 1 | return false; | |
| 1080 |
2/4✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
|
895 | if (!SetupCwd()) |
| 1081 | ✗ | return false; | |
| 1082 |
2/4✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
|
895 | if (!SetupCrashGuard()) |
| 1083 | ✗ | return false; | |
| 1084 | |||
| 1085 | 895 | return true; | |
| 1086 | 913 | } | |
| 1087 | |||
| 1088 | |||
| 1089 | 760 | void FileSystem::SetupUuid() { | |
| 1090 |
1/2✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
|
760 | uuid_cache_ = cvmfs::Uuid::Create(workspace_ + "/uuid"); |
| 1091 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
|
760 | if (uuid_cache_ == NULL) { |
| 1092 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogWarn, | |
| 1093 | "failed to load/store %s/uuid", workspace_.c_str()); | ||
| 1094 | ✗ | uuid_cache_ = cvmfs::Uuid::Create(""); | |
| 1095 | ✗ | assert(uuid_cache_ != NULL); | |
| 1096 | } | ||
| 1097 | 760 | } | |
| 1098 | |||
| 1099 | |||
| 1100 | /** | ||
| 1101 | * Required by CernVM: the fuse module needs to free r/w file descriptor to the | ||
| 1102 | * cache in order to properly unravel the file system stack on shutdown. | ||
| 1103 | */ | ||
| 1104 | ✗ | void FileSystem::TearDown2ReadOnly() { | |
| 1105 | ✗ | if ((cache_mgr_ != NULL) && (cache_mgr_->id() == kPosixCacheManager)) { | |
| 1106 | ✗ | PosixCacheManager *posix_cache_mgr = reinterpret_cast<PosixCacheManager *>( | |
| 1107 | cache_mgr_); | ||
| 1108 | ✗ | posix_cache_mgr->TearDown2ReadOnly(); | |
| 1109 | } | ||
| 1110 | |||
| 1111 | ✗ | unlink(path_crash_guard_.c_str()); | |
| 1112 | ✗ | LogCvmfs(kLogCache, kLogSyslog, "switch to read-only cache mode"); | |
| 1113 | ✗ | SetLogMicroSyslog(""); | |
| 1114 | } | ||
| 1115 | |||
| 1116 | |||
| 1117 | ✗ | void FileSystem::RemapCatalogFd(int from, int to) { | |
| 1118 | ✗ | sqlite::RegisterFdMapping(from, to); | |
| 1119 | } | ||
| 1120 | |||
| 1121 | ✗ | void FileSystem::ReplaceCacheManager(CacheManager *new_cache_mgr) { | |
| 1122 | ✗ | cache_mgr_ = new_cache_mgr; | |
| 1123 | ✗ | sqlite::ReplaceCacheManager(new_cache_mgr); | |
| 1124 | } | ||
| 1125 | |||
| 1126 | |||
| 1127 | 895 | bool FileSystem::TriageCacheMgr() { | |
| 1128 |
1/2✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
|
895 | cache_mgr_instance_ = kDefaultCacheMgrInstance; |
| 1129 | 895 | string instance; | |
| 1130 |
4/10✓ Branch 1 taken 895 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 895 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 180 times.
✓ Branch 8 taken 715 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1790 | if (options_mgr_->GetValue("CVMFS_CACHE_PRIMARY", &instance) |
| 1131 |
5/8✓ Branch 2 taken 895 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 180 times.
✓ Branch 5 taken 715 times.
✓ Branch 7 taken 180 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 895 times.
✗ Branch 10 not taken.
|
1790 | && !instance.empty()) { |
| 1132 |
3/4✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 165 times.
|
180 | if (!CheckInstanceName(instance)) |
| 1133 | 15 | return false; | |
| 1134 |
1/2✓ Branch 1 taken 165 times.
✗ Branch 2 not taken.
|
165 | cache_mgr_instance_ = instance; |
| 1135 | } | ||
| 1136 | |||
| 1137 |
1/2✓ Branch 1 taken 880 times.
✗ Branch 2 not taken.
|
880 | cache_mgr_ = SetupCacheMgr(cache_mgr_instance_); |
| 1138 |
2/2✓ Branch 0 taken 120 times.
✓ Branch 1 taken 760 times.
|
880 | if (cache_mgr_ == NULL) |
| 1139 | 120 | return false; | |
| 1140 | |||
| 1141 | 760 | std::string optarg; | |
| 1142 |
3/10✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 760 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1520 | if (options_mgr_->GetValue("CVMFS_STREAMING_CACHE", &optarg) |
| 1143 |
3/10✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 760 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 760 times.
✗ Branch 12 not taken.
|
1520 | && options_mgr_->IsOn(optarg)) { |
| 1144 | ✗ | unsigned nfiles = kDefaultNfiles; | |
| 1145 | ✗ | if (options_mgr_->GetValue("CVMFS_NFILES", &optarg)) | |
| 1146 | ✗ | nfiles = String2Uint64(optarg); | |
| 1147 | ✗ | size_t buffer_size = StreamingCacheManager::kDefaultBufferSize; | |
| 1148 | ✗ | if (options_mgr_->GetValue("CVMFS_STREAMING_CACHE_BUFFER_SIZE", &optarg)) | |
| 1149 | ✗ | buffer_size = String2Uint64(optarg); | |
| 1150 | ✗ | cache_mgr_ = new StreamingCacheManager(nfiles, cache_mgr_, NULL, NULL, | |
| 1151 | ✗ | buffer_size, statistics_); | |
| 1152 | } | ||
| 1153 | |||
| 1154 | 760 | return true; | |
| 1155 | 895 | } | |
| 1156 | |||
| 1157 | |||
| 1158 | //------------------------------------------------------------------------------ | ||
| 1159 | |||
| 1160 | |||
| 1161 | const char *MountPoint::kDefaultAuthzSearchPath = "/usr/libexec/cvmfs/authz"; | ||
| 1162 | const char *MountPoint::kDefaultBlacklist = "/etc/cvmfs/blacklist"; | ||
| 1163 | |||
| 1164 | 559 | bool MountPoint::CheckBlacklists() { | |
| 1165 | 559 | blacklist_paths_.clear(); | |
| 1166 | 559 | string blacklist; | |
| 1167 |
4/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 529 times.
✓ Branch 10 taken 30 times.
|
559 | if (!options_mgr_->GetValue("CVMFS_BLACKLIST", &blacklist)) |
| 1168 |
1/2✓ Branch 1 taken 529 times.
✗ Branch 2 not taken.
|
529 | blacklist = kDefaultBlacklist; |
| 1169 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
559 | blacklist_paths_.push_back(blacklist); |
| 1170 | |||
| 1171 | 559 | bool append = false; | |
| 1172 |
3/4✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 544 times.
|
559 | if (FileExists(blacklist)) { |
| 1173 |
2/4✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
|
15 | if (!signature_mgr_->LoadBlacklist(blacklist, append)) { |
| 1174 | ✗ | boot_error_ = "failed to load blacklist " + blacklist; | |
| 1175 | ✗ | boot_status_ = loader::kFailSignature; | |
| 1176 | ✗ | return false; | |
| 1177 | } | ||
| 1178 | 15 | append = true; | |
| 1179 | } | ||
| 1180 | |||
| 1181 | 559 | string config_repository_path; | |
| 1182 |
3/4✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 514 times.
|
559 | if (options_mgr_->HasConfigRepository(fqrn_, &config_repository_path)) { |
| 1183 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | blacklist = config_repository_path + "blacklist"; |
| 1184 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | blacklist_paths_.push_back(blacklist); |
| 1185 |
3/4✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 15 times.
|
45 | if (FileExists(blacklist)) { |
| 1186 |
2/4✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
|
30 | if (!signature_mgr_->LoadBlacklist(blacklist, append)) { |
| 1187 | ✗ | boot_error_ = "failed to load blacklist from config repository"; | |
| 1188 | ✗ | boot_status_ = loader::kFailSignature; | |
| 1189 | ✗ | return false; | |
| 1190 | } | ||
| 1191 | } | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | 559 | return true; | |
| 1195 | 559 | } | |
| 1196 | |||
| 1197 | |||
| 1198 | /** | ||
| 1199 | * Like CheckBlacklists but supposed to be used after bootstrap, possibly in | ||
| 1200 | * multi-threaded context. | ||
| 1201 | */ | ||
| 1202 | 30 | bool MountPoint::ReloadBlacklists() { | |
| 1203 | 30 | const bool result = true; | |
| 1204 | 30 | bool append = false; | |
| 1205 |
2/2✓ Branch 1 taken 45 times.
✓ Branch 2 taken 30 times.
|
75 | for (unsigned i = 0; i < blacklist_paths_.size(); ++i) { |
| 1206 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | const string blacklist = blacklist_paths_[i]; |
| 1207 |
2/4✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 45 times.
|
45 | if (FileExists(blacklist)) { |
| 1208 | ✗ | const bool retval = signature_mgr_->LoadBlacklist(blacklist, append); | |
| 1209 | // TODO(jblomer): this can leave us with a half-loaded blacklist | ||
| 1210 | ✗ | if (!retval) | |
| 1211 | ✗ | return false; | |
| 1212 | ✗ | append = true; | |
| 1213 | } | ||
| 1214 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | } |
| 1215 | 30 | return result; | |
| 1216 | } | ||
| 1217 | |||
| 1218 | /** | ||
| 1219 | * Disables kernel caching of symlinks. | ||
| 1220 | * Symlink caching requires fuse >= 3.10 (FUSE_CAP_CACHE_SYMLINKS) and | ||
| 1221 | * linux kernel >= 4.2. Some OS might backport it. | ||
| 1222 | * | ||
| 1223 | * NOTE: This function should only be called before or within cvmfs_init(). | ||
| 1224 | * | ||
| 1225 | */ | ||
| 1226 | ✗ | void MountPoint::DisableCacheSymlinks() { cache_symlinks_ = false; } | |
| 1227 | |||
| 1228 | /** | ||
| 1229 | * Instead of invalidate dentries, they should be expired. | ||
| 1230 | * Fixes issues with mount-on-top mounts and symlink caching. | ||
| 1231 | */ | ||
| 1232 | ✗ | void MountPoint::EnableFuseExpireEntry() { fuse_expire_entry_ = true; } | |
| 1233 | |||
| 1234 | |||
| 1235 | /** | ||
| 1236 | * The option_mgr parameter can be NULL, in which case the global option manager | ||
| 1237 | * from the file system is used. | ||
| 1238 | */ | ||
| 1239 | 574 | MountPoint *MountPoint::Create(const string &fqrn, | |
| 1240 | FileSystem *file_system, | ||
| 1241 | OptionsManager *options_mgr) { | ||
| 1242 |
2/2✓ Branch 0 taken 420 times.
✓ Branch 1 taken 154 times.
|
574 | if (options_mgr == NULL) |
| 1243 | 420 | options_mgr = file_system->options_mgr(); | |
| 1244 | UniquePtr<MountPoint> mountpoint( | ||
| 1245 |
3/6✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 574 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 574 times.
✗ Branch 8 not taken.
|
574 | new MountPoint(fqrn, file_system, options_mgr)); |
| 1246 | |||
| 1247 | // At this point, we have a repository name, the type (fuse or library) and | ||
| 1248 | // an options manager (which can be the same than the FileSystem's one). | ||
| 1249 | |||
| 1250 |
1/2✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
|
574 | mountpoint->CreateStatistics(); |
| 1251 |
1/2✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
|
574 | mountpoint->CreateAuthz(); |
| 1252 |
2/4✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 574 times.
✗ Branch 5 not taken.
|
574 | mountpoint->backoff_throttle_ = new BackoffThrottle(); |
| 1253 | |||
| 1254 |
7/10✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 559 times.
✓ Branch 5 taken 15 times.
✓ Branch 8 taken 559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 559 times.
✓ Branch 12 taken 15 times.
✓ Branch 13 taken 559 times.
|
574 | if (!mountpoint->CreateSignatureManager() || !mountpoint->CheckBlacklists()) |
| 1255 | 15 | return mountpoint.Release(); | |
| 1256 |
3/4✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✓ Branch 5 taken 454 times.
|
559 | if (!mountpoint->CreateDownloadManagers()) |
| 1257 | 105 | return mountpoint.Release(); | |
| 1258 |
2/4✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 454 times.
|
454 | if (file_system->cache_mgr()->id() == kStreamingCacheManager) { |
| 1259 | StreamingCacheManager | ||
| 1260 | ✗ | *streaming_cachemgr = dynamic_cast<StreamingCacheManager *>( | |
| 1261 | ✗ | file_system->cache_mgr()); | |
| 1262 | ✗ | streaming_cachemgr->SetRegularDownloadManager(mountpoint->download_mgr()); | |
| 1263 | ✗ | streaming_cachemgr->SetExternalDownloadManager( | |
| 1264 | mountpoint->external_download_mgr()); | ||
| 1265 | } | ||
| 1266 |
2/4✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 454 times.
|
454 | if (!mountpoint->CreateResolvConfWatcher()) { |
| 1267 | ✗ | return mountpoint.Release(); | |
| 1268 | } | ||
| 1269 |
1/2✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
|
454 | mountpoint->CreateFetchers(); |
| 1270 |
3/4✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 109 times.
✓ Branch 5 taken 345 times.
|
454 | if (!mountpoint->CreateCatalogManager()) |
| 1271 | 109 | return mountpoint.Release(); | |
| 1272 |
2/4✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 345 times.
|
345 | if (!mountpoint->CreateTracer()) |
| 1273 | ✗ | return mountpoint.Release(); | |
| 1274 | |||
| 1275 |
1/2✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
|
345 | mountpoint->ReEvaluateAuthz(); |
| 1276 |
1/2✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
|
345 | mountpoint->CreateTables(); |
| 1277 |
2/4✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 345 times.
|
345 | if (!mountpoint->SetupBehavior()) |
| 1278 | ✗ | return mountpoint.Release(); | |
| 1279 | |||
| 1280 | 345 | mountpoint->boot_status_ = loader::kFailOk; | |
| 1281 | 345 | return mountpoint.Release(); | |
| 1282 | 574 | } | |
| 1283 | |||
| 1284 | |||
| 1285 | 574 | void MountPoint::CreateAuthz() { | |
| 1286 | 574 | string optarg; | |
| 1287 | 574 | string authz_helper; | |
| 1288 |
3/6✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 574 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 574 times.
|
574 | if (options_mgr_->GetValue("CVMFS_AUTHZ_HELPER", &optarg)) |
| 1289 | ✗ | authz_helper = optarg; | |
| 1290 |
1/2✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
|
574 | string authz_search_path(kDefaultAuthzSearchPath); |
| 1291 |
3/6✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 574 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 574 times.
|
574 | if (options_mgr_->GetValue("CVMFS_AUTHZ_SEARCH_PATH", &optarg)) |
| 1292 | ✗ | authz_search_path = optarg; | |
| 1293 | |||
| 1294 | 1148 | authz_fetcher_ = new AuthzExternalFetcher(fqrn_, authz_helper, | |
| 1295 |
2/4✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 574 times.
✗ Branch 5 not taken.
|
574 | authz_search_path, options_mgr_); |
| 1296 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | assert(authz_fetcher_ != NULL); |
| 1297 | |||
| 1298 |
1/2✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
|
574 | authz_session_mgr_ = AuthzSessionManager::Create(authz_fetcher_, statistics_); |
| 1299 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | assert(authz_session_mgr_ != NULL); |
| 1300 | |||
| 1301 |
2/4✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 574 times.
✗ Branch 5 not taken.
|
574 | authz_attachment_ = new AuthzAttachment(authz_session_mgr_); |
| 1302 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | assert(authz_attachment_ != NULL); |
| 1303 | 574 | } | |
| 1304 | |||
| 1305 | |||
| 1306 | 454 | bool MountPoint::CreateCatalogManager() { | |
| 1307 | 454 | string optarg; | |
| 1308 | |||
| 1309 |
2/4✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
|
454 | catalog_mgr_ = new catalog::ClientCatalogManager(this); |
| 1310 | |||
| 1311 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | SetupInodeAnnotation(); |
| 1312 |
3/4✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 439 times.
|
454 | if (!SetupOwnerMaps()) |
| 1313 | 15 | return false; | |
| 1314 |
1/2✓ Branch 1 taken 439 times.
✗ Branch 2 not taken.
|
439 | shash::Any root_hash; |
| 1315 |
3/4✓ Branch 1 taken 439 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 409 times.
|
439 | if (!DetermineRootHash(&root_hash)) |
| 1316 | 30 | return false; | |
| 1317 | |||
| 1318 | bool retval; | ||
| 1319 |
2/2✓ Branch 1 taken 263 times.
✓ Branch 2 taken 146 times.
|
409 | if (root_hash.IsNull()) { |
| 1320 |
1/2✓ Branch 1 taken 263 times.
✗ Branch 2 not taken.
|
263 | retval = catalog_mgr_->Init(); |
| 1321 | } else { | ||
| 1322 | 146 | fixed_catalog_ = true; | |
| 1323 |
2/8✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
292 | const bool alt_root_path = options_mgr_->GetValue("CVMFS_ALT_ROOT_PATH", |
| 1324 | &optarg) | ||
| 1325 |
3/10✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 146 times.
✗ Branch 12 not taken.
|
292 | && options_mgr_->IsOn(optarg); |
| 1326 |
1/2✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
|
146 | retval = catalog_mgr_->InitFixed(root_hash, alt_root_path); |
| 1327 | } | ||
| 1328 |
2/2✓ Branch 0 taken 49 times.
✓ Branch 1 taken 360 times.
|
409 | if (!retval) { |
| 1329 |
1/2✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
|
49 | boot_error_ = "Failed to initialize root file catalog"; |
| 1330 | 49 | boot_status_ = loader::kFailCatalog; | |
| 1331 | 49 | return false; | |
| 1332 | } | ||
| 1333 | |||
| 1334 |
3/4✓ Branch 1 taken 360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 345 times.
|
360 | if (catalog_mgr_->IsRevisionBlacklisted()) { |
| 1335 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | boot_error_ = "repository revision blacklisted"; |
| 1336 | 15 | boot_status_ = loader::kFailRevisionBlacklisted; | |
| 1337 | 15 | return false; | |
| 1338 | } | ||
| 1339 | |||
| 1340 |
3/10✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 345 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
690 | if (options_mgr_->GetValue("CVMFS_AUTO_UPDATE", &optarg) |
| 1341 |
3/10✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 345 times.
✗ Branch 12 not taken.
|
690 | && !options_mgr_->IsOn(optarg)) { |
| 1342 | ✗ | fixed_catalog_ = true; | |
| 1343 | } | ||
| 1344 | |||
| 1345 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_CATALOG_WATERMARK", &optarg)) { |
| 1346 | ✗ | catalog_mgr_->SetCatalogWatermark(String2Uint64(optarg)); | |
| 1347 | } else { | ||
| 1348 | unsigned soft_limit; | ||
| 1349 | unsigned hard_limit; | ||
| 1350 |
1/2✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
|
345 | GetLimitNoFile(&soft_limit, &hard_limit); |
| 1351 | 345 | catalog_mgr_->SetCatalogWatermark(soft_limit / 4); | |
| 1352 | } | ||
| 1353 | |||
| 1354 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 345 times.
|
345 | if (catalog_mgr_->volatile_flag()) { |
| 1355 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug, "content of repository flagged as VOLATILE"); | |
| 1356 | } | ||
| 1357 | |||
| 1358 | 345 | return true; | |
| 1359 | 454 | } | |
| 1360 | |||
| 1361 | |||
| 1362 | 559 | bool MountPoint::CreateDownloadManagers() { | |
| 1363 | 559 | string optarg; | |
| 1364 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
1118 | download_mgr_ = new download::DownloadManager( |
| 1365 | kDefaultNumConnections, | ||
| 1366 |
4/8✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 559 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 559 times.
✗ Branch 13 not taken.
|
1677 | perf::StatisticsTemplate("download", statistics_)); |
| 1367 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
559 | download_mgr_->SetCredentialsAttachment(authz_attachment_); |
| 1368 | |||
| 1369 | // must be set before proxy and host chains are being initialized | ||
| 1370 | // error output is handled in SetShardingPolicy | ||
| 1371 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_PROXY_SHARDING_POLICY", &optarg)) { |
| 1372 | ✗ | if (optarg.compare("EXTERNAL") == 0) { | |
| 1373 | ✗ | download_mgr_->SetShardingPolicy(download::kShardingPolicyExternal); | |
| 1374 | ✗ | download_mgr_->SetFqrn(fqrn()); | |
| 1375 | } | ||
| 1376 | } | ||
| 1377 | |||
| 1378 |
3/10✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 559 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1118 | if (options_mgr_->GetValue("CVMFS_FAILOVER_INDEFINITELY", &optarg) |
| 1379 |
3/10✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 559 times.
✗ Branch 12 not taken.
|
1118 | && options_mgr_->IsOn(optarg)) { |
| 1380 | ✗ | download_mgr_->SetFailoverIndefinitely(); | |
| 1381 | } | ||
| 1382 | |||
| 1383 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_METALINK_URL", &optarg)) { |
| 1384 | ✗ | download_mgr_->SetMetalinkChain(optarg); | |
| 1385 | // host chain will be set later when the metalink server is contacted | ||
| 1386 | ✗ | download_mgr_->SetHostChain(""); | |
| 1387 | // metalink requires redirects | ||
| 1388 | ✗ | download_mgr_->EnableRedirects(); | |
| 1389 |
4/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 469 times.
✓ Branch 10 taken 90 times.
|
559 | } else if (options_mgr_->GetValue("CVMFS_SERVER_URL", &optarg)) { |
| 1390 |
1/2✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
|
469 | download_mgr_->SetHostChain(optarg); |
| 1391 | } | ||
| 1392 | |||
| 1393 |
3/10✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 559 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1118 | if (options_mgr_->GetValue("_CVMFS_DEVEL_IGNORE_SIGNATURE_FAILURES", &optarg) |
| 1394 |
3/10✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 559 times.
✗ Branch 12 not taken.
|
1118 | && options_mgr_->IsOn(optarg)) { |
| 1395 | ✗ | download_mgr_->EnableIgnoreSignatureFailures(); | |
| 1396 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogWarn, | |
| 1397 | "Development option: Activate ignore signature failures during " | ||
| 1398 | "download. " | ||
| 1399 | "DO NOT USE IN PRODUCTION"); | ||
| 1400 | } | ||
| 1401 | |||
| 1402 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
559 | SetupDnsTuning(download_mgr_); |
| 1403 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
559 | SetupHttpTuning(); |
| 1404 | |||
| 1405 | 559 | string forced_proxy_template; | |
| 1406 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_PROXY_TEMPLATE", &optarg)) |
| 1407 | ✗ | forced_proxy_template = optarg; | |
| 1408 |
2/4✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
|
559 | download_mgr_->SetProxyTemplates(file_system_->uuid_cache()->uuid(), |
| 1409 | forced_proxy_template); | ||
| 1410 | |||
| 1411 | 559 | string proxies; | |
| 1412 |
4/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 454 times.
✓ Branch 10 taken 105 times.
|
559 | if (options_mgr_->GetValue("CVMFS_HTTP_PROXY", &optarg)) |
| 1413 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | proxies = optarg; |
| 1414 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
1118 | proxies = download::ResolveProxyDescription( |
| 1415 | proxies, | ||
| 1416 |
4/8✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 559 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 559 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 559 times.
✗ Branch 11 not taken.
|
1118 | file_system_->workspace() + "/proxies" + GetUniqFileSuffix(), |
| 1417 | 559 | download_mgr_); | |
| 1418 |
2/2✓ Branch 1 taken 105 times.
✓ Branch 2 taken 454 times.
|
559 | if (proxies == "") { |
| 1419 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
105 | boot_error_ = "failed to discover HTTP proxy servers"; |
| 1420 | 105 | boot_status_ = loader::kFailWpad; | |
| 1421 | 105 | return false; | |
| 1422 | } | ||
| 1423 | 454 | string fallback_proxies; | |
| 1424 |
3/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 454 times.
|
454 | if (options_mgr_->GetValue("CVMFS_FALLBACK_PROXY", &optarg)) |
| 1425 | ✗ | fallback_proxies = optarg; | |
| 1426 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | download_mgr_->SetProxyChain(proxies, fallback_proxies, |
| 1427 | download::DownloadManager::kSetProxyBoth); | ||
| 1428 | |||
| 1429 |
2/8✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
908 | const bool do_geosort = options_mgr_->GetValue("CVMFS_USE_GEOAPI", &optarg) |
| 1430 |
3/10✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 454 times.
✗ Branch 12 not taken.
|
908 | && options_mgr_->IsOn(optarg); |
| 1431 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
|
454 | if (do_geosort) { |
| 1432 | ✗ | download_mgr_->ProbeGeo(); | |
| 1433 | } | ||
| 1434 |
4/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 60 times.
✓ Branch 10 taken 394 times.
|
454 | if (options_mgr_->GetValue("CVMFS_MAX_SERVERS", &optarg)) { |
| 1435 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
60 | const unsigned max_servers = String2Uint64(optarg); |
| 1436 | 60 | std::vector<std::string> host_chain; | |
| 1437 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
60 | download_mgr_->GetHostInfo(&host_chain, NULL, NULL); |
| 1438 |
6/6✓ Branch 0 taken 45 times.
✓ Branch 1 taken 15 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 45 times.
|
60 | if (max_servers > 0 && max_servers < host_chain.size()) { |
| 1439 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | host_chain.resize(max_servers); |
| 1440 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | download_mgr_->SetHostChain(host_chain); |
| 1441 | } | ||
| 1442 | 60 | } | |
| 1443 | |||
| 1444 |
3/10✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 454 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
908 | if (options_mgr_->GetValue("CVMFS_USE_SSL_SYSTEM_CA", &optarg) |
| 1445 |
3/10✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 454 times.
✗ Branch 12 not taken.
|
908 | && options_mgr_->IsOn(optarg)) { |
| 1446 | ✗ | download_mgr_->UseSystemCertificatePath(); | |
| 1447 | } | ||
| 1448 | |||
| 1449 |
3/10✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 454 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
908 | if (options_mgr_->GetValue("CVMFS_PROXY_SHARD", &optarg) |
| 1450 |
3/10✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 454 times.
✗ Branch 12 not taken.
|
908 | && options_mgr_->IsOn(optarg)) { |
| 1451 | ✗ | download_mgr_->ShardProxies(); | |
| 1452 | } | ||
| 1453 | |||
| 1454 | // configure http tracing header | ||
| 1455 |
3/10✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 454 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
908 | if (options_mgr_->GetValue("CVMFS_HTTP_TRACING", &optarg) |
| 1456 |
3/10✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 454 times.
✗ Branch 12 not taken.
|
908 | && options_mgr_->IsOn(optarg)) { |
| 1457 | ✗ | download_mgr_->EnableHTTPTracing(); | |
| 1458 | ✗ | if (options_mgr_->GetValue("CVMFS_HTTP_TRACING_HEADERS", &optarg)) { | |
| 1459 | ✗ | if (optarg.size() > 1000) { | |
| 1460 | ✗ | LogCvmfs(kLogCvmfs, kLogSyslogErr | kLogDebug, | |
| 1461 | "CVMFS_HTTP_TRACING_HEADERS too large ( max 1000 chars, given " | ||
| 1462 | "%ld )", | ||
| 1463 | optarg.size()); | ||
| 1464 | } else { | ||
| 1465 | ✗ | std::vector<std::string> tokens = SplitString(optarg, '|'); | |
| 1466 | ✗ | const sanitizer::AlphaNumSanitizer sanitizer; | |
| 1467 | |||
| 1468 | ✗ | for (unsigned int i = 0; i < tokens.size(); i++) { | |
| 1469 | ✗ | const std::string token = Trim(tokens[i]); | |
| 1470 | |||
| 1471 | ✗ | std::vector<std::string> key_val = SplitString(token, ':'); | |
| 1472 | |||
| 1473 | ✗ | if (key_val.size() != 2) { | |
| 1474 | ✗ | LogCvmfs(kLogCvmfs, kLogSyslogErr | kLogDebug, | |
| 1475 | "Http tracing header: Skipping current token part of " | ||
| 1476 | "CVMFS_HTTP_TRACING_HEADERS! Invalid " | ||
| 1477 | "<key:value> pair. Token: %s", | ||
| 1478 | token.c_str()); | ||
| 1479 | ✗ | continue; | |
| 1480 | } | ||
| 1481 | |||
| 1482 | ✗ | const std::string prefix = "X-CVMFS-"; | |
| 1483 | ✗ | const std::string key = Trim(key_val[0]); | |
| 1484 | |||
| 1485 | ✗ | if (!sanitizer.IsValid(key)) { | |
| 1486 | ✗ | LogCvmfs(kLogCvmfs, kLogSyslogErr | kLogDebug, | |
| 1487 | "Http tracing header: Skipping current token part of " | ||
| 1488 | "CVMFS_HTTP_TRACING_HEADERS! Invalid key. Only " | ||
| 1489 | "alphanumeric keys " | ||
| 1490 | "are allowed (a-z, A-Z, 0-9). Token: %s", | ||
| 1491 | token.c_str()); | ||
| 1492 | ✗ | continue; | |
| 1493 | } | ||
| 1494 | |||
| 1495 | ✗ | const std::string final_token = prefix + key + ": " | |
| 1496 | ✗ | + Trim(key_val[1]); | |
| 1497 | |||
| 1498 | ✗ | download_mgr_->AddHTTPTracingHeader(final_token); | |
| 1499 | } | ||
| 1500 | } | ||
| 1501 | } | ||
| 1502 | } | ||
| 1503 | |||
| 1504 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | return SetupExternalDownloadMgr(do_geosort); |
| 1505 | 559 | } | |
| 1506 | |||
| 1507 | 454 | bool MountPoint::CreateResolvConfWatcher() { | |
| 1508 | 454 | std::string roaming_value; | |
| 1509 |
2/4✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
|
454 | options_mgr_->GetValue("CVMFS_DNS_ROAMING", &roaming_value); |
| 1510 |
3/10✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 454 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
908 | if (options_mgr_->IsDefined("CVMFS_DNS_ROAMING") |
| 1511 |
3/10✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 454 times.
✗ Branch 12 not taken.
|
908 | && options_mgr_->IsOn(roaming_value)) { |
| 1512 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug, | |
| 1513 | "DNS roaming is enabled for this repository."); | ||
| 1514 | // Create a file watcher to update the DNS settings of the download | ||
| 1515 | // managers when there are changes to /etc/resolv.conf | ||
| 1516 | ✗ | resolv_conf_watcher_ = file_watcher::FileWatcher::Create(); | |
| 1517 | |||
| 1518 | ✗ | if (resolv_conf_watcher_) { | |
| 1519 | ResolvConfEventHandler *handler = new ResolvConfEventHandler( | ||
| 1520 | ✗ | download_mgr_, external_download_mgr_); | |
| 1521 | ✗ | resolv_conf_watcher_->RegisterHandler("/etc/resolv.conf", handler); | |
| 1522 | } | ||
| 1523 | } else { | ||
| 1524 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | LogCvmfs(kLogCvmfs, kLogDebug, |
| 1525 | "DNS roaming is disabled for this repository."); | ||
| 1526 | } | ||
| 1527 | 454 | return true; | |
| 1528 | 454 | } | |
| 1529 | |||
| 1530 | 454 | void MountPoint::CreateFetchers() { | |
| 1531 | 454 | fetcher_ = new cvmfs::Fetcher(file_system_->cache_mgr(), | |
| 1532 | download_mgr_, | ||
| 1533 | backoff_throttle_, | ||
| 1534 |
4/8✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 454 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 454 times.
✗ Branch 12 not taken.
|
454 | perf::StatisticsTemplate("fetch", statistics_)); |
| 1535 | |||
| 1536 | 908 | external_fetcher_ = new cvmfs::Fetcher( | |
| 1537 | 454 | file_system_->cache_mgr(), | |
| 1538 | external_download_mgr_, | ||
| 1539 | backoff_throttle_, | ||
| 1540 |
4/8✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 454 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 454 times.
✗ Branch 12 not taken.
|
454 | perf::StatisticsTemplate("fetch-external", statistics_)); |
| 1541 | 454 | } | |
| 1542 | |||
| 1543 | |||
| 1544 | 574 | bool MountPoint::CreateSignatureManager() { | |
| 1545 | 574 | string optarg; | |
| 1546 |
2/4✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 574 times.
✗ Branch 5 not taken.
|
574 | signature_mgr_ = new signature::SignatureManager(); |
| 1547 |
1/2✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
|
574 | signature_mgr_->Init(); |
| 1548 | |||
| 1549 | 574 | string public_keys; | |
| 1550 |
4/6✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 574 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 480 times.
✓ Branch 10 taken 94 times.
|
574 | if (options_mgr_->GetValue("CVMFS_PUBLIC_KEY", &optarg)) { |
| 1551 |
1/2✓ Branch 1 taken 480 times.
✗ Branch 2 not taken.
|
480 | public_keys = optarg; |
| 1552 |
3/6✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 94 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 94 times.
|
94 | } else if (options_mgr_->GetValue("CVMFS_KEYS_DIR", &optarg)) { |
| 1553 | // Collect .pub files from CVMFS_KEYS_DIR | ||
| 1554 | ✗ | public_keys = JoinStrings(FindFilesBySuffix(optarg, ".pub"), ":"); | |
| 1555 | } else { | ||
| 1556 |
5/10✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 94 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 94 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 94 times.
✗ Branch 17 not taken.
|
188 | public_keys = JoinStrings(FindFilesBySuffix("/etc/cvmfs/keys", ".pub"), |
| 1557 | 94 | ":"); | |
| 1558 | } | ||
| 1559 | |||
| 1560 |
3/4✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 559 times.
|
574 | if (!signature_mgr_->LoadPublicRsaKeys(public_keys)) { |
| 1561 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | boot_error_ = "failed to load public key(s)"; |
| 1562 | 15 | boot_status_ = loader::kFailSignature; | |
| 1563 | 15 | return false; | |
| 1564 | } | ||
| 1565 | |||
| 1566 |
2/2✓ Branch 1 taken 465 times.
✓ Branch 2 taken 94 times.
|
559 | if (public_keys.size() > 0) { |
| 1567 |
1/2✓ Branch 2 taken 465 times.
✗ Branch 3 not taken.
|
465 | LogCvmfs(kLogCvmfs, kLogDebug, "CernVM-FS: using public key(s) %s", |
| 1568 | public_keys.c_str()); | ||
| 1569 | } else { | ||
| 1570 |
1/2✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
|
94 | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogWarn, "no public key loaded"); |
| 1571 | } | ||
| 1572 | |||
| 1573 | 559 | return true; | |
| 1574 | 574 | } | |
| 1575 | |||
| 1576 | |||
| 1577 | 574 | void MountPoint::CreateStatistics() { | |
| 1578 | 574 | statistics_ = file_system_->statistics()->Fork(); | |
| 1579 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 2 taken 558 times.
|
574 | if (file_system_->type() != FileSystem::kFsFuse) |
| 1580 | 16 | return; | |
| 1581 | |||
| 1582 | // TODO(jblomer): this should be registered by the tracker | ||
| 1583 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("inode_tracker.n_insert", |
| 1584 | "overall number of accessed inodes"); | ||
| 1585 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("inode_tracker.n_remove", |
| 1586 | "overall number of evicted inodes"); | ||
| 1587 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("inode_tracker.no_reference", |
| 1588 | "currently active inodes"); | ||
| 1589 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("inode_tracker.n_hit_inode", |
| 1590 | "overall number of inode lookups"); | ||
| 1591 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("inode_tracker.n_hit_path", |
| 1592 | "overall number of successful path lookups"); | ||
| 1593 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("inode_tracker.n_miss_path", |
| 1594 | "overall number of unsuccessful path lookups"); | ||
| 1595 | |||
| 1596 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("dentry_tracker.n_insert", |
| 1597 | "overall number of added negative cache entries"); | ||
| 1598 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("dentry_tracker.n_remove", |
| 1599 | "overall number of evicted negative cache entries"); | ||
| 1600 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("dentry_tracker.n_prune", |
| 1601 | "overall number of prune calls"); | ||
| 1602 | |||
| 1603 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("page_cache_tracker.n_insert", |
| 1604 | "overall number of added page cache entries"); | ||
| 1605 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("page_cache_tracker.n_remove", |
| 1606 | "overall number of evicted page cache entries"); | ||
| 1607 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register("page_cache_tracker.n_open_direct", |
| 1608 | "overall number of direct I/O open calls"); | ||
| 1609 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register( |
| 1610 | "page_cache_tracker.n_open_flush", | ||
| 1611 | "overall number of open calls where the file's page cache gets flushed"); | ||
| 1612 |
3/6✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
|
558 | statistics_->Register( |
| 1613 | "page_cache_tracker.n_open_cached", | ||
| 1614 | "overall number of open calls where the file's page cache is reused"); | ||
| 1615 | } | ||
| 1616 | |||
| 1617 | |||
| 1618 | 345 | void MountPoint::CreateTables() { | |
| 1619 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 333 times.
|
345 | if (file_system_->type() != FileSystem::kFsFuse) { |
| 1620 | // Libcvmfs simplified tables | ||
| 1621 |
2/4✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
|
12 | md5path_cache_ = new lru::Md5PathCache(kLibPathCacheSize, statistics_); |
| 1622 |
2/4✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
|
12 | simple_chunk_tables_ = new SimpleChunkTables(); |
| 1623 | 12 | return; | |
| 1624 | } | ||
| 1625 | |||
| 1626 |
2/4✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
|
333 | chunk_tables_ = new ChunkTables(); |
| 1627 | |||
| 1628 | 333 | string optarg; | |
| 1629 | 333 | uint64_t mem_cache_size = kDefaultMemcacheSize; | |
| 1630 |
3/6✓ Branch 2 taken 333 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 333 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 333 times.
|
333 | if (options_mgr_->GetValue("CVMFS_MEMCACHE_SIZE", &optarg)) |
| 1631 | ✗ | mem_cache_size = String2Uint64(optarg) * 1024 * 1024; | |
| 1632 | |||
| 1633 | const double memcache_unit_size = (static_cast<double>(kInodeCacheFactor) | ||
| 1634 |
1/2✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
|
333 | * lru::Md5PathCache::GetEntrySize()) |
| 1635 |
1/2✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
|
333 | + lru::InodeCache::GetEntrySize() |
| 1636 |
1/2✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
|
333 | + lru::PathCache::GetEntrySize(); |
| 1637 | 333 | const unsigned memcache_num_units = mem_cache_size | |
| 1638 | 333 | / static_cast<unsigned>( | |
| 1639 | memcache_unit_size); | ||
| 1640 | // Number of cache entries must be a multiple of 64 | ||
| 1641 | 333 | const unsigned mask_64 = ~((1 << 6) - 1); | |
| 1642 |
2/4✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
|
333 | inode_cache_ = new lru::InodeCache(memcache_num_units & mask_64, statistics_); |
| 1643 |
2/4✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
|
333 | path_cache_ = new lru::PathCache(memcache_num_units & mask_64, statistics_); |
| 1644 | 666 | md5path_cache_ = new lru::Md5PathCache((memcache_num_units * 7) & mask_64, | |
| 1645 |
2/4✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
|
333 | statistics_); |
| 1646 | |||
| 1647 |
2/4✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
|
333 | inode_tracker_ = new glue::InodeTracker(); |
| 1648 |
2/4✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
|
333 | dentry_tracker_ = new glue::DentryTracker(); |
| 1649 |
2/4✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
|
333 | page_cache_tracker_ = new glue::PageCacheTracker(); |
| 1650 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 333 times.
|
333 | if (file_system_->IsNfsSource()) |
| 1651 | ✗ | page_cache_tracker_->Disable(); | |
| 1652 | 333 | } | |
| 1653 | |||
| 1654 | /** | ||
| 1655 | * Will create a tracer for the current mount point | ||
| 1656 | * Tracefile path, Trace buffer size and trace buffer flush threshold | ||
| 1657 | * can be configured by the options: CVMFS_TRACEFILE, | ||
| 1658 | * CVMFS_TRACEBUFFER, CVMFS_TRACEBUFFER_THRESHOLD(respectively) | ||
| 1659 | * VMFS_TRACEBUFFER and CVMFS_TRACEBUFFER_THRESHOLD will silently fallback | ||
| 1660 | * to default values if configuration values don't exist or are invalid | ||
| 1661 | */ | ||
| 1662 | 345 | bool MountPoint::CreateTracer() { | |
| 1663 | 345 | string optarg; | |
| 1664 |
2/4✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
|
345 | tracer_ = new Tracer(); |
| 1665 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_TRACEFILE", &optarg)) { |
| 1666 | ✗ | if (file_system_->type() != FileSystem::kFsFuse) { | |
| 1667 | ✗ | boot_error_ = "tracer is only supported in the fuse module"; | |
| 1668 | ✗ | boot_status_ = loader::kFailOptions; | |
| 1669 | ✗ | return false; | |
| 1670 | } | ||
| 1671 | ✗ | const string tracebuffer_file = optarg; | |
| 1672 | ✗ | uint64_t tracebuffer_size = kTracerBufferSize; | |
| 1673 | ✗ | uint64_t tracebuffer_threshold = kTracerFlushThreshold; | |
| 1674 | |||
| 1675 | ✗ | if (options_mgr_->GetValue("CVMFS_TRACEBUFFER", &optarg)) { | |
| 1676 | ✗ | tracebuffer_size = String2Uint64(optarg); | |
| 1677 | } | ||
| 1678 | ✗ | if (options_mgr_->GetValue("CVMFS_TRACEBUFFER_THRESHOLD", &optarg)) { | |
| 1679 | ✗ | tracebuffer_threshold = String2Uint64(optarg); | |
| 1680 | } | ||
| 1681 | ✗ | assert(tracebuffer_size <= INT_MAX && tracebuffer_threshold <= INT_MAX); | |
| 1682 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug, | |
| 1683 | "Initialising tracer with buffer size %" PRIu64 | ||
| 1684 | " and threshold %" PRIu64, | ||
| 1685 | tracebuffer_size, tracebuffer_threshold); | ||
| 1686 | ✗ | tracer_->Activate(tracebuffer_size, tracebuffer_threshold, | |
| 1687 | tracebuffer_file); | ||
| 1688 | } | ||
| 1689 | 345 | return true; | |
| 1690 | 345 | } | |
| 1691 | |||
| 1692 | |||
| 1693 | 439 | bool MountPoint::DetermineRootHash(shash::Any *root_hash) { | |
| 1694 | 439 | string optarg; | |
| 1695 |
4/6✓ Branch 2 taken 439 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 439 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 116 times.
✓ Branch 10 taken 323 times.
|
439 | if (options_mgr_->GetValue("CVMFS_ROOT_HASH", &optarg)) { |
| 1696 |
1/2✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
|
116 | *root_hash = MkFromHexPtr(shash::HexPtr(optarg), shash::kSuffixCatalog); |
| 1697 | 116 | return true; | |
| 1698 | } | ||
| 1699 | |||
| 1700 |
4/10✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 323 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 263 times.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
646 | if (!options_mgr_->IsDefined("CVMFS_REPOSITORY_TAG") |
| 1701 |
12/20✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 293 times.
✓ Branch 5 taken 30 times.
✓ Branch 8 taken 293 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 293 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 263 times.
✓ Branch 14 taken 30 times.
✓ Branch 15 taken 293 times.
✓ Branch 16 taken 30 times.
✓ Branch 18 taken 293 times.
✓ Branch 19 taken 30 times.
✓ Branch 21 taken 323 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
646 | && !options_mgr_->IsDefined("CVMFS_REPOSITORY_DATE")) { |
| 1702 | 263 | root_hash->SetNull(); | |
| 1703 | 263 | return true; | |
| 1704 | } | ||
| 1705 | |||
| 1706 | 60 | string history_path; | |
| 1707 |
2/4✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
|
60 | if (!FetchHistory(&history_path)) |
| 1708 | ✗ | return false; | |
| 1709 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
60 | const UnlinkGuard history_file(history_path); |
| 1710 | const UniquePtr<history::History> tag_db( | ||
| 1711 |
2/4✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
|
60 | history::SqliteHistory::Open(history_path)); |
| 1712 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
|
60 | if (!tag_db.IsValid()) { |
| 1713 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslog, | |
| 1714 | "failed to open history database (%s)", history_path.c_str()); | ||
| 1715 | ✗ | boot_error_ = "failed to open history database"; | |
| 1716 | ✗ | boot_status_ = loader::kFailHistory; | |
| 1717 | ✗ | return false; | |
| 1718 | } | ||
| 1719 | |||
| 1720 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
60 | history::History::Tag tag; |
| 1721 | bool retval; | ||
| 1722 |
4/6✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 60 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 30 times.
✓ Branch 10 taken 30 times.
|
60 | if (!options_mgr_->GetValue("CVMFS_REPOSITORY_TAG", &repository_tag_)) { |
| 1723 | 30 | string repository_date; | |
| 1724 | // options_mgr_->IsDefined("CVMFS_REPOSITORY_DATE") must be true | ||
| 1725 |
2/4✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 30 times.
✗ Branch 6 not taken.
|
30 | options_mgr_->GetValue("CVMFS_REPOSITORY_DATE", &repository_date); |
| 1726 |
1/2✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
|
30 | const time_t repository_utctime = IsoTimestamp2UtcTime(repository_date); |
| 1727 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
|
30 | if (repository_utctime == 0) { |
| 1728 | boot_error_ = "invalid timestamp in CVMFS_REPOSITORY_DATE: " | ||
| 1729 | ✗ | + repository_date + ". Use YYYY-MM-DDTHH:MM:SSZ"; | |
| 1730 | ✗ | boot_status_ = loader::kFailHistory; | |
| 1731 | ✗ | return false; | |
| 1732 | } | ||
| 1733 |
1/2✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
|
30 | retval = tag_db->GetByDate(repository_utctime, &tag); |
| 1734 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
|
30 | if (!retval) { |
| 1735 | boot_error_ = "no repository state as early as utc timestamp " | ||
| 1736 |
2/4✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
|
15 | + StringifyTime(repository_utctime, true); |
| 1737 | 15 | boot_status_ = loader::kFailHistory; | |
| 1738 | 15 | return false; | |
| 1739 | } | ||
| 1740 |
1/5✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
30 | LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslog, |
| 1741 | "time stamp %s UTC resolved to tag '%s'", | ||
| 1742 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
30 | StringifyTime(repository_utctime, true).c_str(), tag.name.c_str()); |
| 1743 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | repository_tag_ = tag.name; |
| 1744 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 2 taken 15 times.
|
30 | } else { |
| 1745 |
1/2✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
|
30 | retval = tag_db->GetByName(repository_tag_, &tag); |
| 1746 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
|
30 | if (!retval) { |
| 1747 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | boot_error_ = "no such tag: " + repository_tag_; |
| 1748 | 15 | boot_status_ = loader::kFailHistory; | |
| 1749 | 15 | return false; | |
| 1750 | } | ||
| 1751 | } | ||
| 1752 |
1/2✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
|
30 | LogCvmfs(kLogCvmfs, kLogDebug, "mounting tag %s", tag.name.c_str()); |
| 1753 | |||
| 1754 | 30 | *root_hash = tag.root_hash; | |
| 1755 | 30 | return true; | |
| 1756 | 439 | } | |
| 1757 | |||
| 1758 | |||
| 1759 | 60 | bool MountPoint::FetchHistory(std::string *history_path) { | |
| 1760 | manifest::Failures retval_mf; | ||
| 1761 | 60 | manifest::ManifestEnsemble ensemble; | |
| 1762 |
2/4✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 60 times.
✗ Branch 6 not taken.
|
60 | retval_mf = manifest::Fetch("", fqrn_, 0, NULL, signature_mgr_, download_mgr_, |
| 1763 | &ensemble); | ||
| 1764 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
|
60 | if (retval_mf != manifest::kFailOk) { |
| 1765 | ✗ | boot_error_ = "Failed to fetch manifest"; | |
| 1766 | ✗ | boot_status_ = loader::kFailHistory; | |
| 1767 | ✗ | return false; | |
| 1768 | } | ||
| 1769 | 60 | const shash::Any history_hash = ensemble.manifest->history(); | |
| 1770 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
|
60 | if (history_hash.IsNull()) { |
| 1771 | ✗ | boot_error_ = "No history"; | |
| 1772 | ✗ | boot_status_ = loader::kFailHistory; | |
| 1773 | ✗ | return false; | |
| 1774 | } | ||
| 1775 | |||
| 1776 | 60 | CacheManager::Label label; | |
| 1777 | 60 | label.flags = CacheManager::kLabelHistory; | |
| 1778 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
60 | label.path = fqrn_; |
| 1779 |
2/4✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 60 times.
✗ Branch 6 not taken.
|
180 | const int fd = fetcher_->Fetch( |
| 1780 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
120 | CacheManager::LabeledObject(history_hash, label)); |
| 1781 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
|
60 | if (fd < 0) { |
| 1782 | ✗ | boot_error_ = "failed to download history: " + StringifyInt(-fd); | |
| 1783 | ✗ | boot_status_ = loader::kFailHistory; | |
| 1784 | ✗ | return false; | |
| 1785 | } | ||
| 1786 | // We have the custom sqlite vfs driver installed | ||
| 1787 |
2/4✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
|
60 | *history_path = "@" + StringifyInt(fd); |
| 1788 | 60 | return true; | |
| 1789 | 60 | } | |
| 1790 | |||
| 1791 | |||
| 1792 | ✗ | unsigned MountPoint::GetEffectiveTtlSec() { | |
| 1793 | unsigned max_ttl; | ||
| 1794 | { | ||
| 1795 | ✗ | const MutexLockGuard lock_guard(lock_max_ttl_); | |
| 1796 | ✗ | max_ttl = max_ttl_sec_; | |
| 1797 | } | ||
| 1798 | ✗ | const unsigned catalog_ttl_sec = catalog_mgr_->GetTTL(); | |
| 1799 | |||
| 1800 | ✗ | return max_ttl ? std::min(max_ttl, catalog_ttl_sec) : catalog_ttl_sec; | |
| 1801 | } | ||
| 1802 | |||
| 1803 | |||
| 1804 | ✗ | unsigned MountPoint::GetMaxTtlMn() { | |
| 1805 | ✗ | const MutexLockGuard lock_guard(lock_max_ttl_); | |
| 1806 | ✗ | return max_ttl_sec_ / 60; | |
| 1807 | } | ||
| 1808 | |||
| 1809 | |||
| 1810 | /** | ||
| 1811 | * Files in the workspace from different file systems / mountpoints need to | ||
| 1812 | * have different names. Used, for example, for caching proxy settings. | ||
| 1813 | */ | ||
| 1814 | 559 | string MountPoint::GetUniqFileSuffix() { | |
| 1815 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 559 times.
✗ Branch 9 not taken.
|
1118 | return "." + file_system_->name() + "-" + fqrn_; |
| 1816 | } | ||
| 1817 | |||
| 1818 | |||
| 1819 | 574 | MountPoint::MountPoint(const string &fqrn, | |
| 1820 | FileSystem *file_system, | ||
| 1821 | 574 | OptionsManager *options_mgr) | |
| 1822 |
1/2✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
|
574 | : fqrn_(fqrn) |
| 1823 |
2/4✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 574 times.
✗ Branch 6 not taken.
|
574 | , uuid_(cvmfs::Uuid::Create("")) |
| 1824 | 574 | , file_system_(file_system) | |
| 1825 | 574 | , options_mgr_(options_mgr) | |
| 1826 | 574 | , statistics_(NULL) | |
| 1827 | 574 | , telemetry_aggr_(NULL) | |
| 1828 | 574 | , authz_fetcher_(NULL) | |
| 1829 | 574 | , authz_session_mgr_(NULL) | |
| 1830 | 574 | , authz_attachment_(NULL) | |
| 1831 | 574 | , backoff_throttle_(NULL) | |
| 1832 | 574 | , signature_mgr_(NULL) | |
| 1833 | 574 | , download_mgr_(NULL) | |
| 1834 | 574 | , external_download_mgr_(NULL) | |
| 1835 | 574 | , fetcher_(NULL) | |
| 1836 | 574 | , external_fetcher_(NULL) | |
| 1837 | 574 | , inode_annotation_(NULL) | |
| 1838 | 574 | , catalog_mgr_(NULL) | |
| 1839 | 574 | , chunk_tables_(NULL) | |
| 1840 | 574 | , simple_chunk_tables_(NULL) | |
| 1841 | 574 | , inode_cache_(NULL) | |
| 1842 | 574 | , path_cache_(NULL) | |
| 1843 | 574 | , md5path_cache_(NULL) | |
| 1844 | 574 | , tracer_(NULL) | |
| 1845 | 574 | , inode_tracker_(NULL) | |
| 1846 | 574 | , dentry_tracker_(NULL) | |
| 1847 | 574 | , page_cache_tracker_(NULL) | |
| 1848 | 574 | , statfs_cache_(NULL) | |
| 1849 | 574 | , resolv_conf_watcher_(NULL) | |
| 1850 | 574 | , max_ttl_sec_(kDefaultMaxTtlSec) | |
| 1851 | 574 | , kcache_timeout_sec_(static_cast<double>(kDefaultKCacheTtlSec)) | |
| 1852 | 574 | , fixed_catalog_(false) | |
| 1853 | 574 | , enforce_acls_(false) | |
| 1854 | 574 | , cache_symlinks_(false) | |
| 1855 | 574 | , fuse_expire_entry_(false) | |
| 1856 | 574 | , has_membership_req_(false) | |
| 1857 |
2/4✓ Branch 2 taken 574 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 574 times.
✗ Branch 6 not taken.
|
574 | , talk_socket_path_(std::string("./cvmfs_io.") + fqrn) |
| 1858 | 574 | , talk_socket_uid_(0) | |
| 1859 | 1148 | , talk_socket_gid_(0) { | |
| 1860 | 574 | const int retval = pthread_mutex_init(&lock_max_ttl_, NULL); | |
| 1861 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | assert(retval == 0); |
| 1862 | 574 | } | |
| 1863 | |||
| 1864 | |||
| 1865 | 574 | MountPoint::~MountPoint() { | |
| 1866 | 574 | pthread_mutex_destroy(&lock_max_ttl_); | |
| 1867 | |||
| 1868 |
2/2✓ Branch 0 taken 333 times.
✓ Branch 1 taken 241 times.
|
574 | delete page_cache_tracker_; |
| 1869 |
2/2✓ Branch 0 taken 333 times.
✓ Branch 1 taken 241 times.
|
574 | delete dentry_tracker_; |
| 1870 |
2/2✓ Branch 0 taken 333 times.
✓ Branch 1 taken 241 times.
|
574 | delete inode_tracker_; |
| 1871 |
2/2✓ Branch 0 taken 345 times.
✓ Branch 1 taken 229 times.
|
574 | delete tracer_; |
| 1872 |
2/2✓ Branch 0 taken 345 times.
✓ Branch 1 taken 229 times.
|
574 | delete md5path_cache_; |
| 1873 |
2/2✓ Branch 0 taken 333 times.
✓ Branch 1 taken 241 times.
|
574 | delete path_cache_; |
| 1874 |
2/2✓ Branch 0 taken 333 times.
✓ Branch 1 taken 241 times.
|
574 | delete inode_cache_; |
| 1875 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 562 times.
|
574 | delete simple_chunk_tables_; |
| 1876 |
2/2✓ Branch 0 taken 333 times.
✓ Branch 1 taken 241 times.
|
574 | delete chunk_tables_; |
| 1877 | |||
| 1878 |
2/2✓ Branch 0 taken 454 times.
✓ Branch 1 taken 120 times.
|
574 | delete catalog_mgr_; |
| 1879 |
2/2✓ Branch 0 taken 454 times.
✓ Branch 1 taken 120 times.
|
574 | delete inode_annotation_; |
| 1880 |
2/2✓ Branch 0 taken 454 times.
✓ Branch 1 taken 120 times.
|
574 | delete external_fetcher_; |
| 1881 |
2/2✓ Branch 0 taken 454 times.
✓ Branch 1 taken 120 times.
|
574 | delete fetcher_; |
| 1882 | |||
| 1883 |
2/2✓ Branch 0 taken 454 times.
✓ Branch 1 taken 120 times.
|
574 | delete external_download_mgr_; |
| 1884 |
2/2✓ Branch 0 taken 559 times.
✓ Branch 1 taken 15 times.
|
574 | delete download_mgr_; |
| 1885 | |||
| 1886 |
1/2✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
|
574 | if (signature_mgr_ != NULL) { |
| 1887 | 574 | signature_mgr_->Fini(); | |
| 1888 |
1/2✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
|
574 | delete signature_mgr_; |
| 1889 | } | ||
| 1890 | |||
| 1891 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | if (resolv_conf_watcher_ != NULL) { |
| 1892 | ✗ | resolv_conf_watcher_->Stop(); | |
| 1893 | ✗ | delete resolv_conf_watcher_; | |
| 1894 | } | ||
| 1895 | |||
| 1896 |
1/2✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
|
574 | delete backoff_throttle_; |
| 1897 |
1/2✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
|
574 | delete authz_attachment_; |
| 1898 |
1/2✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
|
574 | delete authz_session_mgr_; |
| 1899 |
1/2✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
|
574 | delete authz_fetcher_; |
| 1900 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
|
574 | delete telemetry_aggr_; |
| 1901 |
1/2✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
|
574 | delete statistics_; |
| 1902 |
1/2✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
|
574 | delete uuid_; |
| 1903 | |||
| 1904 |
2/2✓ Branch 0 taken 345 times.
✓ Branch 1 taken 229 times.
|
574 | delete statfs_cache_; |
| 1905 | 574 | } | |
| 1906 | |||
| 1907 | |||
| 1908 | 347 | void MountPoint::ReEvaluateAuthz() { | |
| 1909 |
1/2✓ Branch 1 taken 347 times.
✗ Branch 2 not taken.
|
347 | const string old_membership_req = membership_req_; |
| 1910 |
1/2✓ Branch 1 taken 347 times.
✗ Branch 2 not taken.
|
347 | has_membership_req_ = catalog_mgr_->GetVOMSAuthz(&membership_req_); |
| 1911 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 347 times.
|
347 | if (old_membership_req != membership_req_) { |
| 1912 | ✗ | authz_session_mgr_->ClearSessionCache(); | |
| 1913 | ✗ | authz_attachment_->set_membership(membership_req_); | |
| 1914 | } | ||
| 1915 | 347 | } | |
| 1916 | |||
| 1917 | |||
| 1918 | ✗ | void MountPoint::SetMaxTtlMn(unsigned value_minutes) { | |
| 1919 | ✗ | const MutexLockGuard lock_guard(lock_max_ttl_); | |
| 1920 | ✗ | max_ttl_sec_ = value_minutes * 60; | |
| 1921 | } | ||
| 1922 | |||
| 1923 | ✗ | void MountPoint::SetMaxTtlSec(unsigned value_secs) { | |
| 1924 | ✗ | const MutexLockGuard lock_guard(lock_max_ttl_); | |
| 1925 | ✗ | max_ttl_sec_ = value_secs; | |
| 1926 | } | ||
| 1927 | |||
| 1928 | 345 | bool MountPoint::SetupBehavior() { | |
| 1929 | 345 | string optarg; | |
| 1930 | |||
| 1931 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_MAX_TTL", &optarg)) |
| 1932 | ✗ | SetMaxTtlMn(String2Uint64(optarg)); | |
| 1933 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_MAX_TTL_SECS", &optarg)) |
| 1934 | ✗ | SetMaxTtlSec(String2Uint64(optarg)); | |
| 1935 | |||
| 1936 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_KCACHE_TIMEOUT", &optarg)) { |
| 1937 | // Can be negative and should then be interpreted as 0.0 | ||
| 1938 | ✗ | kcache_timeout_sec_ = std::max(0.0, | |
| 1939 | ✗ | static_cast<double>(String2Int64(optarg))); | |
| 1940 | } | ||
| 1941 | 345 | LogCvmfs(kLogCvmfs, kLogDebug, "kernel caches expire after %d seconds", | |
| 1942 |
1/2✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
|
345 | static_cast<int>(kcache_timeout_sec_)); |
| 1943 | |||
| 1944 | 345 | uint64_t statfs_time_cache_valid = 0; | |
| 1945 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_STATFS_CACHE_TIMEOUT", &optarg)) { |
| 1946 | ✗ | statfs_time_cache_valid = static_cast<uint64_t>(String2Uint64(optarg)); | |
| 1947 | } | ||
| 1948 |
1/2✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
|
345 | LogCvmfs(kLogCvmfs, kLogDebug, "statfs cache expires after %d seconds", |
| 1949 | static_cast<int>(statfs_time_cache_valid)); | ||
| 1950 |
1/2✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
|
345 | statfs_cache_ = new StatfsCache(statfs_time_cache_valid); |
| 1951 | |||
| 1952 | MagicXattrManager::EVisibility | ||
| 1953 | 345 | xattr_visibility = MagicXattrManager::kVisibilityRootOnly; | |
| 1954 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_HIDE_MAGIC_XATTRS", &optarg)) { |
| 1955 | ✗ | if (options_mgr_->IsOn(optarg)) | |
| 1956 | ✗ | xattr_visibility = MagicXattrManager::kVisibilityNever; | |
| 1957 | ✗ | else if (options_mgr_->IsOff(optarg)) | |
| 1958 | ✗ | xattr_visibility = MagicXattrManager::kVisibilityAlways; | |
| 1959 | } | ||
| 1960 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_MAGIC_XATTRS_VISIBILITY", &optarg)) { |
| 1961 | ✗ | if (ToUpper(optarg) == "ROOTONLY") { | |
| 1962 | ✗ | xattr_visibility = MagicXattrManager::kVisibilityRootOnly; | |
| 1963 | ✗ | } else if (ToUpper(optarg) == "NEVER") { | |
| 1964 | ✗ | xattr_visibility = MagicXattrManager::kVisibilityNever; | |
| 1965 | ✗ | } else if (ToUpper(optarg) == "ALWAYS") { | |
| 1966 | ✗ | xattr_visibility = MagicXattrManager::kVisibilityAlways; | |
| 1967 | } else { | ||
| 1968 | ✗ | LogCvmfs(kLogCvmfs, kLogSyslogWarn | kLogDebug, | |
| 1969 | "unsupported setting: CVMFS_MAGIC_XATTRS_VISIBILITY=%s", | ||
| 1970 | optarg.c_str()); | ||
| 1971 | } | ||
| 1972 | } | ||
| 1973 | |||
| 1974 | 345 | std::set<gid_t> protected_xattr_gids; | |
| 1975 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_XATTR_PRIVILEGED_GIDS", &optarg)) { |
| 1976 | ✗ | std::vector<string> tmp = SplitString(optarg, ','); | |
| 1977 | |||
| 1978 | ✗ | for (size_t i = 0; i < tmp.size(); i++) { | |
| 1979 | ✗ | const std::string trimmed = Trim(tmp[i]); | |
| 1980 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug, "Privileged gid for xattr added: %s", | |
| 1981 | trimmed.c_str()); | ||
| 1982 | ✗ | protected_xattr_gids.insert(static_cast<gid_t>(String2Uint64(trimmed))); | |
| 1983 | } | ||
| 1984 | } | ||
| 1985 | 345 | std::set<std::string> protected_xattrs; | |
| 1986 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_XATTR_PROTECTED_XATTRS", &optarg)) { |
| 1987 | ✗ | std::vector<string> tmp = SplitString(optarg, ','); | |
| 1988 | |||
| 1989 | ✗ | for (size_t i = 0; i < tmp.size(); i++) { | |
| 1990 | ✗ | const std::string trimmed = Trim(tmp[i]); | |
| 1991 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug, "Protected xattr added: %s", | |
| 1992 | trimmed.c_str()); | ||
| 1993 | ✗ | protected_xattrs.insert(trimmed); | |
| 1994 | } | ||
| 1995 | |||
| 1996 | // root has always access to xattr | ||
| 1997 | ✗ | if (protected_xattr_gids.count(0) < 1) { | |
| 1998 | ✗ | protected_xattr_gids.insert(0); | |
| 1999 | ✗ | LogCvmfs(kLogCvmfs, kLogDebug, | |
| 2000 | "Automatically added root to have access to protected xattrs."); | ||
| 2001 | } | ||
| 2002 | } | ||
| 2003 | 345 | magic_xattr_mgr_ = new MagicXattrManager( | |
| 2004 |
2/4✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
|
345 | this, xattr_visibility, protected_xattrs, protected_xattr_gids); |
| 2005 | |||
| 2006 | |||
| 2007 |
3/10✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 345 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
690 | if (options_mgr_->GetValue("CVMFS_ENFORCE_ACLS", &optarg) |
| 2008 |
3/10✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 345 times.
✗ Branch 12 not taken.
|
690 | && options_mgr_->IsOn(optarg)) { |
| 2009 | ✗ | enforce_acls_ = true; | |
| 2010 | } | ||
| 2011 | |||
| 2012 |
3/10✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 345 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
690 | if (options_mgr_->GetValue("CVMFS_CACHE_SYMLINKS", &optarg) |
| 2013 |
3/10✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 345 times.
✗ Branch 12 not taken.
|
690 | && options_mgr_->IsOn(optarg)) { |
| 2014 | ✗ | cache_symlinks_ = true; | |
| 2015 | } | ||
| 2016 | |||
| 2017 | |||
| 2018 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_TALK_SOCKET", &optarg)) { |
| 2019 | ✗ | talk_socket_path_ = optarg; | |
| 2020 | } | ||
| 2021 |
3/6✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
|
345 | if (options_mgr_->GetValue("CVMFS_TALK_OWNER", &optarg)) { |
| 2022 | ✗ | const bool retval = GetUidOf(optarg, &talk_socket_uid_, &talk_socket_gid_); | |
| 2023 | ✗ | if (!retval) { | |
| 2024 | ✗ | boot_error_ = "unknown owner of cvmfs_talk socket: " + optarg; | |
| 2025 | ✗ | boot_status_ = loader::kFailOptions; | |
| 2026 | ✗ | return false; | |
| 2027 | } | ||
| 2028 | } | ||
| 2029 | |||
| 2030 | // this can be later be changed to switch through different | ||
| 2031 | // telemetryAggregators | ||
| 2032 |
3/10✓ Branch 1 taken 345 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 345 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
690 | if (options_mgr_->GetValue("CVMFS_TELEMETRY_SEND", &optarg) |
| 2033 |
3/10✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 345 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 345 times.
✗ Branch 12 not taken.
|
690 | && options_mgr_->IsOn(optarg)) { |
| 2034 | ✗ | int telemetry_send_rate_sec = kDefaultTelemetrySendRateSec; | |
| 2035 | ✗ | if (options_mgr_->GetValue("CVMFS_TELEMETRY_RATE", &optarg)) { | |
| 2036 | ✗ | telemetry_send_rate_sec = static_cast<int>(String2Uint64(optarg)); | |
| 2037 | |||
| 2038 | // minimum send rate: 5sec | ||
| 2039 | ✗ | if (telemetry_send_rate_sec < kMinimumTelemetrySendRateSec) { | |
| 2040 | ✗ | telemetry_send_rate_sec = kMinimumTelemetrySendRateSec; | |
| 2041 | } | ||
| 2042 | |||
| 2043 | ✗ | telemetry_aggr_ = perf::TelemetryAggregator::Create( | |
| 2044 | statistics_, | ||
| 2045 | telemetry_send_rate_sec, | ||
| 2046 | options_mgr_, | ||
| 2047 | this, | ||
| 2048 | ✗ | fqrn_, | |
| 2049 | perf::kTelemetryInflux); | ||
| 2050 | ✗ | LogCvmfs(kLogTelemetry, kLogSyslog | kLogDebug, | |
| 2051 | "Enable telemetry to report every %d seconds", | ||
| 2052 | telemetry_send_rate_sec); | ||
| 2053 | } | ||
| 2054 | } | ||
| 2055 | |||
| 2056 | 345 | return true; | |
| 2057 | 345 | } | |
| 2058 | |||
| 2059 | |||
| 2060 | /** | ||
| 2061 | * Called twice once for the regular download manager and once for the external | ||
| 2062 | * download manager. | ||
| 2063 | */ | ||
| 2064 | 559 | void MountPoint::SetupDnsTuning(download::DownloadManager *manager) { | |
| 2065 | 559 | string optarg; | |
| 2066 | 559 | unsigned dns_timeout_ms = download::DownloadManager::kDnsDefaultTimeoutMs; | |
| 2067 | 559 | unsigned dns_retries = download::DownloadManager::kDnsDefaultRetries; | |
| 2068 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_DNS_TIMEOUT", &optarg)) |
| 2069 | ✗ | dns_timeout_ms = String2Uint64(optarg) * 1000; | |
| 2070 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_DNS_RETRIES", &optarg)) |
| 2071 | ✗ | dns_retries = String2Uint64(optarg); | |
| 2072 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
559 | manager->SetDnsParameters(dns_retries, dns_timeout_ms); |
| 2073 | |||
| 2074 | // Rest has to be after SetDnsParameters because SetDnsParameters might | ||
| 2075 | // construct a new resolver object | ||
| 2076 | |||
| 2077 | 559 | unsigned dns_min_ttl = dns::Resolver::kDefaultMinTtl; | |
| 2078 | 559 | unsigned dns_max_ttl = dns::Resolver::kDefaultMaxTtl; | |
| 2079 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_DNS_MIN_TTL", &optarg)) |
| 2080 | ✗ | dns_min_ttl = String2Uint64(optarg); | |
| 2081 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_DNS_MAX_TTL", &optarg)) |
| 2082 | ✗ | dns_max_ttl = String2Uint64(optarg); | |
| 2083 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
559 | manager->SetDnsTtlLimits(dns_min_ttl, dns_max_ttl); |
| 2084 | |||
| 2085 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_DNS_SERVER", &optarg)) { |
| 2086 | ✗ | download_mgr_->SetDnsServer(optarg); | |
| 2087 | } | ||
| 2088 | |||
| 2089 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_IPFAMILY_PREFER", &optarg)) { |
| 2090 | ✗ | switch (String2Int64(optarg)) { | |
| 2091 | ✗ | case 4: | |
| 2092 | ✗ | manager->SetIpPreference(dns::kIpPreferV4); | |
| 2093 | ✗ | break; | |
| 2094 | ✗ | case 6: | |
| 2095 | ✗ | manager->SetIpPreference(dns::kIpPreferV6); | |
| 2096 | ✗ | break; | |
| 2097 | } | ||
| 2098 | } | ||
| 2099 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_MAX_IPADDR_PER_PROXY", &optarg)) |
| 2100 | ✗ | manager->SetMaxIpaddrPerProxy(String2Uint64(optarg)); | |
| 2101 | 559 | } | |
| 2102 | |||
| 2103 | |||
| 2104 | 454 | bool MountPoint::SetupExternalDownloadMgr(bool dogeosort) { | |
| 2105 | 454 | string optarg; | |
| 2106 |
2/4✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
|
1362 | external_download_mgr_ = download_mgr_->Clone( |
| 2107 |
2/4✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
|
908 | perf::StatisticsTemplate("download-external", statistics_), "external"); |
| 2108 | |||
| 2109 | unsigned timeout; | ||
| 2110 | unsigned timeout_direct; | ||
| 2111 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | download_mgr_->GetTimeout(&timeout, &timeout_direct); |
| 2112 |
3/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 454 times.
|
454 | if (options_mgr_->GetValue("CVMFS_EXTERNAL_TIMEOUT", &optarg)) { |
| 2113 | ✗ | timeout = String2Uint64(optarg); | |
| 2114 | } | ||
| 2115 |
3/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 454 times.
|
454 | if (options_mgr_->GetValue("CVMFS_EXTERNAL_TIMEOUT_DIRECT", &optarg)) { |
| 2116 | ✗ | timeout_direct = String2Uint64(optarg); | |
| 2117 | } | ||
| 2118 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | external_download_mgr_->SetTimeout(timeout, timeout_direct); |
| 2119 | |||
| 2120 |
3/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 454 times.
|
454 | if (options_mgr_->GetValue("CVMFS_EXTERNAL_METALINK", &optarg)) { |
| 2121 | ✗ | external_download_mgr_->SetMetalinkChain(optarg); | |
| 2122 | // host chain will be set later when the metalink server is contacted | ||
| 2123 | ✗ | external_download_mgr_->SetHostChain(""); | |
| 2124 | // metalink requires redirects | ||
| 2125 | ✗ | external_download_mgr_->EnableRedirects(); | |
| 2126 |
4/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 30 times.
✓ Branch 10 taken 424 times.
|
454 | } else if (options_mgr_->GetValue("CVMFS_EXTERNAL_URL", &optarg)) { |
| 2127 |
1/2✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
|
30 | external_download_mgr_->SetHostChain(optarg); |
| 2128 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
|
30 | if (dogeosort) { |
| 2129 | ✗ | std::vector<std::string> host_chain; | |
| 2130 | ✗ | external_download_mgr_->GetHostInfo(&host_chain, NULL, NULL); | |
| 2131 | ✗ | download_mgr_->GeoSortServers(&host_chain); | |
| 2132 | ✗ | external_download_mgr_->SetHostChain(host_chain); | |
| 2133 | } | ||
| 2134 | } else { | ||
| 2135 |
2/4✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 424 times.
✗ Branch 6 not taken.
|
424 | external_download_mgr_->SetHostChain(""); |
| 2136 | } | ||
| 2137 | |||
| 2138 |
4/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 45 times.
✓ Branch 10 taken 409 times.
|
454 | if (options_mgr_->GetValue("CVMFS_EXTERNAL_MAX_SERVERS", &optarg)) { |
| 2139 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | const unsigned max_servers = String2Uint64(optarg); |
| 2140 | 45 | std::vector<std::string> host_chain; | |
| 2141 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | external_download_mgr_->GetHostInfo(&host_chain, NULL, NULL); |
| 2142 |
6/6✓ Branch 0 taken 30 times.
✓ Branch 1 taken 15 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 30 times.
|
45 | if (max_servers > 0 && max_servers < host_chain.size()) { |
| 2143 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | host_chain.resize(max_servers); |
| 2144 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | external_download_mgr_->SetHostChain(host_chain); |
| 2145 | } | ||
| 2146 | 45 | } | |
| 2147 | |||
| 2148 |
1/2✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
|
454 | string proxies = "DIRECT"; |
| 2149 |
3/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 454 times.
|
454 | if (options_mgr_->GetValue("CVMFS_EXTERNAL_HTTP_PROXY", &optarg)) { |
| 2150 | ✗ | proxies = download::ResolveProxyDescription( | |
| 2151 | optarg, | ||
| 2152 | ✗ | file_system_->workspace() + "/proxies-external" + GetUniqFileSuffix(), | |
| 2153 | ✗ | external_download_mgr_); | |
| 2154 | ✗ | if (proxies == "") { | |
| 2155 | ✗ | boot_error_ = "failed to discover external HTTP proxy servers"; | |
| 2156 | ✗ | boot_status_ = loader::kFailWpad; | |
| 2157 | ✗ | return false; | |
| 2158 | } | ||
| 2159 | } | ||
| 2160 | 454 | string fallback_proxies; | |
| 2161 |
3/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 454 times.
|
454 | if (options_mgr_->GetValue("CVMFS_EXTERNAL_FALLBACK_PROXY", &optarg)) |
| 2162 | ✗ | fallback_proxies = optarg; | |
| 2163 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | external_download_mgr_->SetProxyChain( |
| 2164 | proxies, fallback_proxies, download::DownloadManager::kSetProxyBoth); | ||
| 2165 | |||
| 2166 | 454 | return true; | |
| 2167 | 454 | } | |
| 2168 | |||
| 2169 | |||
| 2170 | 559 | void MountPoint::SetupHttpTuning() { | |
| 2171 | 559 | string optarg; | |
| 2172 | |||
| 2173 | // TODO(jblomer): avoid double default settings | ||
| 2174 | |||
| 2175 | 559 | unsigned timeout = kDefaultTimeoutSec; | |
| 2176 | 559 | unsigned timeout_direct = kDefaultTimeoutSec; | |
| 2177 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_TIMEOUT", &optarg)) |
| 2178 | ✗ | timeout = String2Uint64(optarg); | |
| 2179 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_TIMEOUT_DIRECT", &optarg)) |
| 2180 | ✗ | timeout_direct = String2Uint64(optarg); | |
| 2181 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
559 | download_mgr_->SetTimeout(timeout, timeout_direct); |
| 2182 | |||
| 2183 | 559 | unsigned max_retries = kDefaultRetries; | |
| 2184 | 559 | unsigned backoff_init = kDefaultBackoffInitMs; | |
| 2185 | 559 | unsigned backoff_max = kDefaultBackoffMaxMs; | |
| 2186 |
4/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 547 times.
✓ Branch 10 taken 12 times.
|
559 | if (options_mgr_->GetValue("CVMFS_MAX_RETRIES", &optarg)) |
| 2187 |
1/2✓ Branch 1 taken 547 times.
✗ Branch 2 not taken.
|
547 | max_retries = String2Uint64(optarg); |
| 2188 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_BACKOFF_INIT", &optarg)) |
| 2189 | ✗ | backoff_init = String2Uint64(optarg) * 1000; | |
| 2190 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_BACKOFF_MAX", &optarg)) |
| 2191 | ✗ | backoff_max = String2Uint64(optarg) * 1000; | |
| 2192 |
1/2✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
|
559 | download_mgr_->SetRetryParameters(max_retries, backoff_init, backoff_max); |
| 2193 | |||
| 2194 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_LOW_SPEED_LIMIT", &optarg)) |
| 2195 | ✗ | download_mgr_->SetLowSpeedLimit(String2Uint64(optarg)); | |
| 2196 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_PROXY_RESET_AFTER", &optarg)) { |
| 2197 | ✗ | download_mgr_->SetProxyGroupResetDelay(String2Uint64(optarg)); | |
| 2198 | // Use the proxy reset delay as the default for the metalink reset delay | ||
| 2199 | ✗ | download_mgr_->SetMetalinkResetDelay(String2Uint64(optarg)); | |
| 2200 | } | ||
| 2201 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_METALINK_RESET_AFTER", &optarg)) |
| 2202 | ✗ | download_mgr_->SetMetalinkResetDelay(String2Uint64(optarg)); | |
| 2203 |
3/6✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 559 times.
|
559 | if (options_mgr_->GetValue("CVMFS_HOST_RESET_AFTER", &optarg)) |
| 2204 | ✗ | download_mgr_->SetHostResetDelay(String2Uint64(optarg)); | |
| 2205 | |||
| 2206 |
3/10✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 559 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1118 | if (options_mgr_->GetValue("CVMFS_FOLLOW_REDIRECTS", &optarg) |
| 2207 |
3/10✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 559 times.
✗ Branch 12 not taken.
|
1118 | && options_mgr_->IsOn(optarg)) { |
| 2208 | ✗ | download_mgr_->EnableRedirects(); | |
| 2209 | } | ||
| 2210 |
3/10✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 559 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
1118 | if (options_mgr_->GetValue("CVMFS_SEND_INFO_HEADER", &optarg) |
| 2211 |
3/10✓ Branch 2 taken 559 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 559 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 559 times.
✗ Branch 12 not taken.
|
1118 | && options_mgr_->IsOn(optarg)) { |
| 2212 | ✗ | download_mgr_->EnableInfoHeader(); | |
| 2213 | } | ||
| 2214 | 559 | } | |
| 2215 | |||
| 2216 | |||
| 2217 | 454 | void MountPoint::SetupInodeAnnotation() { | |
| 2218 | 454 | string optarg; | |
| 2219 | |||
| 2220 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
|
454 | if (file_system_->IsNfsSource()) { |
| 2221 | ✗ | inode_annotation_ = new catalog::InodeNfsGenerationAnnotation(); | |
| 2222 | } else { | ||
| 2223 |
1/2✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
|
454 | inode_annotation_ = new catalog::InodeGenerationAnnotation(); |
| 2224 | } | ||
| 2225 |
3/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 454 times.
|
454 | if (options_mgr_->GetValue("CVMFS_INITIAL_GENERATION", &optarg)) { |
| 2226 | ✗ | inode_annotation_->IncGeneration(String2Uint64(optarg)); | |
| 2227 | } | ||
| 2228 | |||
| 2229 |
2/2✓ Branch 1 taken 438 times.
✓ Branch 2 taken 16 times.
|
454 | if (file_system_->type() == FileSystem::kFsFuse) { |
| 2230 | 438 | catalog_mgr_->SetInodeAnnotation(inode_annotation_); | |
| 2231 | } | ||
| 2232 | 454 | } | |
| 2233 | |||
| 2234 | |||
| 2235 | 454 | bool MountPoint::SetupOwnerMaps() { | |
| 2236 | 454 | string optarg; | |
| 2237 | 454 | catalog::OwnerMap uid_map; | |
| 2238 | 454 | catalog::OwnerMap gid_map; | |
| 2239 | |||
| 2240 |
4/6✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 454 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 439 times.
|
454 | if (options_mgr_->GetValue("CVMFS_UID_MAP", &optarg)) { |
| 2241 |
2/4✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
|
15 | if (!uid_map.Read(optarg)) { |
| 2242 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | boot_error_ = "failed to parse uid map " + optarg; |
| 2243 | 15 | boot_status_ = loader::kFailOptions; | |
| 2244 | 15 | return false; | |
| 2245 | } | ||
| 2246 | } | ||
| 2247 |
3/6✓ Branch 2 taken 439 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 439 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 439 times.
|
439 | if (options_mgr_->GetValue("CVMFS_GID_MAP", &optarg)) { |
| 2248 | ✗ | if (!gid_map.Read(optarg)) { | |
| 2249 | ✗ | boot_error_ = "failed to parse gid map " + optarg; | |
| 2250 | ✗ | boot_status_ = loader::kFailOptions; | |
| 2251 | ✗ | return false; | |
| 2252 | } | ||
| 2253 | } | ||
| 2254 |
1/2✓ Branch 1 taken 439 times.
✗ Branch 2 not taken.
|
439 | catalog_mgr_->SetOwnerMaps(uid_map, gid_map); |
| 2255 | |||
| 2256 | // TODO(jblomer): make local to catalog manager | ||
| 2257 |
3/10✓ Branch 1 taken 439 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 439 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 439 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
878 | if (options_mgr_->GetValue("CVMFS_CLAIM_OWNERSHIP", &optarg) |
| 2258 |
3/10✓ Branch 2 taken 439 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 439 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 439 times.
✗ Branch 12 not taken.
|
878 | && options_mgr_->IsOn(optarg)) { |
| 2259 | ✗ | g_claim_ownership = true; | |
| 2260 | } | ||
| 2261 |
3/10✓ Branch 1 taken 439 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 439 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 439 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
878 | if (options_mgr_->GetValue("CVMFS_WORLD_READABLE", &optarg) |
| 2262 |
3/10✓ Branch 2 taken 439 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 439 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 439 times.
✗ Branch 12 not taken.
|
878 | && options_mgr_->IsOn(optarg)) { |
| 2263 | ✗ | g_world_readable = true; | |
| 2264 | } | ||
| 2265 | |||
| 2266 | |||
| 2267 | 439 | return true; | |
| 2268 | 454 | } | |
| 2269 | |||
| 2270 |