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