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