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 
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  n_emfile_ = statistics_->Register("eio.emfile",
269  "EMFILE returned to calling process. cvmfs.cc:cvmfs_read()");
270 
271  string optarg;
272  if (options_mgr_->GetValue("CVMFS_INSTRUMENT_FUSE", &optarg) &&
273  options_mgr_->IsOn(optarg))
274  {
276  }
277 
278  hist_fs_lookup_ = new Log2Histogram(30);
279  hist_fs_forget_ = new Log2Histogram(30);
286  hist_fs_open_ = new Log2Histogram(30);
287  hist_fs_read_ = new Log2Histogram(30);
289 }
290 
291 
297  const string &instance
298 ) {
299  string optarg;
301 
302  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_REFCOUNT", instance),
303  &optarg)
304  && options_mgr_->IsOff(optarg))
305  {
306  settings.do_refcount = false;
307  }
308 
309  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SHARED", instance),
310  &optarg)
311  && options_mgr_->IsOn(optarg))
312  {
313  settings.is_shared = true;
314  }
315  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SERVER_MODE", instance),
316  &optarg)
317  && options_mgr_->IsOn(optarg))
318  {
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  {
327  settings.quota_limit = String2Int64(optarg) * 1024 * 1024;
328  }
329  if (settings.quota_limit > 0)
330  settings.is_managed = true;
331 
332  settings.cache_path = kDefaultCacheBase;
333  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_BASE", instance),
334  &optarg))
335  {
336  settings.cache_path = MakeCanonicalPath(optarg);
337  settings.cache_base_defined = true;
338  }
339  if (settings.is_shared) {
340  settings.cache_path += "/shared";
341  } else {
342  settings.cache_path += "/" + name_;
343  }
344 
345  // CheckCacheMode makes sure that CVMFS_CACHE_DIR and CVMFS_CACHE_BASE are
346  // not set at the same time.
347  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_DIR", instance),
348  &optarg))
349  {
350  settings.cache_dir_defined = true;
351  settings.cache_path = optarg;
352  }
353  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_ALIEN", instance),
354  &optarg))
355  {
356  settings.is_alien = true;
357  settings.cache_path = optarg;
358  }
359  // We already changed the cwd to the workspace
360  // Which is only done if using FUSE
361  if ((type_ == kFsFuse) && (settings.cache_path == workspace_fullpath_)) {
362  settings.cache_path = ".";
363  }
364 
365  // The cache workspace usually is the cache directory, unless explicitly
366  // set otherwise
367  settings.workspace = settings.cache_path;
368  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_WORKSPACE", instance),
369  &optarg) ||
370  options_mgr_->GetValue("CVMFS_WORKSPACE", &optarg))
371  {
372  // Used for the shared quota manager
373  settings.workspace = optarg;
374  }
375 
376  return settings;
377 }
378 
379 
381  string optarg;
382 
383  if (options_mgr_->GetValue("CVMFS_NFS_SOURCE", &optarg) &&
384  options_mgr_->IsOn(optarg))
385  {
386  nfs_mode_ |= kNfsMaps;
387  if (options_mgr_->GetValue("CVMFS_NFS_SHARED", &optarg)) {
389  nfs_maps_dir_ = optarg;
390  }
391  }
392 
393  if ((type_ == kFsLibrary) && (nfs_mode_ != kNfsNone)) {
394  boot_error_ = "Failure: libcvmfs does not support NFS export.";
396  return false;
397  }
398  return true;
399 }
400 
401 
403  : name_(fs_info.name)
404  , exe_path_(fs_info.exe_path)
405  , type_(fs_info.type)
406  , options_mgr_(fs_info.options_mgr)
407  , wait_workspace_(fs_info.wait_workspace)
408  , foreground_(fs_info.foreground)
409  , n_fs_open_(NULL)
410  , n_fs_dir_open_(NULL)
411  , n_fs_lookup_(NULL)
412  , n_fs_lookup_negative_(NULL)
413  , n_fs_stat_(NULL)
414  , n_fs_stat_stale_(NULL)
415  , n_fs_statfs_(NULL)
416  , n_fs_statfs_cached_(NULL)
417  , n_fs_read_(NULL)
418  , n_fs_readlink_(NULL)
419  , n_fs_forget_(NULL)
420  , n_fs_inode_replace_(NULL)
421  , no_open_files_(NULL)
422  , no_open_dirs_(NULL)
423  , n_eio_total_(NULL)
424  , n_eio_01_(NULL)
425  , n_eio_02_(NULL)
426  , n_eio_03_(NULL)
427  , n_eio_04_(NULL)
428  , n_eio_05_(NULL)
429  , n_eio_06_(NULL)
430  , n_eio_07_(NULL)
431  , n_eio_08_(NULL)
432  , n_emfile_(NULL)
433  , statistics_(NULL)
434  , fd_workspace_lock_(-1)
435  , found_previous_crash_(false)
437  , cache_mgr_(NULL)
438  , uuid_cache_(NULL)
439  , nfs_maps_(NULL)
440  , has_custom_sqlitevfs_(false)
441 {
442  assert(!g_alive);
443  g_alive = true;
444  g_uid = geteuid();
445  g_gid = getegid();
446 
447  string optarg;
448  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SERVER_MODE",
450  &optarg)
451  && options_mgr_->IsOn(optarg))
452  {
453  g_raw_symlinks = true;
454  }
455 }
456 
457 
460 
463 
464  delete uuid_cache_;
465  delete nfs_maps_;
466  delete cache_mgr_;
467 
468  if (sqlite3_temp_directory) {
469  sqlite3_free(sqlite3_temp_directory);
470  sqlite3_temp_directory = NULL;
471  }
472 
473  if (!path_crash_guard_.empty())
474  unlink(path_crash_guard_.c_str());
475  if (!path_workspace_lock_.empty())
476  unlink(path_workspace_lock_.c_str());
477  if (fd_workspace_lock_ >= 0)
479 
480  sqlite3_shutdown();
482 
483  delete hist_fs_lookup_;
484  delete hist_fs_forget_multi_;
485  delete hist_fs_forget_;
486  delete hist_fs_getattr_;
487  delete hist_fs_readlink_;
488  delete hist_fs_opendir_;
489  delete hist_fs_releasedir_;
490  delete hist_fs_readdir_;
491  delete hist_fs_open_;
492  delete hist_fs_read_;
493  delete hist_fs_release_;
494  delete statistics_;
495 
496  SetLogSyslogPrefix("");
497  SetLogMicroSyslog("");
498  SetLogDebugFile("");
499  google::protobuf::ShutdownProtobufLibrary();
500  g_alive = false;
501 }
502 
503 
505  path_workspace_lock_ = workspace_ + "/lock." + name_;
507  if (fd_workspace_lock_ >= 0)
508  return true;
509 
510  if (fd_workspace_lock_ == -1) {
511  boot_error_ = "could not acquire workspace lock (" +
512  StringifyInt(errno) + ")";
514  return false;
515  }
516 
517  assert(fd_workspace_lock_ == -2);
518 
519  if (!wait_workspace_) {
521  return false;
522  }
523 
525  if (fd_workspace_lock_ < 0) {
526  boot_error_ = "could not acquire workspace lock (" +
527  StringifyInt(errno) + ")";
529  return false;
530  }
531  return true;
532 }
533 
534 
536  void *user_data __attribute__((unused)),
537  int sqlite_extended_error,
538  const char *message)
539 {
540  int log_dest = kLogDebug;
541  int sqlite_error = sqlite_extended_error & 0xFF;
542  switch (sqlite_error) {
543  case SQLITE_INTERNAL:
544  case SQLITE_PERM:
545  case SQLITE_NOMEM:
546  case SQLITE_IOERR:
547  case SQLITE_CORRUPT:
548  case SQLITE_FULL:
549  case SQLITE_CANTOPEN:
550  case SQLITE_MISUSE:
551  case SQLITE_FORMAT:
552  case SQLITE_NOTADB:
553  log_dest |= kLogSyslogErr;
554  break;
555  case SQLITE_WARNING:
556  case SQLITE_NOTICE:
557  default:
558  break;
559  }
560  LogCvmfs(kLogCvmfs, log_dest, "SQlite3: %s (%d)",
561  message, sqlite_extended_error);
562 }
563 
564 
571  const string &generic_parameter,
572  const string &instance)
573 {
574  assert(HasPrefix(generic_parameter, "CVMFS_CACHE_", false));
575 
576  if (instance == kDefaultCacheMgrInstance) {
577  // Compatibility parameter names
578  if ((generic_parameter == "CVMFS_CACHE_SHARED") &&
579  !options_mgr_->IsDefined(generic_parameter))
580  {
581  return "CVMFS_SHARED_CACHE";
582  }
583  if ((generic_parameter == "CVMFS_CACHE_ALIEN") &&
584  !options_mgr_->IsDefined(generic_parameter))
585  {
586  return "CVMFS_ALIEN_CACHE";
587  }
588  if ((generic_parameter == "CVMFS_CACHE_SERVER_MODE") &&
589  !options_mgr_->IsDefined(generic_parameter))
590  {
591  return "CVMFS_SERVER_CACHE_MODE";
592  }
593  if ((generic_parameter == "CVMFS_CACHE_QUOTA_LIMIT") &&
594  !options_mgr_->IsDefined(generic_parameter))
595  {
596  return "CVMFS_QUOTA_LIMIT";
597  }
598  return generic_parameter;
599  }
600 
601  return "CVMFS_CACHE_" + instance + "_" + generic_parameter.substr(12);
602 }
603 
604 
607  n_eio_total_->Set(0);
608  n_eio_01_->Set(0);
609  n_eio_02_->Set(0);
610  n_eio_03_->Set(0);
611  n_eio_04_->Set(0);
612  n_eio_05_->Set(0);
613  n_eio_06_->Set(0);
614  n_eio_07_->Set(0);
615  n_eio_08_->Set(0);
616  n_emfile_->Set(0);
617 }
618 
619 
623 CacheManager *FileSystem::SetupCacheMgr(const string &instance) {
624  if (constructed_instances_.find(instance) != constructed_instances_.end()) {
625  boot_error_ = "circular cache definition: " + instance;
627  return NULL;
628  }
629  constructed_instances_.insert(instance);
630 
631  LogCvmfs(kLogCvmfs, kLogDebug, "setting up cache manager instance %s",
632  instance.c_str());
633  string instance_type;
634  if (instance == kDefaultCacheMgrInstance) {
635  instance_type = "posix";
636  } else {
637  options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_TYPE", instance),
638  &instance_type);
639  }
640  if (instance_type == "posix") {
641  return SetupPosixCacheMgr(instance);
642  } else if (instance_type == "ram") {
643  return SetupRamCacheMgr(instance);
644  } else if (instance_type == "tiered") {
645  return SetupTieredCacheMgr(instance);
646  } else if (instance_type == "external") {
647  return SetupExternalCacheMgr(instance);
648  } else {
649  boot_error_ = "invalid cache manager type for '" + instance + "':" +
650  instance_type;
652  return NULL;
653  }
654 }
655 
656 
658  string optarg;
659  unsigned nfiles = kDefaultNfiles;
660  if (options_mgr_->GetValue("CVMFS_NFILES", &optarg))
661  nfiles = String2Uint64(optarg);
662  vector<string> cmd_line;
663  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_CMDLINE", instance),
664  &optarg))
665  {
666  cmd_line = SplitString(optarg, ',');
667  }
668 
669  if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_LOCATOR", instance),
670  &optarg))
671  {
672  boot_error_ = MkCacheParm("CVMFS_CACHE_LOCATOR", instance) + " missing";
674  return NULL;
675  }
676 
678  ExternalCacheManager::CreatePlugin(optarg, cmd_line));
679  if (!plugin_handle->IsValid()) {
680  boot_error_ = plugin_handle->error_msg();
682  return NULL;
683  }
685  plugin_handle->fd_connection(), nfiles, name_ + ":" + instance);
686  if (cache_mgr == NULL) {
687  boot_error_ = "failed to create external cache manager for " + instance;
689  return NULL;
690  }
691  cache_mgr->AcquireQuotaManager(ExternalQuotaManager::Create(cache_mgr));
692  return cache_mgr;
693 }
694 
695 
698  if (!CheckPosixCacheSettings(settings))
699  return NULL;
701  settings.cache_path,
702  settings.is_alien,
705  settings.do_refcount));
706  if (!cache_mgr.IsValid()) {
707  boot_error_ = "Failed to setup posix cache '" + instance + "' in " +
708  settings.cache_path + ": " + strerror(errno);
710  return NULL;
711  }
712 
713  // Sentinel file for future use
714  // Might be a read-only cache
715  const bool ignore_failure = settings.is_alien;
716  CreateFile(settings.cache_path + "/.cvmfscache", 0600, ignore_failure);
717 
718  if (settings.is_managed) {
719  if (!SetupPosixQuotaMgr(settings, cache_mgr.weak_ref()))
720  return NULL;
721  }
722  return cache_mgr.Release();
723 }
724 
725 
726 CacheManager *FileSystem::SetupRamCacheMgr(const string &instance) {
727  string optarg;
728  unsigned nfiles = kDefaultNfiles;
729  if (options_mgr_->GetValue("CVMFS_NFILES", &optarg)) {
730  nfiles = String2Uint64(optarg);
731  }
732  uint64_t sz_cache_bytes;
733  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SIZE", instance),
734  &optarg))
735  {
736  if (HasSuffix(optarg, "%", false)) {
737  sz_cache_bytes = platform_memsize() * String2Uint64(optarg)/100;
738  } else {
739  sz_cache_bytes = String2Uint64(optarg) * 1024 * 1024;
740  }
741  } else {
742  sz_cache_bytes = platform_memsize() >> 5; // ~3%
743  }
745  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_MALLOC", instance),
746  &optarg))
747  {
748  if (optarg == "libc") {
750  } else if (optarg == "heap") {
752  } else {
753  boot_error_ = "Failure: unknown malloc " +
754  MkCacheParm("CVMFS_CACHE_MALLOC", instance) + "=" + optarg;
756  return NULL;
757  }
758  }
759  sz_cache_bytes = RoundUp8(std::max(static_cast<uint64_t>(40 * 1024 * 1024),
760  sz_cache_bytes));
762  sz_cache_bytes,
763  nfiles,
764  alloc,
765  perf::StatisticsTemplate("cache." + instance, statistics_));
766  if (cache_mgr == NULL) {
767  boot_error_ = "failed to create ram cache manager for " + instance;
769  return NULL;
770  }
771  cache_mgr->AcquireQuotaManager(new NoopQuotaManager());
772  return cache_mgr;
773 }
774 
775 
777  string optarg;
778  if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_UPPER", instance),
779  &optarg))
780  {
781  boot_error_ = MkCacheParm("CVMFS_CACHE_UPPER", instance) + " missing";
783  return NULL;
784  }
785  UniquePtr<CacheManager> upper(SetupCacheMgr(optarg));
786  if (!upper.IsValid())
787  return NULL;
788 
789  if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_LOWER", instance),
790  &optarg))
791  {
792  boot_error_ = MkCacheParm("CVMFS_CACHE_LOWER", instance) + " missing";
794  return NULL;
795  }
796  UniquePtr<CacheManager> lower(SetupCacheMgr(optarg));
797  if (!lower.IsValid())
798  return NULL;
799 
800  CacheManager *tiered =
801  TieredCacheManager::Create(upper.Release(), lower.Release());
802  if (tiered == NULL) {
803  boot_error_ = "Failed to setup tiered cache manager " + instance;
805  return NULL;
806  }
807  if (options_mgr_->GetValue(
808  MkCacheParm("CVMFS_CACHE_LOWER_READONLY", instance), &optarg) &&
809  options_mgr_->IsOn(optarg))
810  {
811  static_cast<TieredCacheManager*>(tiered)->SetLowerReadOnly();
812  }
813  return tiered;
814 }
815 
816 
818  path_crash_guard_ = workspace_ + "/running." + name_;
819  platform_stat64 info;
820  int retval = platform_stat(path_crash_guard_.c_str(), &info);
821  if (retval == 0) {
822  found_previous_crash_ = true;
824  "looks like cvmfs has been crashed previously");
825  }
826  retval = open(path_crash_guard_.c_str(), O_RDONLY | O_CREAT, 0600);
827  if (retval < 0) {
828  boot_error_ = "could not open running sentinel (" +
829  StringifyInt(errno) + ")";
831  return false;
832  }
833  close(retval);
834  return true;
835 }
836 
837 
839  if (type_ == kFsFuse) {
840  // Try to jump to workspace / cache directory. This tests, if it is
841  // accessible and it brings speed later on.
842  int retval = chdir(workspace_.c_str());
843  if (retval != 0) {
844  boot_error_ = "workspace " + workspace_ + " is unavailable";
846  return false;
847  }
848  workspace_ = ".";
849  return true;
850  }
851 
852  // Note: as of version 2.4 support for CVMFS_CWD_CACHE is dropped due to
853  // disproportionate large complexity to configure correctly. This affects
854  // only libcvmfs, mostly the legacy part.
855  // string optarg;
856  // if (options_mgr_->GetValue("CVMFS_CWD_CACHE", &optarg) &&
857  // options_mgr_->IsOn(optarg))
858  // {
859  // ...
860  // }
861  return true;
862 }
863 
864 
869  setenv("CVMFS_ARCH", GetArch().c_str(), 1 /* overwrite */);
870 }
871 
872 
874  const OptionsManager &options_mgr, const std::string &prefix)
875 {
877 
878  string optarg;
879  if (options_mgr.GetValue("CVMFS_SYSLOG_LEVEL", &optarg))
881  if (options_mgr.GetValue("CVMFS_SYSLOG_FACILITY", &optarg))
883  if (options_mgr.GetValue("CVMFS_USYSLOG", &optarg))
884  SetLogMicroSyslog(optarg);
885  if (options_mgr.GetValue("CVMFS_DEBUGLOG", &optarg))
886  SetLogDebugFile(optarg);
887  if (options_mgr.GetValue("CVMFS_SYSLOG_PREFIX", &optarg)) {
888  SetLogSyslogPrefix(optarg);
889  } else {
890  SetLogSyslogPrefix(prefix);
891  }
892 }
893 
894 
897 }
898 
899 
901 #ifdef CVMFS_NFS_SUPPORT
902  if (!IsHaNfsSource())
904 
905  string no_nfs_sentinel;
906  if (cache_mgr_->id() == kPosixCacheManager) {
907  PosixCacheManager *posix_cache_mgr =
908  reinterpret_cast<PosixCacheManager *>(cache_mgr_);
909  no_nfs_sentinel = posix_cache_mgr->cache_path() + "/no_nfs_maps." + name_;
910  if (!IsNfsSource()) {
911  // Might be a read-only cache
912  const bool ignore_failure = posix_cache_mgr->alien_cache();
913  CreateFile(no_nfs_sentinel, 0600, ignore_failure);
914  return true;
915  }
916  } else {
917  if (IsNfsSource()) {
918  boot_error_ = "NFS source only works with POSIX cache manager.";
920  return false;
921  }
922  return true;
923  }
924 
926  assert(IsNfsSource());
927  if (!no_nfs_sentinel.empty() && FileExists(no_nfs_sentinel)) {
928  boot_error_ = "Cache was used without NFS maps before. "
929  "It has to be wiped out.";
931  return false;
932  }
933 
934  // nfs maps need to be protected by workspace lock
935  PosixCacheManager *posix_cache_mgr =
936  reinterpret_cast<PosixCacheManager *>(cache_mgr_);
937  if (posix_cache_mgr->cache_path() != workspace_) {
938  boot_error_ = "Cache directory and workspace must be identical for "
939  "NFS export";
941  return false;
942  }
943 
944  string inode_cache_dir = nfs_maps_dir_ + "/nfs_maps." + name_;
945  if (!MkdirDeep(inode_cache_dir, 0700)) {
946  boot_error_ = "Failed to initialize NFS maps";
948  return false;
949  }
950 
951  // TODO(jblomer): make this a manager class
952  if (IsHaNfsSource()) {
954  inode_cache_dir,
957  statistics_);
958  } else {
960  inode_cache_dir,
963  statistics_);
964  }
965 
966  if (nfs_maps_ == NULL) {
967  boot_error_ = "Failed to initialize NFS maps";
969  return false;
970  }
971 
972  string optarg;
973  if (options_mgr_->GetValue("CVMFS_NFS_INTERLEAVED_INODES", &optarg)) {
974  vector<string> tokens = SplitString(optarg, '%');
975  if (tokens.size() != 2) {
976  boot_error_ =
977  "invalid format for CVMFS_NFS_INTERLEAVED_INODES: " + optarg;
979  return false;
980  }
982  String2Uint64(tokens[0]));
983  }
984 
985  return true;
986 
987 #else
988  return true;
989 #endif
990 }
991 
992 
995  CacheManager *cache_mgr
996 ) {
997  assert(settings.quota_limit >= 0);
998  int64_t quota_threshold = settings.quota_limit / 2;
999  string cache_workspace = settings.cache_path;
1000  if (settings.cache_path != settings.workspace) {
1002  "using workspace %s to protect cache database in %s",
1003  settings.workspace.c_str(), settings.cache_path.c_str());
1004  cache_workspace += ":" + settings.workspace;
1005  }
1006  PosixQuotaManager *quota_mgr;
1007 
1008  if (settings.is_shared) {
1009  quota_mgr = PosixQuotaManager::CreateShared(
1010  exe_path_,
1011  cache_workspace,
1012  settings.quota_limit,
1013  quota_threshold,
1014  foreground_);
1015  if (quota_mgr == NULL) {
1016  boot_error_ = "Failed to initialize shared lru cache";
1018  return false;
1019  }
1020  } else {
1021  quota_mgr = PosixQuotaManager::Create(
1022  cache_workspace,
1023  settings.quota_limit,
1024  quota_threshold,
1026  if (quota_mgr == NULL) {
1027  boot_error_ = "Failed to initialize lru cache";
1029  return false;
1030  }
1031  }
1032 
1033  if (quota_mgr->GetSize() > quota_mgr->GetCapacity()) {
1035  "cache is already beyond quota size "
1036  "(size: %" PRId64 ", capacity: %" PRId64 "), cleaning up",
1037  quota_mgr->GetSize(), quota_mgr->GetCapacity());
1038  if (!quota_mgr->Cleanup(quota_threshold)) {
1039  delete quota_mgr;
1040  boot_error_ = "Failed to clean up cache";
1042  return false;
1043  }
1044  }
1045 
1046  int retval = cache_mgr->AcquireQuotaManager(quota_mgr);
1047  assert(retval);
1049  "CernVM-FS: quota initialized, current size %luMB",
1050  quota_mgr->GetSize() / (1024 * 1024));
1051  return true;
1052 }
1053 
1054 
1056  // Make sure SQlite starts clean after initialization
1057  sqlite3_shutdown();
1058 
1059  int retval;
1060  retval = sqlite3_config(SQLITE_CONFIG_LOG, FileSystem::LogSqliteError, NULL);
1061  assert(retval == SQLITE_OK);
1062  retval = sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
1063  assert(retval == SQLITE_OK);
1065 
1066  // Disable SQlite3 file locking
1067  retval = sqlite3_vfs_register(sqlite3_vfs_find("unix-none"), 1);
1068  assert(retval == SQLITE_OK);
1069 }
1070 
1071 
1073  string optarg;
1074  // This is very similar to "determine cache dir". It's for backward
1075  // compatibility with classic cache configuration where there was no
1076  // distinction between workspace and cache.
1077  // Complicated cache configurations should explicitly set CVMFS_WORKSPACE.
1079  if (options_mgr_->GetValue("CVMFS_CACHE_BASE", &optarg))
1080  workspace_ = MakeCanonicalPath(optarg);
1081  if (options_mgr_->GetValue("CVMFS_SHARED_CACHE", &optarg) &&
1082  options_mgr_->IsOn(optarg))
1083  {
1084  workspace_ += "/shared";
1085  } else {
1086  workspace_ += "/" + name_;
1087  }
1088  if (options_mgr_->GetValue("CVMFS_CACHE_DIR", &optarg)) {
1089  if (options_mgr_->IsDefined("CVMFS_CACHE_BASE")) {
1090  boot_error_ =
1091  "'CVMFS_CACHE_BASE' and 'CVMFS_CACHE_DIR' are mutually exclusive";
1093  return false;
1094  }
1095  workspace_ = optarg;
1096  }
1097  if (options_mgr_->GetValue("CVMFS_WORKSPACE", &optarg))
1098  workspace_ = optarg;
1100 
1101  // If workspace and alien cache are the same directory, we need to open
1102  // permission now to 0770 to avoid a race when fixing it later
1103  const int mode = 0770;
1104  if (!MkdirDeep(workspace_, mode, false)) {
1105  boot_error_ = "cannot create workspace directory " + workspace_;
1107  return false;
1108  }
1109 
1110  if (!LockWorkspace())
1111  return false;
1112  if (!SetupCwd())
1113  return false;
1114  if (!SetupCrashGuard())
1115  return false;
1116 
1117  return true;
1118 }
1119 
1120 
1123  if (uuid_cache_ == NULL) {
1125  "failed to load/store %s/uuid", workspace_.c_str());
1127  assert(uuid_cache_ != NULL);
1128  }
1129 }
1130 
1131 
1137  if ((cache_mgr_ != NULL) &&
1138  (cache_mgr_->id() == kPosixCacheManager)) {
1139  PosixCacheManager *posix_cache_mgr =
1140  reinterpret_cast<PosixCacheManager *>(cache_mgr_);
1141  posix_cache_mgr->TearDown2ReadOnly();
1142  }
1143 
1144  unlink(path_crash_guard_.c_str());
1145  LogCvmfs(kLogCache, kLogSyslog, "switch to read-only cache mode");
1146  SetLogMicroSyslog("");
1147 }
1148 
1149 
1150 void FileSystem::RemapCatalogFd(int from, int to) {
1151  sqlite::RegisterFdMapping(from, to);
1152 }
1153 
1155  cache_mgr_ = new_cache_mgr;
1156  sqlite::ReplaceCacheManager(new_cache_mgr);
1157 }
1158 
1159 
1162  string instance;
1163  if (options_mgr_->GetValue("CVMFS_CACHE_PRIMARY", &instance) &&
1164  !instance.empty())
1165  {
1166  if (!CheckInstanceName(instance))
1167  return false;
1168  cache_mgr_instance_ = instance;
1169  }
1170 
1172  if (cache_mgr_ == NULL)
1173  return false;
1174 
1175  std::string optarg;
1176  if (options_mgr_->GetValue("CVMFS_STREAMING_CACHE", &optarg) &&
1177  options_mgr_->IsOn(optarg))
1178  {
1179  unsigned nfiles = kDefaultNfiles;
1180  if (options_mgr_->GetValue("CVMFS_NFILES", &optarg))
1181  nfiles = String2Uint64(optarg);
1182  size_t buffer_size = StreamingCacheManager::kDefaultBufferSize;
1183  if (options_mgr_->GetValue("CVMFS_STREAMING_CACHE_BUFFER_SIZE", &optarg))
1184  buffer_size = String2Uint64(optarg);
1185  cache_mgr_ = new StreamingCacheManager(nfiles, cache_mgr_, NULL, NULL,
1186  buffer_size, statistics_);
1187  }
1188 
1189  return true;
1190 }
1191 
1192 
1193 //------------------------------------------------------------------------------
1194 
1195 
1196 const char *MountPoint::kDefaultAuthzSearchPath = "/usr/libexec/cvmfs/authz";
1197 const char *MountPoint::kDefaultBlacklist = "/etc/cvmfs/blacklist";
1198 
1200  blacklist_paths_.clear();
1201  string blacklist;
1202  if (!options_mgr_->GetValue("CVMFS_BLACKLIST", &blacklist))
1203  blacklist = kDefaultBlacklist;
1204  blacklist_paths_.push_back(blacklist);
1205 
1206  bool append = false;
1207  if (FileExists(blacklist)) {
1208  if (!signature_mgr_->LoadBlacklist(blacklist, append)) {
1209  boot_error_ = "failed to load blacklist " + blacklist;
1211  return false;
1212  }
1213  append = true;
1214  }
1215 
1216  string config_repository_path;
1217  if (options_mgr_->HasConfigRepository(fqrn_, &config_repository_path)) {
1218  blacklist = config_repository_path + "blacklist";
1219  blacklist_paths_.push_back(blacklist);
1220  if (FileExists(blacklist)) {
1221  if (!signature_mgr_->LoadBlacklist(blacklist, append)) {
1222  boot_error_ = "failed to load blacklist from config repository";
1224  return false;
1225  }
1226  }
1227  }
1228 
1229  return true;
1230 }
1231 
1232 
1238  bool result = true;
1239  bool append = false;
1240  for (unsigned i = 0; i < blacklist_paths_.size(); ++i) {
1241  string blacklist = blacklist_paths_[i];
1242  if (FileExists(blacklist)) {
1243  bool retval = signature_mgr_->LoadBlacklist(blacklist, append);
1244  // TODO(jblomer): this can leave us with a half-loaded blacklist
1245  if (!retval)
1246  return false;
1247  append = true;
1248  }
1249  }
1250  return result;
1251 }
1252 
1262  cache_symlinks_ = false;
1263 }
1264 
1270  fuse_expire_entry_ = true;
1271 }
1272 
1273 
1279  const string &fqrn,
1280  FileSystem *file_system,
1281  OptionsManager *options_mgr)
1282 {
1283  if (options_mgr == NULL)
1284  options_mgr = file_system->options_mgr();
1285  UniquePtr<MountPoint> mountpoint(new MountPoint(
1286  fqrn, file_system, options_mgr));
1287 
1288  // At this point, we have a repository name, the type (fuse or library) and
1289  // an options manager (which can be the same than the FileSystem's one).
1290 
1291  mountpoint->CreateStatistics();
1292  mountpoint->CreateAuthz();
1293  mountpoint->backoff_throttle_ = new BackoffThrottle();
1294 
1295  if (!mountpoint->CreateSignatureManager() || !mountpoint->CheckBlacklists())
1296  return mountpoint.Release();
1297  if (!mountpoint->CreateDownloadManagers())
1298  return mountpoint.Release();
1299  if (file_system->cache_mgr()->id() == kStreamingCacheManager) {
1300  StreamingCacheManager *streaming_cachemgr =
1301  dynamic_cast<StreamingCacheManager *>(file_system->cache_mgr());
1302  streaming_cachemgr->SetRegularDownloadManager(mountpoint->download_mgr());
1303  streaming_cachemgr->SetExternalDownloadManager(
1304  mountpoint->external_download_mgr());
1305  }
1306  if (!mountpoint->CreateResolvConfWatcher()) {
1307  return mountpoint.Release();
1308  }
1309  mountpoint->CreateFetchers();
1310  if (!mountpoint->CreateCatalogManager())
1311  return mountpoint.Release();
1312  if (!mountpoint->CreateTracer())
1313  return mountpoint.Release();
1314 
1315  mountpoint->ReEvaluateAuthz();
1316  mountpoint->CreateTables();
1317  if (!mountpoint->SetupBehavior())
1318  return mountpoint.Release();
1319 
1320  mountpoint->boot_status_ = loader::kFailOk;
1321  return mountpoint.Release();
1322 }
1323 
1324 
1326  string optarg;
1327  string authz_helper;
1328  if (options_mgr_->GetValue("CVMFS_AUTHZ_HELPER", &optarg))
1329  authz_helper = optarg;
1330  string authz_search_path(kDefaultAuthzSearchPath);
1331  if (options_mgr_->GetValue("CVMFS_AUTHZ_SEARCH_PATH", &optarg))
1332  authz_search_path = optarg;
1333 
1335  fqrn_,
1336  authz_helper,
1337  authz_search_path,
1338  options_mgr_);
1339  assert(authz_fetcher_ != NULL);
1340 
1343  statistics_);
1344  assert(authz_session_mgr_ != NULL);
1345 
1347  assert(authz_attachment_ != NULL);
1348 }
1349 
1350 
1352  string optarg;
1353 
1355 
1357  if (!SetupOwnerMaps())
1358  return false;
1359  shash::Any root_hash;
1360  if (!DetermineRootHash(&root_hash))
1361  return false;
1362 
1363  bool retval;
1364  if (root_hash.IsNull()) {
1365  retval = catalog_mgr_->Init();
1366  } else {
1367  fixed_catalog_ = true;
1368  bool alt_root_path =
1369  options_mgr_->GetValue("CVMFS_ALT_ROOT_PATH", &optarg) &&
1370  options_mgr_->IsOn(optarg);
1371  retval = catalog_mgr_->InitFixed(root_hash, alt_root_path);
1372  }
1373  if (!retval) {
1374  boot_error_ = "Failed to initialize root file catalog";
1376  return false;
1377  }
1378 
1380  boot_error_ = "repository revision blacklisted";
1382  return false;
1383  }
1384 
1385  if (options_mgr_->GetValue("CVMFS_AUTO_UPDATE", &optarg) &&
1386  !options_mgr_->IsOn(optarg))
1387  {
1388  fixed_catalog_ = true;
1389  }
1390 
1391  if (options_mgr_->GetValue("CVMFS_CATALOG_WATERMARK", &optarg)) {
1393  } else {
1394  unsigned soft_limit;
1395  unsigned hard_limit;
1396  GetLimitNoFile(&soft_limit, &hard_limit);
1397  catalog_mgr_->SetCatalogWatermark(soft_limit / 4);
1398  }
1399 
1400  if (catalog_mgr_->volatile_flag()) {
1401  LogCvmfs(kLogCvmfs, kLogDebug, "content of repository flagged as VOLATILE");
1402  }
1403 
1404  return true;
1405 }
1406 
1407 
1409  string optarg;
1411  perf::StatisticsTemplate("download", statistics_));
1413 
1414  // must be set before proxy and host chains are being initialized
1415  // error output is handled in SetShardingPolicy
1416  if (options_mgr_->GetValue("CVMFS_PROXY_SHARDING_POLICY", &optarg)) {
1417  if (optarg.compare("EXTERNAL") == 0) {
1420  }
1421  }
1422 
1423  if (options_mgr_->GetValue("CVMFS_FAILOVER_INDEFINITELY", &optarg) &&
1424  options_mgr_->IsOn(optarg)) {
1426  }
1427 
1428  if (options_mgr_->GetValue("CVMFS_METALINK_URL", &optarg)) {
1429  download_mgr_->SetMetalinkChain(optarg);
1430  // host chain will be set later when the metalink server is contacted
1432  // metalink requires redirects
1434  } else if (options_mgr_->GetValue("CVMFS_SERVER_URL", &optarg)) {
1435  download_mgr_->SetHostChain(optarg);
1436  }
1437 
1438  if (options_mgr_->GetValue("_CVMFS_DEVEL_IGNORE_SIGNATURE_FAILURES", &optarg)
1439  && options_mgr_->IsOn(optarg)) {
1442  "Development option: Activate ignore signature failures during download. "
1443  "DO NOT USE IN PRODUCTION");
1444  }
1445 
1447  SetupHttpTuning();
1448 
1449  string forced_proxy_template;
1450  if (options_mgr_->GetValue("CVMFS_PROXY_TEMPLATE", &optarg))
1451  forced_proxy_template = optarg;
1453  forced_proxy_template);
1454 
1455  string proxies;
1456  if (options_mgr_->GetValue("CVMFS_HTTP_PROXY", &optarg))
1457  proxies = optarg;
1459  proxies,
1460  file_system_->workspace() + "/proxies" + GetUniqFileSuffix(),
1461  download_mgr_);
1462  if (proxies == "") {
1463  boot_error_ = "failed to discover HTTP proxy servers";
1465  return false;
1466  }
1467  string fallback_proxies;
1468  if (options_mgr_->GetValue("CVMFS_FALLBACK_PROXY", &optarg))
1469  fallback_proxies = optarg;
1470  download_mgr_->SetProxyChain(proxies, fallback_proxies,
1472 
1473  bool do_geosort = options_mgr_->GetValue("CVMFS_USE_GEOAPI", &optarg) &&
1474  options_mgr_->IsOn(optarg);
1475  if (do_geosort) {
1477  }
1478  if (options_mgr_->GetValue("CVMFS_MAX_SERVERS", &optarg)) {
1479  unsigned max_servers = String2Uint64(optarg);
1480  std::vector<std::string> host_chain;
1481  download_mgr_->GetHostInfo(&host_chain, NULL, NULL);
1482  if (max_servers > 0 && max_servers < host_chain.size()) {
1483  host_chain.resize(max_servers);
1484  download_mgr_->SetHostChain(host_chain);
1485  }
1486  }
1487 
1488  if (options_mgr_->GetValue("CVMFS_USE_SSL_SYSTEM_CA", &optarg) &&
1489  options_mgr_->IsOn(optarg)) {
1491  }
1492 
1493  if (options_mgr_->GetValue("CVMFS_PROXY_SHARD", &optarg) &&
1494  options_mgr_->IsOn(optarg)) {
1496  }
1497 
1498  // configure http tracing header
1499  if (options_mgr_->GetValue("CVMFS_HTTP_TRACING", &optarg) &&
1500  options_mgr_->IsOn(optarg)) {
1502  if (options_mgr_->GetValue("CVMFS_HTTP_TRACING_HEADERS", &optarg)) {
1503  if (optarg.size() > 1000) {
1505  "CVMFS_HTTP_TRACING_HEADERS too large ( max 1000 chars, given %ld )",
1506  optarg.size());
1507  } else {
1508  std::vector<std::string> tokens = SplitString(optarg, '|');
1509  sanitizer::AlphaNumSanitizer sanitizer;
1510 
1511  for (unsigned int i = 0; i < tokens.size(); i++) {
1512  std::string token = Trim(tokens[i]);
1513 
1514  std::vector<std::string> key_val = SplitString(token, ':');
1515 
1516  if (key_val.size() != 2) {
1518  "Http tracing header: Skipping current token part of "
1519  "CVMFS_HTTP_TRACING_HEADERS! Invalid "
1520  "<key:value> pair. Token: %s", token.c_str());
1521  continue;
1522  }
1523 
1524  std::string prefix = "X-CVMFS-";
1525  std::string key = Trim(key_val[0]);
1526 
1527  if (!sanitizer.IsValid(key)) {
1529  "Http tracing header: Skipping current token part of "
1530  "CVMFS_HTTP_TRACING_HEADERS! Invalid key. Only alphanumeric keys "
1531  "are allowed (a-z, A-Z, 0-9). Token: %s", token.c_str());
1532  continue;
1533  }
1534 
1535  std::string final_token = prefix + key + ": " + Trim(key_val[1]);
1536 
1537  download_mgr_->AddHTTPTracingHeader(final_token);
1538  }
1539  }
1540  }
1541  }
1542 
1543  return SetupExternalDownloadMgr(do_geosort);
1544 }
1545 
1547  std::string roaming_value;
1548  options_mgr_->GetValue("CVMFS_DNS_ROAMING", &roaming_value);
1549  if (options_mgr_->IsDefined("CVMFS_DNS_ROAMING") &&
1550  options_mgr_->IsOn(roaming_value)) {
1552  "DNS roaming is enabled for this repository.");
1553  // Create a file watcher to update the DNS settings of the download
1554  // managers when there are changes to /etc/resolv.conf
1556 
1557  if (resolv_conf_watcher_) {
1558  ResolvConfEventHandler *handler =
1560  resolv_conf_watcher_->RegisterHandler("/etc/resolv.conf", handler);
1561  }
1562  } else {
1564  "DNS roaming is disabled for this repository.");
1565  }
1566  return true;
1567 }
1568 
1570  fetcher_ = new cvmfs::Fetcher(
1572  download_mgr_,
1575 
1580  perf::StatisticsTemplate("fetch-external", statistics_));
1581 }
1582 
1583 
1585  string optarg;
1587  signature_mgr_->Init();
1588 
1589  string public_keys;
1590  if (options_mgr_->GetValue("CVMFS_PUBLIC_KEY", &optarg)) {
1591  public_keys = optarg;
1592  } else if (options_mgr_->GetValue("CVMFS_KEYS_DIR", &optarg)) {
1593  // Collect .pub files from CVMFS_KEYS_DIR
1594  public_keys = JoinStrings(FindFilesBySuffix(optarg, ".pub"), ":");
1595  } else {
1596  public_keys =
1597  JoinStrings(FindFilesBySuffix("/etc/cvmfs/keys", ".pub"), ":");
1598  }
1599 
1600  if (!signature_mgr_->LoadPublicRsaKeys(public_keys)) {
1601  boot_error_ = "failed to load public key(s)";
1603  return false;
1604  }
1605 
1606  if (public_keys.size() > 0) {
1607  LogCvmfs(kLogCvmfs, kLogDebug, "CernVM-FS: using public key(s) %s",
1608  public_keys.c_str());
1609  } else {
1610  LogCvmfs(kLogCvmfs, kLogDebug | kLogSyslogWarn, "no public key loaded");
1611  }
1612 
1613  return true;
1614 }
1615 
1616 
1620  return;
1621 
1622  // TODO(jblomer): this should be registered by the tracker
1623  statistics_->Register("inode_tracker.n_insert",
1624  "overall number of accessed inodes");
1625  statistics_->Register("inode_tracker.n_remove",
1626  "overall number of evicted inodes");
1627  statistics_->Register("inode_tracker.no_reference",
1628  "currently active inodes");
1629  statistics_->Register("inode_tracker.n_hit_inode",
1630  "overall number of inode lookups");
1631  statistics_->Register("inode_tracker.n_hit_path",
1632  "overall number of successful path lookups");
1633  statistics_->Register("inode_tracker.n_miss_path",
1634  "overall number of unsuccessful path lookups");
1635 
1636  statistics_->Register("dentry_tracker.n_insert",
1637  "overall number of added negative cache entries");
1638  statistics_->Register("dentry_tracker.n_remove",
1639  "overall number of evicted negative cache entries");
1640  statistics_->Register("dentry_tracker.n_prune",
1641  "overall number of prune calls");
1642 
1643  statistics_->Register("page_cache_tracker.n_insert",
1644  "overall number of added page cache entries");
1645  statistics_->Register("page_cache_tracker.n_remove",
1646  "overall number of evicted page cache entries");
1647  statistics_->Register("page_cache_tracker.n_open_direct",
1648  "overall number of direct I/O open calls");
1649  statistics_->Register("page_cache_tracker.n_open_flush",
1650  "overall number of open calls where the file's page cache gets flushed");
1651  statistics_->Register("page_cache_tracker.n_open_cached",
1652  "overall number of open calls where the file's page cache is reused");
1653 }
1654 
1655 
1658  // Libcvmfs simplified tables
1661  return;
1662  }
1663 
1664  chunk_tables_ = new ChunkTables();
1665 
1666  string optarg;
1667  uint64_t mem_cache_size = kDefaultMemcacheSize;
1668  if (options_mgr_->GetValue("CVMFS_MEMCACHE_SIZE", &optarg))
1669  mem_cache_size = String2Uint64(optarg) * 1024 * 1024;
1670 
1671  const double memcache_unit_size =
1672  (static_cast<double>(kInodeCacheFactor) * lru::Md5PathCache::GetEntrySize())
1674  const unsigned memcache_num_units =
1675  mem_cache_size / static_cast<unsigned>(memcache_unit_size);
1676  // Number of cache entries must be a multiple of 64
1677  const unsigned mask_64 = ~((1 << 6) - 1);
1678  inode_cache_ = new lru::InodeCache(memcache_num_units & mask_64, statistics_);
1679  path_cache_ = new lru::PathCache(memcache_num_units & mask_64, statistics_);
1680  md5path_cache_ = new lru::Md5PathCache((memcache_num_units * 7) & mask_64,
1681  statistics_);
1682 
1686  if (file_system_->IsNfsSource())
1688 }
1689 
1699  string optarg;
1700  tracer_ = new Tracer();
1701  if (options_mgr_->GetValue("CVMFS_TRACEFILE", &optarg)) {
1703  boot_error_ = "tracer is only supported in the fuse module";
1705  return false;
1706  }
1707  string tracebuffer_file = optarg;
1708  uint64_t tracebuffer_size = kTracerBufferSize;
1709  uint64_t tracebuffer_threshold = kTracerFlushThreshold;
1710 
1711  if (options_mgr_->GetValue("CVMFS_TRACEBUFFER", &optarg)) {
1712  tracebuffer_size = String2Uint64(optarg);
1713  }
1714  if (options_mgr_->GetValue("CVMFS_TRACEBUFFER_THRESHOLD",
1715  &optarg)) {
1716  tracebuffer_threshold = String2Uint64(optarg);
1717  }
1718  assert(tracebuffer_size <= INT_MAX
1719  && tracebuffer_threshold <= INT_MAX);
1721  "Initialising tracer with buffer size %" PRIu64 " and threshold %" PRIu64,
1722  tracebuffer_size, tracebuffer_threshold);
1723  tracer_->Activate(tracebuffer_size, tracebuffer_threshold,
1724  tracebuffer_file);
1725  }
1726  return true;
1727 }
1728 
1729 
1731  string optarg;
1732  if (options_mgr_->GetValue("CVMFS_ROOT_HASH", &optarg)) {
1733  *root_hash = MkFromHexPtr(shash::HexPtr(optarg), shash::kSuffixCatalog);
1734  return true;
1735  }
1736 
1737  if (!options_mgr_->IsDefined("CVMFS_REPOSITORY_TAG") &&
1738  !options_mgr_->IsDefined("CVMFS_REPOSITORY_DATE"))
1739  {
1740  root_hash->SetNull();
1741  return true;
1742  }
1743 
1744  string history_path;
1745  if (!FetchHistory(&history_path))
1746  return false;
1747  UnlinkGuard history_file(history_path);
1749  history::SqliteHistory::Open(history_path));
1750  if (!tag_db.IsValid()) {
1752  "failed to open history database (%s)", history_path.c_str());
1753  boot_error_ = "failed to open history database";
1755  return false;
1756  }
1757 
1759  bool retval;
1760  if (!options_mgr_->GetValue("CVMFS_REPOSITORY_TAG", &repository_tag_)) {
1761  string repository_date;
1762  // options_mgr_->IsDefined("CVMFS_REPOSITORY_DATE") must be true
1763  options_mgr_->GetValue("CVMFS_REPOSITORY_DATE", &repository_date);
1764  time_t repository_utctime = IsoTimestamp2UtcTime(repository_date);
1765  if (repository_utctime == 0) {
1766  boot_error_ = "invalid timestamp in CVMFS_REPOSITORY_DATE: " +
1767  repository_date + ". Use YYYY-MM-DDTHH:MM:SSZ";
1769  return false;
1770  }
1771  retval = tag_db->GetByDate(repository_utctime, &tag);
1772  if (!retval) {
1773  boot_error_ = "no repository state as early as utc timestamp " +
1774  StringifyTime(repository_utctime, true);
1776  return false;
1777  }
1779  "time stamp %s UTC resolved to tag '%s'",
1780  StringifyTime(repository_utctime, true).c_str(),
1781  tag.name.c_str());
1782  repository_tag_ = tag.name;
1783  } else {
1784  retval = tag_db->GetByName(repository_tag_, &tag);
1785  if (!retval) {
1786  boot_error_ = "no such tag: " + repository_tag_;
1788  return false;
1789  }
1790  }
1791  LogCvmfs(kLogCvmfs, kLogDebug, "mounting tag %s", tag.name.c_str());
1792 
1793  *root_hash = tag.root_hash;
1794  return true;
1795 }
1796 
1797 
1798 bool MountPoint::FetchHistory(std::string *history_path) {
1799  manifest::Failures retval_mf;
1800  manifest::ManifestEnsemble ensemble;
1801  retval_mf = manifest::Fetch("", fqrn_, 0, NULL, signature_mgr_, download_mgr_,
1802  &ensemble);
1803  if (retval_mf != manifest::kFailOk) {
1804  boot_error_ = "Failed to fetch manifest";
1806  return false;
1807  }
1808  shash::Any history_hash = ensemble.manifest->history();
1809  if (history_hash.IsNull()) {
1810  boot_error_ = "No history";
1812  return false;
1813  }
1814 
1815  CacheManager::Label label;
1817  label.path = fqrn_;
1818  int fd = fetcher_->Fetch(CacheManager::LabeledObject(history_hash, label));
1819  if (fd < 0) {
1820  boot_error_ = "failed to download history: " + StringifyInt(-fd);
1822  return false;
1823  }
1824  // We have the custom sqlite vfs driver installed
1825  *history_path = "@" + StringifyInt(fd);
1826  return true;
1827 }
1828 
1829 
1831  unsigned max_ttl;
1832  {
1833  MutexLockGuard lock_guard(lock_max_ttl_);
1834  max_ttl = max_ttl_sec_;
1835  }
1836  const unsigned catalog_ttl_sec = catalog_mgr_->GetTTL();
1837 
1838  return max_ttl ? std::min(max_ttl, catalog_ttl_sec) : catalog_ttl_sec;
1839 }
1840 
1841 
1843  MutexLockGuard lock_guard(lock_max_ttl_);
1844  return max_ttl_sec_ / 60;
1845 }
1846 
1847 
1853  return "." + file_system_->name() + "-" + fqrn_;
1854 }
1855 
1856 
1858  const string &fqrn,
1859  FileSystem *file_system,
1860  OptionsManager *options_mgr)
1861  : fqrn_(fqrn)
1862  , uuid_(cvmfs::Uuid::Create(""))
1863  , file_system_(file_system)
1864  , options_mgr_(options_mgr)
1865  , statistics_(NULL)
1866  , telemetry_aggr_(NULL)
1867  , authz_fetcher_(NULL)
1868  , authz_session_mgr_(NULL)
1869  , authz_attachment_(NULL)
1870  , backoff_throttle_(NULL)
1871  , signature_mgr_(NULL)
1872  , download_mgr_(NULL)
1873  , external_download_mgr_(NULL)
1874  , fetcher_(NULL)
1875  , external_fetcher_(NULL)
1876  , inode_annotation_(NULL)
1877  , catalog_mgr_(NULL)
1878  , chunk_tables_(NULL)
1879  , simple_chunk_tables_(NULL)
1880  , inode_cache_(NULL)
1881  , path_cache_(NULL)
1882  , md5path_cache_(NULL)
1883  , tracer_(NULL)
1884  , inode_tracker_(NULL)
1885  , dentry_tracker_(NULL)
1886  , page_cache_tracker_(NULL)
1887  , statfs_cache_(NULL)
1888  , resolv_conf_watcher_(NULL)
1889  , max_ttl_sec_(kDefaultMaxTtlSec)
1890  , kcache_timeout_sec_(static_cast<double>(kDefaultKCacheTtlSec))
1891  , fixed_catalog_(false)
1892  , enforce_acls_(false)
1893  , cache_symlinks_(false)
1894  , fuse_expire_entry_(false)
1895  , has_membership_req_(false)
1896  , talk_socket_path_(std::string("./cvmfs_io.") + fqrn)
1897  , talk_socket_uid_(0)
1898  , talk_socket_gid_(0)
1899 {
1900  int retval = pthread_mutex_init(&lock_max_ttl_, NULL);
1901  assert(retval == 0);
1902 }
1903 
1904 
1906  pthread_mutex_destroy(&lock_max_ttl_);
1907 
1908  delete page_cache_tracker_;
1909  delete dentry_tracker_;
1910  delete inode_tracker_;
1911  delete tracer_;
1912  delete md5path_cache_;
1913  delete path_cache_;
1914  delete inode_cache_;
1915  delete simple_chunk_tables_;
1916  delete chunk_tables_;
1917 
1918  delete catalog_mgr_;
1919  delete inode_annotation_;
1920  delete external_fetcher_;
1921  delete fetcher_;
1922 
1923  delete external_download_mgr_;
1924  delete download_mgr_;
1925 
1926  if (signature_mgr_ != NULL) {
1927  signature_mgr_->Fini();
1928  delete signature_mgr_;
1929  }
1930 
1931  if (resolv_conf_watcher_ != NULL) {
1933  delete resolv_conf_watcher_;
1934  }
1935 
1936  delete backoff_throttle_;
1937  delete authz_attachment_;
1938  delete authz_session_mgr_;
1939  delete authz_fetcher_;
1940  delete telemetry_aggr_;
1941  delete statistics_;
1942  delete uuid_;
1943 
1944  delete statfs_cache_;
1945 }
1946 
1947 
1949  string old_membership_req = membership_req_;
1951  if (old_membership_req != membership_req_) {
1954  }
1955 }
1956 
1957 
1958 void MountPoint::SetMaxTtlMn(unsigned value_minutes) {
1959  MutexLockGuard lock_guard(lock_max_ttl_);
1960  max_ttl_sec_ = value_minutes * 60;
1961 }
1962 
1964  string optarg;
1965 
1966  if (options_mgr_->GetValue("CVMFS_MAX_TTL", &optarg))
1967  SetMaxTtlMn(String2Uint64(optarg));
1968 
1969  if (options_mgr_->GetValue("CVMFS_KCACHE_TIMEOUT", &optarg)) {
1970  // Can be negative and should then be interpreted as 0.0
1972  std::max(0.0, static_cast<double>(String2Int64(optarg)));
1973  }
1974  LogCvmfs(kLogCvmfs, kLogDebug, "kernel caches expire after %d seconds",
1975  static_cast<int>(kcache_timeout_sec_));
1976 
1977  uint64_t statfs_time_cache_valid = 0;
1978  if (options_mgr_->GetValue("CVMFS_STATFS_CACHE_TIMEOUT", &optarg)) {
1979  statfs_time_cache_valid = static_cast<uint64_t>(String2Uint64(optarg));
1980  }
1981  LogCvmfs(kLogCvmfs, kLogDebug, "statfs cache expires after %d seconds",
1982  static_cast<int>(statfs_time_cache_valid));
1983  statfs_cache_ = new StatfsCache(statfs_time_cache_valid);
1984 
1985  MagicXattrManager::EVisibility xattr_visibility =
1987  if (options_mgr_->GetValue("CVMFS_HIDE_MAGIC_XATTRS", &optarg)) {
1988  if (options_mgr_->IsOn(optarg))
1989  xattr_visibility = MagicXattrManager::kVisibilityNever;
1990  else if (options_mgr_->IsOff(optarg))
1991  xattr_visibility = MagicXattrManager::kVisibilityAlways;
1992  }
1993  if (options_mgr_->GetValue("CVMFS_MAGIC_XATTRS_VISIBILITY", &optarg)) {
1994  if (ToUpper(optarg) == "ROOTONLY") {
1995  xattr_visibility = MagicXattrManager::kVisibilityRootOnly;
1996  } else if (ToUpper(optarg) == "NEVER") {
1997  xattr_visibility = MagicXattrManager::kVisibilityNever;
1998  } else if (ToUpper(optarg) == "ALWAYS") {
1999  xattr_visibility = MagicXattrManager::kVisibilityAlways;
2000  } else {
2002  "unsupported setting: CVMFS_MAGIC_XATTRS_VISIBILITY=%s",
2003  optarg.c_str());
2004  }
2005  }
2006 
2007  std::set<gid_t> protected_xattr_gids;
2008  if (options_mgr_->GetValue("CVMFS_XATTR_PRIVILEGED_GIDS", &optarg)) {
2009  std::vector<string> tmp = SplitString(optarg, ',');
2010 
2011  for (size_t i = 0; i < tmp.size(); i++) {
2012  std::string trimmed = Trim(tmp[i]);
2014  "Privileged gid for xattr added: %s", trimmed.c_str());
2015  protected_xattr_gids.insert(static_cast<gid_t>(String2Uint64(trimmed)));
2016  }
2017  }
2018  std::set<std::string> protected_xattrs;
2019  if (options_mgr_->GetValue("CVMFS_XATTR_PROTECTED_XATTRS", &optarg)) {
2020  std::vector<string> tmp = SplitString(optarg, ',');
2021 
2022  for (size_t i = 0; i < tmp.size(); i++) {
2023  std::string trimmed = Trim(tmp[i]);
2025  "Protected xattr added: %s", trimmed.c_str());
2026  protected_xattrs.insert(trimmed);
2027  }
2028 
2029  // root has always access to xattr
2030  if (protected_xattr_gids.count(0) < 1) {
2031  protected_xattr_gids.insert(0);
2033  "Automatically added root to have access to protected xattrs.");
2034  }
2035  }
2036  magic_xattr_mgr_ = new MagicXattrManager(this, xattr_visibility,
2037  protected_xattrs, protected_xattr_gids);
2038 
2039 
2040  if (options_mgr_->GetValue("CVMFS_ENFORCE_ACLS", &optarg)
2041  && options_mgr_->IsOn(optarg))
2042  {
2043  enforce_acls_ = true;
2044  }
2045 
2046  if (options_mgr_->GetValue("CVMFS_CACHE_SYMLINKS", &optarg)
2047  && options_mgr_->IsOn(optarg))
2048  {
2049  cache_symlinks_ = true;
2050  }
2051 
2052 
2053 
2054  if (options_mgr_->GetValue("CVMFS_TALK_SOCKET", &optarg)) {
2055  talk_socket_path_ = optarg;
2056  }
2057  if (options_mgr_->GetValue("CVMFS_TALK_OWNER", &optarg)) {
2058  bool retval = GetUidOf(optarg, &talk_socket_uid_, &talk_socket_gid_);
2059  if (!retval) {
2060  boot_error_ = "unknown owner of cvmfs_talk socket: " + optarg;
2062  return false;
2063  }
2064  }
2065 
2066  // this can be later be changed to switch through different
2067  // telemetryAggregators
2068  if (options_mgr_->GetValue("CVMFS_TELEMETRY_SEND", &optarg)
2069  && options_mgr_->IsOn(optarg)) {
2070  int telemetry_send_rate_sec = kDefaultTelemetrySendRateSec;
2071  if (options_mgr_->GetValue("CVMFS_TELEMETRY_RATE", &optarg)) {
2072  telemetry_send_rate_sec = static_cast<int>(String2Uint64(optarg));
2073 
2074  // minimum send rate: 5sec
2075  if (telemetry_send_rate_sec < kMinimumTelemetrySendRateSec) {
2076  telemetry_send_rate_sec = kMinimumTelemetrySendRateSec;
2077  }
2078 
2080  telemetry_send_rate_sec,
2081  options_mgr_,
2082  this,
2083  fqrn_,
2086  "Enable telemetry to report every %d seconds",
2087  telemetry_send_rate_sec);
2088  }
2089  }
2090 
2091  return true;
2092 }
2093 
2094 
2100  string optarg;
2101  unsigned dns_timeout_ms = download::DownloadManager::kDnsDefaultTimeoutMs;
2102  unsigned dns_retries = download::DownloadManager::kDnsDefaultRetries;
2103  if (options_mgr_->GetValue("CVMFS_DNS_TIMEOUT", &optarg))
2104  dns_timeout_ms = String2Uint64(optarg) * 1000;
2105  if (options_mgr_->GetValue("CVMFS_DNS_RETRIES", &optarg))
2106  dns_retries = String2Uint64(optarg);
2107  manager->SetDnsParameters(dns_retries, dns_timeout_ms);
2108 
2109  // Rest has to be after SetDnsParameters because SetDnsParameters might
2110  // construct a new resolver object
2111 
2112  unsigned dns_min_ttl = dns::Resolver::kDefaultMinTtl;
2113  unsigned dns_max_ttl = dns::Resolver::kDefaultMaxTtl;
2114  if (options_mgr_->GetValue("CVMFS_DNS_MIN_TTL", &optarg))
2115  dns_min_ttl = String2Uint64(optarg);
2116  if (options_mgr_->GetValue("CVMFS_DNS_MAX_TTL", &optarg))
2117  dns_max_ttl = String2Uint64(optarg);
2118  manager->SetDnsTtlLimits(dns_min_ttl, dns_max_ttl);
2119 
2120  if (options_mgr_->GetValue("CVMFS_DNS_SERVER", &optarg)) {
2121  download_mgr_->SetDnsServer(optarg);
2122  }
2123 
2124  if (options_mgr_->GetValue("CVMFS_IPFAMILY_PREFER", &optarg)) {
2125  switch (String2Int64(optarg)) {
2126  case 4:
2128  break;
2129  case 6:
2131  break;
2132  }
2133  }
2134  if (options_mgr_->GetValue("CVMFS_MAX_IPADDR_PER_PROXY", &optarg))
2135  manager->SetMaxIpaddrPerProxy(String2Uint64(optarg));
2136 }
2137 
2138 
2140  string optarg;
2142  download_mgr_->Clone(perf::StatisticsTemplate("download-external",
2143  statistics_), "external");
2144 
2145  unsigned timeout;
2146  unsigned timeout_direct;
2147  download_mgr_->GetTimeout(&timeout, &timeout_direct);
2148  if (options_mgr_->GetValue("CVMFS_EXTERNAL_TIMEOUT", &optarg)) {
2149  timeout = String2Uint64(optarg);
2150  }
2151  if (options_mgr_->GetValue("CVMFS_EXTERNAL_TIMEOUT_DIRECT", &optarg)) {
2152  timeout_direct = String2Uint64(optarg);
2153  }
2154  external_download_mgr_->SetTimeout(timeout, timeout_direct);
2155 
2156  if (options_mgr_->GetValue("CVMFS_EXTERNAL_METALINK", &optarg)) {
2158  // host chain will be set later when the metalink server is contacted
2160  // metalink requires redirects
2162  } else if (options_mgr_->GetValue("CVMFS_EXTERNAL_URL", &optarg)) {
2164  if (dogeosort) {
2165  std::vector<std::string> host_chain;
2166  external_download_mgr_->GetHostInfo(&host_chain, NULL, NULL);
2167  download_mgr_->GeoSortServers(&host_chain);
2168  external_download_mgr_->SetHostChain(host_chain);
2169  }
2170  } else {
2172  }
2173 
2174  if (options_mgr_->GetValue("CVMFS_EXTERNAL_MAX_SERVERS", &optarg)) {
2175  unsigned max_servers = String2Uint64(optarg);
2176  std::vector<std::string> host_chain;
2177  external_download_mgr_->GetHostInfo(&host_chain, NULL, NULL);
2178  if (max_servers > 0 && max_servers < host_chain.size()) {
2179  host_chain.resize(max_servers);
2180  external_download_mgr_->SetHostChain(host_chain);
2181  }
2182  }
2183 
2184  string proxies = "DIRECT";
2185  if (options_mgr_->GetValue("CVMFS_EXTERNAL_HTTP_PROXY", &optarg)) {
2187  optarg,
2188  file_system_->workspace() + "/proxies-external" + GetUniqFileSuffix(),
2190  if (proxies == "") {
2191  boot_error_ = "failed to discover external HTTP proxy servers";
2193  return false;
2194  }
2195  }
2196  string fallback_proxies;
2197  if (options_mgr_->GetValue("CVMFS_EXTERNAL_FALLBACK_PROXY", &optarg))
2198  fallback_proxies = optarg;
2200  proxies, fallback_proxies, download::DownloadManager::kSetProxyBoth);
2201 
2202  return true;
2203 }
2204 
2205 
2207  string optarg;
2208 
2209  // TODO(jblomer): avoid double default settings
2210 
2211  unsigned timeout = kDefaultTimeoutSec;
2212  unsigned timeout_direct = kDefaultTimeoutSec;
2213  if (options_mgr_->GetValue("CVMFS_TIMEOUT", &optarg))
2214  timeout = String2Uint64(optarg);
2215  if (options_mgr_->GetValue("CVMFS_TIMEOUT_DIRECT", &optarg))
2216  timeout_direct = String2Uint64(optarg);
2217  download_mgr_->SetTimeout(timeout, timeout_direct);
2218 
2219  unsigned max_retries = kDefaultRetries;
2220  unsigned backoff_init = kDefaultBackoffInitMs;
2221  unsigned backoff_max = kDefaultBackoffMaxMs;
2222  if (options_mgr_->GetValue("CVMFS_MAX_RETRIES", &optarg))
2223  max_retries = String2Uint64(optarg);
2224  if (options_mgr_->GetValue("CVMFS_BACKOFF_INIT", &optarg))
2225  backoff_init = String2Uint64(optarg) * 1000;
2226  if (options_mgr_->GetValue("CVMFS_BACKOFF_MAX", &optarg))
2227  backoff_max = String2Uint64(optarg) * 1000;
2228  download_mgr_->SetRetryParameters(max_retries, backoff_init, backoff_max);
2229 
2230  if (options_mgr_->GetValue("CVMFS_LOW_SPEED_LIMIT", &optarg))
2232  if (options_mgr_->GetValue("CVMFS_PROXY_RESET_AFTER", &optarg)) {
2234  // Use the proxy reset delay as the default for the metalink reset delay
2236  }
2237  if (options_mgr_->GetValue("CVMFS_METALINK_RESET_AFTER", &optarg))
2239  if (options_mgr_->GetValue("CVMFS_HOST_RESET_AFTER", &optarg))
2241 
2242  if (options_mgr_->GetValue("CVMFS_FOLLOW_REDIRECTS", &optarg) &&
2243  options_mgr_->IsOn(optarg))
2244  {
2246  }
2247  if (options_mgr_->GetValue("CVMFS_SEND_INFO_HEADER", &optarg) &&
2248  options_mgr_->IsOn(optarg))
2249  {
2251  }
2252 }
2253 
2254 
2256  string optarg;
2257 
2258  if (file_system_->IsNfsSource()) {
2260  } else {
2262  }
2263  if (options_mgr_->GetValue("CVMFS_INITIAL_GENERATION", &optarg)) {
2265  }
2266 
2269  }
2270 }
2271 
2272 
2274  string optarg;
2275  catalog::OwnerMap uid_map;
2276  catalog::OwnerMap gid_map;
2277 
2278  if (options_mgr_->GetValue("CVMFS_UID_MAP", &optarg)) {
2279  if (!uid_map.Read(optarg)) {
2280  boot_error_ = "failed to parse uid map " + optarg;
2282  return false;
2283  }
2284  }
2285  if (options_mgr_->GetValue("CVMFS_GID_MAP", &optarg)) {
2286  if (!gid_map.Read(optarg)) {
2287  boot_error_ = "failed to parse gid map " + optarg;
2289  return false;
2290  }
2291  }
2292  catalog_mgr_->SetOwnerMaps(uid_map, gid_map);
2293 
2294  // TODO(jblomer): make local to catalog manager
2295  if (options_mgr_->GetValue("CVMFS_CLAIM_OWNERSHIP", &optarg) &&
2296  options_mgr_->IsOn(optarg))
2297  {
2298  g_claim_ownership = true;
2299  }
2300  if (options_mgr_->GetValue("CVMFS_WORLD_READABLE", &optarg) &&
2301  options_mgr_->IsOn(optarg))
2302  {
2303  g_world_readable = true;
2304  }
2305 
2306 
2307 
2308  return true;
2309 }
perf::Counter * n_eio_07_
Definition: mountpoint.h:354
IoErrorInfo io_error_info_
Definition: mountpoint.h:357
OptionsManager * options_mgr()
Definition: mountpoint.h:248
std::string exe_path()
Definition: mountpoint.h:207
static const unsigned kDnsDefaultTimeoutMs
Definition: download.h:177
bool GetVOMSAuthz(std::string *authz) const
void SetLogSyslogFacility(const int local_facility)
Definition: logging.cc:183
FileSystem * file_system_
Definition: mountpoint.h:629
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:414
void SetLogSyslogLevel(const int level)
Definition: logging.cc:151
bool IsNull() const
Definition: hash.h:383
bool foreground_
Definition: mountpoint.h:331
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:355
perf::Counter * n_emfile_
Definition: mountpoint.h:356
Log2Histogram * hist_fs_forget_multi_
Definition: mountpoint.h:362
perf::Counter * n_fs_statfs_cached_
Definition: mountpoint.h:340
static FileWatcher * Create()
Definition: file_watcher.cc:44
void SetupInodeAnnotation()
Definition: mountpoint.cc:2255
bool SetupCwd()
Definition: mountpoint.cc:838
catalog::InodeAnnotation * inode_annotation_
Definition: mountpoint.h:646
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:384
bool DetermineNfsMode()
Definition: mountpoint.cc:380
static SqliteHistory * Open(const std::string &file_name)
void SetHostChain(const std::string &host_list)
static const unsigned kTracerFlushThreshold
Definition: mountpoint.h:591
virtual uint64_t GetSize()
Definition: quota_posix.cc:777
static Publisher * Create(const SettingsPublisher &settings)
uid_t talk_socket_uid_
Definition: mountpoint.h:677
void SetMetalinkChain(const std::string &metalink_list)
void SetLowSpeedLimit(const unsigned low_speed_limit)
Definition: download.cc:2201
perf::Counter * n_fs_stat_stale_
Definition: mountpoint.h:338
Log2Histogram * hist_fs_opendir_
Definition: mountpoint.h:365
bool LockWorkspace()
Definition: mountpoint.cc:504
bool CreateTracer()
Definition: mountpoint.cc:1698
bool wait_workspace_
Definition: mountpoint.h:330
virtual bool Cleanup(const uint64_t leave_size)
Definition: quota_posix.cc:125
double kcache_timeout_sec_
Definition: mountpoint.h:664
signature::SignatureManager * signature_mgr_
Definition: mountpoint.h:641
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:335
std::string name
Definition: history.h:88
AuthzSessionManager * authz_session_mgr_
Definition: mountpoint.h:638
static const unsigned kDefaultRetries
Definition: mountpoint.h:584
string Trim(const string &raw, bool trim_newline)
Definition: string.cc:446
string JoinStrings(const vector< string > &strings, const string &joint)
Definition: string.cc:343
perf::Statistics * statistics_
Definition: mountpoint.h:358
download::DownloadManager * download_mgr_
Definition: mountpoint.h:642
static const unsigned kDefaultTimeoutSec
Definition: mountpoint.h:583
std::string exe_path_
Definition: mountpoint.h:324
bool CheckInstanceName(const std::string &instance)
Definition: mountpoint.cc:109
perf::Statistics * statistics_
Definition: mountpoint.h:635
Log2Histogram * hist_fs_readlink_
Definition: mountpoint.h:364
static void SetupLoggingStandalone(const OptionsManager &options_mgr, const std::string &prefix)
Definition: mountpoint.cc:873
void SetProxyChain(const std::string &proxy_list, const std::string &fallback_proxy_list, const ProxySetModes set_mode)
Definition: download.cc:2812
std::string fqrn() const
Definition: mountpoint.h:514
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:678
void SetupSqlite()
Definition: mountpoint.cc:1055
perf::Counter * n_eio_total_
Definition: mountpoint.h:347
bool IsOn(const std::string &param_value) const
Definition: options.cc:409
std::string GetUniqFileSuffix()
Definition: mountpoint.cc:1852
StatfsCache * statfs_cache_
Definition: mountpoint.h:658
download::DownloadManager * external_download_mgr_
Definition: mountpoint.h:643
MagicXattrManager * magic_xattr_mgr_
Definition: mountpoint.h:657
bool fuse_expire_entry_
Definition: mountpoint.h:668
static const size_t kDefaultBufferSize
Definition: cache_stream.h:33
CacheManager * SetupCacheMgr(const std::string &instance)
Definition: mountpoint.cc:623
const SettingsPublisher & settings() const
Definition: repository.h:317
perf::Statistics * statistics_
Definition: repository.h:139
void SetupHttpTuning()
Definition: mountpoint.cc:2206
static const char * kDefaultBlacklist
Definition: mountpoint.h:592
virtual bool AcquireQuotaManager(QuotaManager *quota_mgr)
Definition: cache_extern.cc:85
unsigned max_ttl_sec_
Definition: mountpoint.h:662
static const unsigned kDefaultMaxTtl
Definition: dns.h:182
bool CreateDownloadManagers()
Definition: mountpoint.cc:1408
std::string talk_socket_path_
Definition: mountpoint.h:676
perf::Counter * n_fs_stat_
Definition: mountpoint.h:337
perf::Counter * n_eio_05_
Definition: mountpoint.h:352
perf::Counter * no_open_files_
Definition: mountpoint.h:345
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:895
static void SetupGlobalEnvironmentParams()
Definition: mountpoint.cc:868
int fd_workspace_lock_
Definition: mountpoint.h:385
void CreateStatistics()
Definition: mountpoint.cc:1617
bool UnregisterVfsRdOnly()
Definition: sqlitevfs.cc:522
CacheManager * SetupRamCacheMgr(const std::string &instance)
Definition: mountpoint.cc:726
bool cache_symlinks_
Definition: mountpoint.h:667
static void LogSqliteError(void *user_data __attribute__((unused)), int sqlite_extended_error, const char *message)
Definition: mountpoint.cc:535
static void CleanupInstance()
Definition: sqlitemem.cc:170
void EnableFuseExpireEntry()
Definition: mountpoint.cc:1269
static const unsigned kNfsMaps
Definition: mountpoint.h:182
std::string workspace_
Definition: mountpoint.h:378
string StringifyTime(const time_t seconds, const bool utc)
Definition: string.cc:105
PosixCacheSettings DeterminePosixCacheSettings(const std::string &instance)
Definition: mountpoint.cc:296
void SetDnsServer(const std::string &address)
Definition: download.cc:2129
int platform_stat(const char *path, platform_stat64 *buf)
void AssignGlobalArenas()
Definition: sqlitemem.cc:137
DownloadManager * Clone(const perf::StatisticsTemplate &statistics, const std::string &cloned_name)
Definition: download.cc:3225
bool has_membership_req_
Definition: mountpoint.h:674
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:348
void ReEvaluateAuthz()
Definition: mountpoint.cc:1948
bool HasConfigRepository(const std::string &fqrn, std::string *config_path)
Definition: options.cc:256
std::set< std::string > constructed_instances_
Definition: mountpoint.h:413
bool DetermineRootHash(shash::Any *root_hash)
Definition: mountpoint.cc:1730
#define SetLogDebugFile(filename)
void SetTimeout(const unsigned seconds_proxy, const unsigned seconds_direct)
Definition: download.cc:2187
bool CreateCatalogManager()
Definition: mountpoint.cc:1351
struct cvmcache_object_info __attribute__
Definition: atomic.h:24
void RemapCatalogFd(int from, int to)
Definition: mountpoint.cc:1150
static const unsigned kNfsNone
Definition: mountpoint.h:178
std::string path_crash_guard_
Definition: mountpoint.h:391
IntegerMap< uint64_t > OwnerMap
Definition: catalog.h:41
catalog::WritableCatalogManager * catalog_mgr_
Definition: repository.h:385
bool SetupWorkspace()
Definition: mountpoint.cc:1072
static const char * kDefaultAuthzSearchPath
Definition: mountpoint.h:575
Type type()
Definition: mountpoint.h:250
FileSystem(const FileSystemInfo &fs_info)
Definition: mountpoint.cc:402
static const unsigned kLibPathCacheSize
Definition: mountpoint.h:563
void SetFqrn(const std::string &fqrn)
Definition: download.h:248
std::string boot_error_
Definition: mountpoint.h:88
OptionsManager * options_mgr_
Definition: mountpoint.h:633
Log2Histogram * hist_fs_getattr_
Definition: mountpoint.h:363
bool IsValid(const std::string &input) const
Definition: sanitizer.cc:114
Log2Histogram * hist_fs_releasedir_
Definition: mountpoint.h:366
Definition: tracer.h:35
bool FileExists(const std::string &path)
Definition: posix.cc:802
void ReplaceCacheManager(CacheManager *new_cache_mgr)
Definition: mountpoint.cc:1154
void DisableCacheSymlinks()
Definition: mountpoint.cc:1261
void SetDnsTtlLimits(const unsigned min_seconds, const unsigned max_seconds)
Definition: download.cc:2166
std::string cache_path()
Definition: cache_posix.h:107
perf::Counter * n_fs_readlink_
Definition: mountpoint.h:342
uint64_t platform_memsize()
int64_t String2Int64(const string &value)
Definition: string.cc:240
void SetMaxTtlMn(unsigned value_minutes)
Definition: mountpoint.cc:1958
string ToUpper(const string &mixed_case)
Definition: string.cc:494
static const unsigned kDefaultBackoffInitMs
Definition: mountpoint.h:585
perf::Counter * n_fs_forget_
Definition: mountpoint.h:343
MountPoint(const std::string &fqrn, FileSystem *file_system, OptionsManager *options_mgr)
Definition: mountpoint.cc:1857
void GetLimitNoFile(unsigned *soft_limit, unsigned *hard_limit)
Definition: posix.cc:1491
Tracer * tracer_
Definition: mountpoint.h:653
void SetProxyGroupResetDelay(const unsigned seconds)
Definition: download.cc:3126
static CacheManager * Create(CacheManager *upper_cache, CacheManager *lower_cache)
static bool g_alive
Definition: mountpoint.h:258
static const unsigned kDefaultNumConnections
Definition: mountpoint.h:579
void Set(const int64_t val)
Definition: statistics.h:33
void TearDown2ReadOnly()
Definition: mountpoint.cc:1136
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:652
std::string name_
Definition: mountpoint.h:323
vector< string > SplitString(const string &str, char delim)
Definition: string.cc:308
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:454
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:272
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:673
glue::DentryTracker * dentry_tracker_
Definition: mountpoint.h:655
int Fetch(const CacheManager::LabeledObject &object, const std::string &alt_url="")
Definition: fetch.cc:81
perf::Counter * n_fs_read_
Definition: mountpoint.h:341
signature::SignatureManager * signature_mgr_
Definition: repository.h:140
perf::Counter * n_eio_06_
Definition: mountpoint.h:353
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:299
virtual uint64_t GetCapacity()
Definition: quota_posix.cc:657
glue::PageCacheTracker * page_cache_tracker_
Definition: mountpoint.h:656
bool SetShardingPolicy(const ShardingPolicySelector type)
Definition: download.cc:3206
bool found_previous_crash_
Definition: mountpoint.h:397
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:1160
bool CheckPosixCacheSettings(const PosixCacheSettings &settings)
Definition: mountpoint.cc:126
perf::TelemetryAggregator * telemetry_aggr_
Definition: mountpoint.h:636
perf::Counter * n_fs_inode_replace_
Definition: mountpoint.h:344
bool IsNfsSource()
Definition: mountpoint.h:195
ChunkTables * chunk_tables_
Definition: mountpoint.h:648
CacheManager * cache_mgr()
Definition: mountpoint.h:205
uid_t g_uid
Definition: globals.cc:13
void SetupDnsTuning(download::DownloadManager *manager)
Definition: mountpoint.cc:2099
cvmfs::Uuid * uuid_cache_
Definition: mountpoint.h:424
unsigned GetEffectiveTtlSec()
Definition: mountpoint.cc:1830
int TryLockFile(const std::string &path)
Definition: posix.cc:924
bool MkdirDeep(const std::string &path, const mode_t mode, bool verify_writable)
Definition: posix.cc:857
int LockFile(const std::string &path)
Definition: posix.cc:982
void SetIpPreference(const dns::IpPreference preference)
Definition: download.cc:2176
static const unsigned kDefaultBackoffMaxMs
Definition: mountpoint.h:586
lru::InodeCache * inode_cache_
Definition: mountpoint.h:650
CacheManager * SetupPosixCacheMgr(const std::string &instance)
Definition: mountpoint.cc:696
download::DownloadManager * download_mgr()
Definition: mountpoint.h:505
perf::Counter * n_fs_open_
Definition: mountpoint.h:333
static uint64_t RoundUp8(const uint64_t size)
Definition: smalloc.h:37
bool SetupPosixQuotaMgr(const PosixCacheSettings &settings, CacheManager *cache_mgr)
Definition: mountpoint.cc:993
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:232
unsigned nfs_mode_
Definition: mountpoint.h:418
void SetRetryParameters(const unsigned max_retries, const unsigned backoff_init_ms, const unsigned backoff_max_ms)
Definition: download.cc:3154
string StringifyInt(const int64_t value)
Definition: string.cc:78
Type type_
Definition: mountpoint.h:325
static const unsigned kInodeCacheFactor
Definition: mountpoint.h:567
void SetMaxIpaddrPerProxy(unsigned limit)
Definition: download.cc:3165
void EnableIgnoreSignatureFailures()
Definition: download.cc:3190
std::string GetArch()
Definition: posix.cc:1457
void Inc(class Counter *counter)
Definition: statistics.h:50
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
Definition: string.cc:285
perf::Counter * n_eio_04_
Definition: mountpoint.h:351
Log2Histogram * hist_fs_readdir_
Definition: mountpoint.h:367
bool GetValue(const std::string &key, std::string *value) const
Definition: options.cc:376
cvmfs::Uuid * uuid_
Definition: mountpoint.h:625
void SetExternalDownloadManager(download::DownloadManager *download_mgr)
Definition: cache_stream.h:61
OptionsManager * options_mgr_
Definition: cvmfs.cc:153
bool LoadBlacklist(const std::string &path_blacklist, bool append)
Definition: signature.cc:547
BackoffThrottle * backoff_throttle_
Definition: mountpoint.h:640
AuthzAttachment * authz_attachment_
Definition: mountpoint.h:639
void SetProxyTemplates(const std::string &direct, const std::string &forced)
Definition: download.cc:3171
SimpleChunkTables * simple_chunk_tables_
Definition: mountpoint.h:649
bool InitFixed(const shash::Any &root_hash, bool alternative_path)
perf::Counter * n_eio_03_
Definition: mountpoint.h:350
static const unsigned kDefaultNfiles
Definition: mountpoint.h:261
static FileSystem * Create(const FileSystemInfo &fs_info)
Definition: mountpoint.cc:166
bool has_custom_sqlitevfs_
Definition: mountpoint.h:435
perf::Counter * n_fs_statfs_
Definition: mountpoint.h:339
bool ReloadBlacklists()
Definition: mountpoint.cc:1237
std::string name()
Definition: mountpoint.h:234
time_t IsoTimestamp2UtcTime(const std::string &iso8601)
Definition: string.cc:216
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:663
void CreateAuthz()
Definition: mountpoint.cc:1325
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: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:246
static const unsigned kTracerBufferSize
Definition: mountpoint.h:590
void SetupUuid()
Definition: mountpoint.cc:1121
perf::Counter * n_eio_02_
Definition: mountpoint.h:349
catalog::ClientCatalogManager * catalog_mgr_
Definition: mountpoint.h:647
bool CreateSignatureManager()
Definition: mountpoint.cc:1584
std::string fqrn_
Definition: mountpoint.h:624
unsigned GetMaxTtlMn()
Definition: mountpoint.cc:1842
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:1355
bool SetupBehavior()
Definition: mountpoint.cc:1963
static ExternalCacheManager * Create(int fd_connection, unsigned max_open_fds, const std::string &ident)
AuthzFetcher * authz_fetcher_
Definition: mountpoint.h:637
bool FetchHistory(std::string *history_path)
Definition: mountpoint.cc:1798
perf::Statistics * statistics()
Definition: mountpoint.h:249
bool enforce_acls_
Definition: mountpoint.h:666
bool IsHaNfsSource()
Definition: mountpoint.h:196
void CreateTables()
Definition: mountpoint.cc:1656
shash::Any history() const
Definition: manifest.h:135
bool SetupCrashGuard()
Definition: mountpoint.cc:817
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:264
void ResetErrorCounters()
Definition: mountpoint.cc:605
Definition: mutex.h:42
Log2Histogram * hist_fs_lookup_
Definition: mountpoint.h:360
shash::Any root_hash
Definition: history.h:89
bool LoadPublicRsaKeys(const std::string &path_list)
Definition: signature.cc:305
void SetRegularDownloadManager(download::DownloadManager *download_mgr)
Definition: cache_stream.h:58
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:2210
static const unsigned kDefaultMemcacheSize
Definition: mountpoint.h:571
FileSystem * file_system_
Definition: cvmfs.cc:128
std::string repository_tag_
Definition: mountpoint.h:669
static const unsigned kDefaultMinTtl
Definition: dns.h:177
bool SetupOwnerMaps()
Definition: mountpoint.cc:2273
void SetDnsParameters(const unsigned retries, const unsigned timeout_ms)
Definition: download.cc:2148
bool CreateResolvConfWatcher()
Definition: mountpoint.cc:1546
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:369
void SetCatalogWatermark(unsigned limit)
static bool g_is_enabled
Definition: algorithm.h:201
bool SetupNfsMaps()
Definition: mountpoint.cc:900
std::string path
Definition: cache.h:133
bool CheckBlacklists()
Definition: mountpoint.cc:1199
void SetMetalinkResetDelay(const unsigned seconds)
Definition: download.cc:3136
std::vector< std::string > blacklist_paths_
Definition: mountpoint.h:670
cvmfs::Fetcher * fetcher_
Definition: mountpoint.h:644
file_watcher::FileWatcher * resolv_conf_watcher_
Definition: mountpoint.h:660
static const unsigned kDnsDefaultRetries
Definition: download.h:176
bool GeoSortServers(std::vector< std::string > *servers, std::vector< uint64_t > *output_order=NULL)
Definition: download.cc:2525
bool SetupExternalDownloadMgr(bool dogeosort)
Definition: mountpoint.cc:2139
void SetOwnerMaps(const OwnerMap &uid_map, const OwnerMap &gid_map)
CacheManager * SetupExternalCacheMgr(const std::string &instance)
Definition: mountpoint.cc:657
static void CleanupInstance()
Definition: clientctx.cc:18
perf::Counter * n_fs_lookup_negative_
Definition: mountpoint.h:336
Log2Histogram * hist_fs_open_
Definition: mountpoint.h:368
virtual bool AcquireQuotaManager(QuotaManager *quota_mgr)=0
std::string cache_mgr_instance_
Definition: mountpoint.h:408
std::string path_workspace_lock_
Definition: mountpoint.h:386
virtual void IncGeneration(const uint64_t by)=0
Log2Histogram * hist_fs_release_
Definition: mountpoint.h:370
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:596
OptionsManager * options_mgr_
Definition: mountpoint.h:329
perf::Counter * no_open_dirs_
Definition: mountpoint.h:346
glue::InodeTracker * inode_tracker_
Definition: mountpoint.h:654
bool fixed_catalog_
Definition: mountpoint.h:665
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:597
void GetHostInfo(std::vector< std::string > *host_chain, std::vector< int > *rtt, unsigned *current_host)
Definition: download.cc:2293
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:776
std::vector< std::string > FindFilesBySuffix(const std::string &dir, const std::string &suffix)
Definition: posix.cc:1135
std::string workspace()
Definition: mountpoint.h:252
bool g_claim_ownership
Definition: globals.cc:11
lru::PathCache * path_cache_
Definition: mountpoint.h:651
CacheManager * cache_mgr_
Definition: mountpoint.h:419
void AddHTTPTracingHeader(const std::string &header)
Definition: download.cc:3198
void SetCredentialsAttachment(CredentialsAttachment *ca)
Definition: download.cc:2113
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:251
cvmfs::Fetcher * external_fetcher_
Definition: mountpoint.h:645
perf::Counter * n_fs_dir_open_
Definition: mountpoint.h:334
std::string MkCacheParm(const std::string &generic_parameter, const std::string &instance)
Definition: mountpoint.cc:570
void UnlockFile(const int filedes)
Definition: posix.cc:1006
NfsMaps * nfs_maps_
Definition: mountpoint.h:430
download::DownloadManager * external_download_mgr()
Definition: mountpoint.h:506
void CreateFetchers()
Definition: mountpoint.cc:1569
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:3145
static MountPoint * Create(const std::string &fqrn, FileSystem *file_system, OptionsManager *options_mgr=NULL)
Definition: mountpoint.cc:1278
Log2Histogram * hist_fs_forget_
Definition: mountpoint.h:361
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
Definition: logging.cc:528