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