CernVM-FS  2.10.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_tiered.h"
38 #include "catalog.h"
39 #include "catalog_mgr_client.h"
40 #include "clientctx.h"
41 #include "download.h"
42 #include "duplex_sqlite3.h"
43 #include "fetch.h"
44 #include "file_chunk.h"
45 #include "globals.h"
46 #include "glue_buffer.h"
47 #include "google/protobuf/stubs/common.h"
48 #include "history.h"
49 #include "history_sqlite.h"
50 #include "logging.h"
51 #include "lru_md.h"
52 #include "manifest.h"
53 #include "manifest_fetch.h"
54 #include "nfs_maps.h"
55 #ifdef CVMFS_NFS_SUPPORT
56 #include "nfs_maps_leveldb.h"
57 #include "nfs_maps_sqlite.h"
58 #endif
59 #include "options.h"
60 #include "platform.h"
61 #include "quota_posix.h"
63 #include "signature.h"
64 #include "sqlitemem.h"
65 #include "sqlitevfs.h"
66 #include "statistics.h"
67 #include "tracer.h"
68 #include "util/pointer.h"
69 #include "util/posix.h"
70 #include "util/string.h"
71 #include "util_concurrency.h"
72 #include "uuid.h"
73 #include "wpad.h"
74 
75 using namespace std; // NOLINT
76 
77 
78 bool FileSystem::g_alive = false;
79 const char *FileSystem::kDefaultCacheBase = "/var/lib/cvmfs";
80 const char *FileSystem::kDefaultCacheMgrInstance = "default";
81 
82 
83 FileSystem::IoErrorInfo::IoErrorInfo() : counter_(NULL), timestamp_last_(0) { }
84 
86  counter_->Set(0);
87  timestamp_last_ = 0;
88 }
89 
91  perf::Inc(counter_);
92  timestamp_last_ = time(NULL);
93 }
94 
96 
97 int64_t FileSystem::IoErrorInfo::count() { return counter_->Get(); }
98 
99 time_t FileSystem::IoErrorInfo::timestamp_last() { return timestamp_last_; }
100 
101 
102 
107 bool FileSystem::CheckInstanceName(const std::string &instance) {
108  if (instance.length() > 24)
109  return false;
110  sanitizer::CacheInstanceSanitizer instance_sanitizer;
111  if (!instance_sanitizer.IsValid(instance)) {
112  boot_error_ = "invalid instance name (" + instance + "), " +
113  "only characters a-z, A-Z, 0-9, _ are allowed";
115  return false;
116  }
117  return true;
118 }
119 
120 
126 {
127  if (settings.is_alien && settings.is_shared) {
128  boot_error_ = "Failure: shared local disk cache and alien cache mutually "
129  "exclusive. Please turn off shared local disk cache.";
131  return false;
132  }
133  if (settings.is_alien && settings.is_managed) {
134  boot_error_ = "Failure: quota management and alien cache mutually "
135  "exclusive. Please turn off quota limit.";
137  return false;
138  }
139 
140  if (type_ == kFsLibrary) {
141  if (settings.is_shared || settings.is_managed) {
142  boot_error_ = "Failure: libcvmfs supports only unmanaged exclusive cache "
143  "or alien cache.";
145  return false;
146  }
147  }
148 
149  if (settings.cache_base_defined && settings.cache_dir_defined) {
150  boot_error_ =
151  "'CVMFS_CACHE_BASE' and 'CVMFS_CACHE_DIR' are mutually exclusive";
153  return false;
154  }
155 
156  return true;
157 }
158 
159 
166  file_system(new FileSystem(fs_info));
167 
168  file_system->SetupLogging();
169  LogCvmfs(kLogCvmfs, kLogDebug, "Options:\n%s",
170  file_system->options_mgr()->Dump().c_str());
171 
172  file_system->CreateStatistics();
173  file_system->SetupSqlite();
174  if (!file_system->DetermineNfsMode())
175  return file_system.Release();
176  if (!file_system->SetupWorkspace())
177  return file_system.Release();
178 
179  // Redirect SQlite temp directory to workspace (global variable)
180  unsigned length_tempdir = file_system->workspace_.length() + 1;
181  sqlite3_temp_directory = static_cast<char *>(sqlite3_malloc(length_tempdir));
182  snprintf(sqlite3_temp_directory,
183  length_tempdir,
184  "%s",
185  file_system->workspace_.c_str());
186 
187  if (!file_system->TriageCacheMgr())
188  return file_system.Release();
189  file_system->SetupUuid();
190  if (!file_system->SetupNfsMaps())
191  return file_system.Release();
192  bool retval = sqlite::RegisterVfsRdOnly(
193  file_system->cache_mgr_,
194  file_system->statistics_,
196  assert(retval);
197  file_system->has_custom_sqlitevfs_ = true;
198 
200 
201  file_system->boot_status_ = loader::kFailOk;
202  return file_system.Release();
203 }
204 
205 
208 
209  // Register the ShortString's static counters
210  statistics_->Register("pathstring.n_instances", "Number of instances");
211  statistics_->Register("pathstring.n_overflows", "Number of overflows");
212  statistics_->Register("namestring.n_instances", "Number of instances");
213  statistics_->Register("namestring.n_overflows", "Number of overflows");
214  statistics_->Register("linkstring.n_instances", "Number of instances");
215  statistics_->Register("linkstring.n_overflows", "Number of overflows");
216 
217  // Callback counters
218  n_fs_open_ = statistics_->Register("cvmfs.n_fs_open",
219  "Overall number of file open operations");
220  n_fs_dir_open_ = statistics_->Register("cvmfs.n_fs_dir_open",
221  "Overall number of directory open operations");
222  n_fs_lookup_ = statistics_->Register("cvmfs.n_fs_lookup",
223  "Number of lookups");
224  n_fs_lookup_negative_ = statistics_->Register("cvmfs.n_fs_lookup_negative",
225  "Number of negative lookups");
226  n_fs_stat_ = statistics_->Register("cvmfs.n_fs_stat", "Number of stats");
227  n_fs_read_ = statistics_->Register("cvmfs.n_fs_read", "Number of files read");
228  n_fs_readlink_ = statistics_->Register("cvmfs.n_fs_readlink",
229  "Number of links read");
230  n_fs_forget_ = statistics_->Register("cvmfs.n_fs_forget",
231  "Number of inode forgets");
232  no_open_files_ = statistics_->Register("cvmfs.no_open_files",
233  "Number of currently opened files");
234  no_open_dirs_ = statistics_->Register("cvmfs.no_open_dirs",
235  "Number of currently opened directories");
236  io_error_info_.SetCounter(statistics_->Register("cvmfs.n_io_error",
237  "Number of I/O errors"));
238 
239  string optarg;
240  if (options_mgr_->GetValue("CVMFS_INSTRUMENT_FUSE", &optarg) &&
241  options_mgr_->IsOn(optarg))
242  {
244  }
245 
246  hist_fs_lookup_ = new Log2Histogram(30);
247  hist_fs_forget_ = new Log2Histogram(30);
254  hist_fs_open_ = new Log2Histogram(30);
255  hist_fs_read_ = new Log2Histogram(30);
257 }
258 
259 
265  const string &instance
266 ) {
267  string optarg;
269 
270  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SHARED", instance),
271  &optarg)
272  && options_mgr_->IsOn(optarg))
273  {
274  settings.is_shared = true;
275  }
276  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SERVER_MODE", instance),
277  &optarg)
278  && options_mgr_->IsOn(optarg))
279  {
280  settings.avoid_rename = true;
281  }
282 
283  if (type_ == kFsFuse)
284  settings.quota_limit = kDefaultQuotaLimit;
285  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_QUOTA_LIMIT", instance),
286  &optarg))
287  {
288  settings.quota_limit = String2Int64(optarg) * 1024 * 1024;
289  }
290  if (settings.quota_limit > 0)
291  settings.is_managed = true;
292 
293  settings.cache_path = kDefaultCacheBase;
294  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_BASE", instance),
295  &optarg))
296  {
297  settings.cache_path = MakeCanonicalPath(optarg);
298  settings.cache_base_defined = true;
299  }
300  if (settings.is_shared) {
301  settings.cache_path += "/shared";
302  } else {
303  settings.cache_path += "/" + name_;
304  }
305 
306  // CheckCacheMode makes sure that CVMFS_CACHE_DIR and CVMFS_CACHE_BASE are
307  // not set at the same time.
308  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_DIR", instance),
309  &optarg))
310  {
311  settings.cache_dir_defined = true;
312  settings.cache_path = optarg;
313  }
314  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_ALIEN", instance),
315  &optarg))
316  {
317  settings.is_alien = true;
318  settings.cache_path = optarg;
319  }
320  // We already changed the cwd to the workspace
321  // Which is only done if using FUSE
322  if ((type_ == kFsFuse) && (settings.cache_path == workspace_fullpath_)) {
323  settings.cache_path = ".";
324  }
325 
326  // The cache workspace usually is the cache directory, unless explicitly
327  // set otherwise
328  settings.workspace = settings.cache_path;
329  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_WORKSPACE", instance),
330  &optarg) ||
331  options_mgr_->GetValue("CVMFS_WORKSPACE", &optarg))
332  {
333  // Used for the shared quota manager
334  settings.workspace = optarg;
335  }
336 
337  return settings;
338 }
339 
340 
342  string optarg;
343 
344  if (options_mgr_->GetValue("CVMFS_NFS_SOURCE", &optarg) &&
345  options_mgr_->IsOn(optarg))
346  {
347  nfs_mode_ |= kNfsMaps;
348  if (options_mgr_->GetValue("CVMFS_NFS_SHARED", &optarg)) {
350  nfs_maps_dir_ = optarg;
351  }
352  }
353 
354  if ((type_ == kFsLibrary) && (nfs_mode_ != kNfsNone)) {
355  boot_error_ = "Failure: libcvmfs does not support NFS export.";
357  return false;
358  }
359  return true;
360 }
361 
362 
364  : name_(fs_info.name)
365  , exe_path_(fs_info.exe_path)
366  , type_(fs_info.type)
367  , options_mgr_(fs_info.options_mgr)
368  , wait_workspace_(fs_info.wait_workspace)
369  , foreground_(fs_info.foreground)
370  , n_fs_open_(NULL)
371  , n_fs_dir_open_(NULL)
372  , n_fs_lookup_(NULL)
373  , n_fs_lookup_negative_(NULL)
374  , n_fs_stat_(NULL)
375  , n_fs_read_(NULL)
376  , n_fs_readlink_(NULL)
377  , n_fs_forget_(NULL)
378  , no_open_files_(NULL)
379  , no_open_dirs_(NULL)
380  , statistics_(NULL)
381  , fd_workspace_lock_(-1)
382  , found_previous_crash_(false)
384  , cache_mgr_(NULL)
385  , uuid_cache_(NULL)
386  , nfs_maps_(NULL)
387  , has_custom_sqlitevfs_(false)
388 {
389  assert(!g_alive);
390  g_alive = true;
391  g_uid = geteuid();
392  g_gid = getegid();
393 
394  string optarg;
395  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SERVER_MODE",
397  &optarg)
398  && options_mgr_->IsOn(optarg))
399  {
400  g_raw_symlinks = true;
401  }
402 }
403 
404 
407 
410 
411  delete uuid_cache_;
412  delete nfs_maps_;
413  delete cache_mgr_;
414 
415  if (sqlite3_temp_directory) {
416  sqlite3_free(sqlite3_temp_directory);
417  sqlite3_temp_directory = NULL;
418  }
419 
420  if (!path_crash_guard_.empty())
421  unlink(path_crash_guard_.c_str());
422  if (!path_workspace_lock_.empty())
423  unlink(path_workspace_lock_.c_str());
424  if (fd_workspace_lock_ >= 0)
426 
427  sqlite3_shutdown();
429 
430  delete hist_fs_lookup_;
431  delete hist_fs_forget_multi_;
432  delete hist_fs_forget_;
433  delete hist_fs_getattr_;
434  delete hist_fs_readlink_;
435  delete hist_fs_opendir_;
436  delete hist_fs_releasedir_;
437  delete hist_fs_readdir_;
438  delete hist_fs_open_;
439  delete hist_fs_read_;
440  delete hist_fs_release_;
441  delete statistics_;
442 
443  SetLogSyslogPrefix("");
444  SetLogMicroSyslog("");
445  SetLogDebugFile("");
446  google::protobuf::ShutdownProtobufLibrary();
447  g_alive = false;
448 }
449 
450 
452  path_workspace_lock_ = workspace_ + "/lock." + name_;
454  if (fd_workspace_lock_ >= 0)
455  return true;
456 
457  if (fd_workspace_lock_ == -1) {
458  boot_error_ = "could not acquire workspace lock (" +
459  StringifyInt(errno) + ")";
461  return false;
462  }
463 
464  assert(fd_workspace_lock_ == -2);
465 
466  if (!wait_workspace_) {
468  return false;
469  }
470 
472  if (fd_workspace_lock_ < 0) {
473  boot_error_ = "could not acquire workspace lock (" +
474  StringifyInt(errno) + ")";
476  return false;
477  }
478  return true;
479 }
480 
481 
483  void *user_data __attribute__((unused)),
484  int sqlite_extended_error,
485  const char *message)
486 {
487  int log_dest = kLogDebug;
488  int sqlite_error = sqlite_extended_error & 0xFF;
489  switch (sqlite_error) {
490  case SQLITE_INTERNAL:
491  case SQLITE_PERM:
492  case SQLITE_NOMEM:
493  case SQLITE_IOERR:
494  case SQLITE_CORRUPT:
495  case SQLITE_FULL:
496  case SQLITE_CANTOPEN:
497  case SQLITE_MISUSE:
498  case SQLITE_FORMAT:
499  case SQLITE_NOTADB:
500  log_dest |= kLogSyslogErr;
501  break;
502  case SQLITE_WARNING:
503  case SQLITE_NOTICE:
504  default:
505  break;
506  }
507  LogCvmfs(kLogCvmfs, log_dest, "SQlite3: %s (%d)",
508  message, sqlite_extended_error);
509 }
510 
511 
518  const string &generic_parameter,
519  const string &instance)
520 {
521  assert(HasPrefix(generic_parameter, "CVMFS_CACHE_", false));
522 
523  if (instance == kDefaultCacheMgrInstance) {
524  // Compatibility parameter names
525  if ((generic_parameter == "CVMFS_CACHE_SHARED") &&
526  !options_mgr_->IsDefined(generic_parameter))
527  {
528  return "CVMFS_SHARED_CACHE";
529  }
530  if ((generic_parameter == "CVMFS_CACHE_ALIEN") &&
531  !options_mgr_->IsDefined(generic_parameter))
532  {
533  return "CVMFS_ALIEN_CACHE";
534  }
535  if ((generic_parameter == "CVMFS_CACHE_SERVER_MODE") &&
536  !options_mgr_->IsDefined(generic_parameter))
537  {
538  return "CVMFS_SERVER_CACHE_MODE";
539  }
540  if ((generic_parameter == "CVMFS_CACHE_QUOTA_LIMIT") &&
541  !options_mgr_->IsDefined(generic_parameter))
542  {
543  return "CVMFS_QUOTA_LIMIT";
544  }
545  return generic_parameter;
546  }
547 
548  return "CVMFS_CACHE_" + instance + "_" + generic_parameter.substr(12);
549 }
550 
551 
554 }
555 
556 
560 CacheManager *FileSystem::SetupCacheMgr(const string &instance) {
561  if (constructed_instances_.find(instance) != constructed_instances_.end()) {
562  boot_error_ = "circular cache definition: " + instance;
564  return NULL;
565  }
566  constructed_instances_.insert(instance);
567 
568  LogCvmfs(kLogCvmfs, kLogDebug, "setting up cache manager instance %s",
569  instance.c_str());
570  string instance_type;
571  if (instance == kDefaultCacheMgrInstance) {
572  instance_type = "posix";
573  } else {
574  options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_TYPE", instance),
575  &instance_type);
576  }
577  if (instance_type == "posix") {
578  return SetupPosixCacheMgr(instance);
579  } else if (instance_type == "ram") {
580  return SetupRamCacheMgr(instance);
581  } else if (instance_type == "tiered") {
582  return SetupTieredCacheMgr(instance);
583  } else if (instance_type == "external") {
584  return SetupExternalCacheMgr(instance);
585  } else {
586  boot_error_ = "invalid cache manager type for '" + instance + "':" +
587  instance_type;
589  return NULL;
590  }
591 }
592 
593 
595  string optarg;
596  unsigned nfiles = kDefaultNfiles;
597  if (options_mgr_->GetValue("CVMFS_NFILES", &optarg))
598  nfiles = String2Uint64(optarg);
599  vector<string> cmd_line;
600  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_CMDLINE", instance),
601  &optarg))
602  {
603  cmd_line = SplitString(optarg, ',');
604  }
605 
606  if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_LOCATOR", instance),
607  &optarg))
608  {
609  boot_error_ = MkCacheParm("CVMFS_CACHE_LOCATOR", instance) + " missing";
611  return NULL;
612  }
613 
615  ExternalCacheManager::CreatePlugin(optarg, cmd_line));
616  if (!plugin_handle->IsValid()) {
617  boot_error_ = plugin_handle->error_msg();
619  return NULL;
620  }
622  plugin_handle->fd_connection(), nfiles, name_ + ":" + instance);
623  if (cache_mgr == NULL) {
624  boot_error_ = "failed to create external cache manager for " + instance;
626  return NULL;
627  }
628  cache_mgr->AcquireQuotaManager(ExternalQuotaManager::Create(cache_mgr));
629  return cache_mgr;
630 }
631 
632 
635  if (!CheckPosixCacheSettings(settings))
636  return NULL;
637 
639  settings.cache_path,
640  settings.is_alien,
643  if (!cache_mgr.IsValid()) {
644  boot_error_ = "Failed to setup posix cache '" + instance + "' in " +
645  settings.cache_path + ": " + strerror(errno);
647  return NULL;
648  }
649 
650  // Sentinel file for future use
651  // Might be a read-only cache
652  const bool ignore_failure = settings.is_alien;
653  CreateFile(settings.cache_path + "/.cvmfscache", 0600, ignore_failure);
654 
655  if (settings.is_managed) {
656  if (!SetupPosixQuotaMgr(settings, cache_mgr.weak_ref()))
657  return NULL;
658  }
659  return cache_mgr.Release();
660 }
661 
662 
663 CacheManager *FileSystem::SetupRamCacheMgr(const string &instance) {
664  string optarg;
665  unsigned nfiles = kDefaultNfiles;
666  if (options_mgr_->GetValue("CVMFS_NFILES", &optarg)) {
667  nfiles = String2Uint64(optarg);
668  }
669  uint64_t sz_cache_bytes;
670  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_SIZE", instance),
671  &optarg))
672  {
673  if (HasSuffix(optarg, "%", false)) {
674  sz_cache_bytes = platform_memsize() * String2Uint64(optarg)/100;
675  } else {
676  sz_cache_bytes = String2Uint64(optarg) * 1024 * 1024;
677  }
678  } else {
679  sz_cache_bytes = platform_memsize() >> 5; // ~3%
680  }
682  if (options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_MALLOC", instance),
683  &optarg))
684  {
685  if (optarg == "libc") {
687  } else if (optarg == "heap") {
689  } else {
690  boot_error_ = "Failure: unknown malloc " +
691  MkCacheParm("CVMFS_CACHE_MALLOC", instance) + "=" + optarg;
693  return NULL;
694  }
695  }
696  sz_cache_bytes = RoundUp8(std::max(static_cast<uint64_t>(40 * 1024 * 1024),
697  sz_cache_bytes));
699  sz_cache_bytes,
700  nfiles,
701  alloc,
702  perf::StatisticsTemplate("cache." + instance, statistics_));
703  if (cache_mgr == NULL) {
704  boot_error_ = "failed to create ram cache manager for " + instance;
706  return NULL;
707  }
708  cache_mgr->AcquireQuotaManager(new NoopQuotaManager());
709  return cache_mgr;
710 }
711 
712 
714  string optarg;
715  if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_UPPER", instance),
716  &optarg))
717  {
718  boot_error_ = MkCacheParm("CVMFS_CACHE_UPPER", instance) + " missing";
720  return NULL;
721  }
722  UniquePtr<CacheManager> upper(SetupCacheMgr(optarg));
723  if (!upper.IsValid())
724  return NULL;
725 
726  if (!options_mgr_->GetValue(MkCacheParm("CVMFS_CACHE_LOWER", instance),
727  &optarg))
728  {
729  boot_error_ = MkCacheParm("CVMFS_CACHE_LOWER", instance) + " missing";
731  return NULL;
732  }
733  UniquePtr<CacheManager> lower(SetupCacheMgr(optarg));
734  if (!lower.IsValid())
735  return NULL;
736 
737  CacheManager *tiered =
738  TieredCacheManager::Create(upper.Release(), lower.Release());
739  if (tiered == NULL) {
740  boot_error_ = "Failed to setup tiered cache manager " + instance;
742  return NULL;
743  }
744  if (options_mgr_->GetValue(
745  MkCacheParm("CVMFS_CACHE_LOWER_READONLY", instance), &optarg) &&
746  options_mgr_->IsOn(optarg))
747  {
748  static_cast<TieredCacheManager*>(tiered)->SetLowerReadOnly();
749  }
750  return tiered;
751 }
752 
753 
755  path_crash_guard_ = workspace_ + "/running." + name_;
756  platform_stat64 info;
757  int retval = platform_stat(path_crash_guard_.c_str(), &info);
758  if (retval == 0) {
759  found_previous_crash_ = true;
761  "looks like cvmfs has been crashed previously");
762  }
763  retval = open(path_crash_guard_.c_str(), O_RDONLY | O_CREAT, 0600);
764  if (retval < 0) {
765  boot_error_ = "could not open running sentinel (" +
766  StringifyInt(errno) + ")";
768  return false;
769  }
770  close(retval);
771  return true;
772 }
773 
774 
776  if (type_ == kFsFuse) {
777  // Try to jump to workspace / cache directory. This tests, if it is
778  // accessible and it brings speed later on.
779  int retval = chdir(workspace_.c_str());
780  if (retval != 0) {
781  boot_error_ = "workspace " + workspace_ + " is unavailable";
783  return false;
784  }
785  workspace_ = ".";
786  return true;
787  }
788 
789  // Note: as of version 2.4 support for CVMFS_CWD_CACHE is dropped due to
790  // disproportionate large complexity to configure correctly. This affects
791  // only libcvmfs, mostly the legacy part.
792  // string optarg;
793  // if (options_mgr_->GetValue("CVMFS_CWD_CACHE", &optarg) &&
794  // options_mgr_->IsOn(optarg))
795  // {
796  // ...
797  // }
798  return true;
799 }
800 
801 
803  string optarg;
804  if (options_mgr_->GetValue("CVMFS_SYSLOG_LEVEL", &optarg))
806  if (options_mgr_->GetValue("CVMFS_SYSLOG_FACILITY", &optarg))
808  if (options_mgr_->GetValue("CVMFS_USYSLOG", &optarg))
809  SetLogMicroSyslog(optarg);
810  if (options_mgr_->GetValue("CVMFS_DEBUGLOG", &optarg))
811  SetLogDebugFile(optarg);
812  if (options_mgr_->GetValue("CVMFS_SYSLOG_PREFIX", &optarg)) {
813  SetLogSyslogPrefix(optarg);
814  } else {
816  }
817 }
818 
819 
821 #ifdef CVMFS_NFS_SUPPORT
822  if (!IsHaNfsSource())
824 
825  string no_nfs_sentinel;
826  if (cache_mgr_->id() == kPosixCacheManager) {
827  PosixCacheManager *posix_cache_mgr =
828  reinterpret_cast<PosixCacheManager *>(cache_mgr_);
829  no_nfs_sentinel = posix_cache_mgr->cache_path() + "/no_nfs_maps." + name_;
830  if (!IsNfsSource()) {
831  // Might be a read-only cache
832  const bool ignore_failure = posix_cache_mgr->alien_cache();
833  CreateFile(no_nfs_sentinel, 0600, ignore_failure);
834  return true;
835  }
836  } else {
837  if (IsNfsSource()) {
838  boot_error_ = "NFS source only works with POSIX cache manager.";
840  return false;
841  }
842  return true;
843  }
844 
846  assert(IsNfsSource());
847  if (!no_nfs_sentinel.empty() && FileExists(no_nfs_sentinel)) {
848  boot_error_ = "Cache was used without NFS maps before. "
849  "It has to be wiped out.";
851  return false;
852  }
853 
854  // nfs maps need to be protected by workspace lock
855  PosixCacheManager *posix_cache_mgr =
856  reinterpret_cast<PosixCacheManager *>(cache_mgr_);
857  if (posix_cache_mgr->cache_path() != workspace_) {
858  boot_error_ = "Cache directory and workspace must be identical for "
859  "NFS export";
861  return false;
862  }
863 
864  string inode_cache_dir = nfs_maps_dir_ + "/nfs_maps." + name_;
865  if (!MkdirDeep(inode_cache_dir, 0700)) {
866  boot_error_ = "Failed to initialize NFS maps";
868  return false;
869  }
870 
871  // TODO(jblomer): make this a manager class
872  if (IsHaNfsSource()) {
874  inode_cache_dir,
877  statistics_);
878  } else {
880  inode_cache_dir,
883  statistics_);
884  }
885 
886  if (nfs_maps_ == NULL) {
887  boot_error_ = "Failed to initialize NFS maps";
889  return false;
890  }
891 
892  string optarg;
893  if (options_mgr_->GetValue("CVMFS_NFS_INTERLEAVED_INODES", &optarg)) {
894  vector<string> tokens = SplitString(optarg, '%');
895  if (tokens.size() != 2) {
896  boot_error_ =
897  "invalid format for CVMFS_NFS_INTERLEAVED_INODES: " + optarg;
899  return false;
900  }
902  String2Uint64(tokens[0]));
903  }
904 
905  return true;
906 
907 #else
908  return true;
909 #endif
910 }
911 
912 
915  CacheManager *cache_mgr
916 ) {
917  assert(settings.quota_limit >= 0);
918  int64_t quota_threshold = settings.quota_limit / 2;
919  string cache_workspace = settings.cache_path;
920  if (settings.cache_path != settings.workspace) {
922  "using workspace %s to protect cache database in %s",
923  settings.workspace.c_str(), settings.cache_path.c_str());
924  cache_workspace += ":" + settings.workspace;
925  }
926  PosixQuotaManager *quota_mgr;
927 
928  if (settings.is_shared) {
930  exe_path_,
931  cache_workspace,
932  settings.quota_limit,
933  quota_threshold,
934  foreground_);
935  if (quota_mgr == NULL) {
936  boot_error_ = "Failed to initialize shared lru cache";
938  return false;
939  }
940  } else {
941  quota_mgr = PosixQuotaManager::Create(
942  cache_workspace,
943  settings.quota_limit,
944  quota_threshold,
946  if (quota_mgr == NULL) {
947  boot_error_ = "Failed to initialize lru cache";
949  return false;
950  }
951  }
952 
953  if (quota_mgr->GetSize() > quota_mgr->GetCapacity()) {
955  "cache is already beyond quota size "
956  "(size: %" PRId64 ", capacity: %" PRId64 "), cleaning up",
957  quota_mgr->GetSize(), quota_mgr->GetCapacity());
958  if (!quota_mgr->Cleanup(quota_threshold)) {
959  delete quota_mgr;
960  boot_error_ = "Failed to clean up cache";
962  return false;
963  }
964  }
965 
966  int retval = cache_mgr->AcquireQuotaManager(quota_mgr);
967  assert(retval);
969  "CernVM-FS: quota initialized, current size %luMB",
970  quota_mgr->GetSize() / (1024 * 1024));
971  return true;
972 }
973 
974 
976  // Make sure SQlite starts clean after initialization
977  sqlite3_shutdown();
978 
979  int retval;
980  retval = sqlite3_config(SQLITE_CONFIG_LOG, FileSystem::LogSqliteError, NULL);
981  assert(retval == SQLITE_OK);
982  retval = sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
983  assert(retval == SQLITE_OK);
985 
986  // Disable SQlite3 file locking
987  retval = sqlite3_vfs_register(sqlite3_vfs_find("unix-none"), 1);
988  assert(retval == SQLITE_OK);
989 }
990 
991 
993  string optarg;
994  // This is very similar to "determine cache dir". It's for backward
995  // compatibility with classic cache configuration where there was no
996  // distinction between workspace and cache.
997  // Complicated cache configurations should explicitly set CVMFS_WORKSPACE.
999  if (options_mgr_->GetValue("CVMFS_CACHE_BASE", &optarg))
1000  workspace_ = MakeCanonicalPath(optarg);
1001  if (options_mgr_->GetValue("CVMFS_SHARED_CACHE", &optarg) &&
1002  options_mgr_->IsOn(optarg))
1003  {
1004  workspace_ += "/shared";
1005  } else {
1006  workspace_ += "/" + name_;
1007  }
1008  if (options_mgr_->GetValue("CVMFS_CACHE_DIR", &optarg)) {
1009  if (options_mgr_->IsDefined("CVMFS_CACHE_BASE")) {
1010  boot_error_ =
1011  "'CVMFS_CACHE_BASE' and 'CVMFS_CACHE_DIR' are mutually exclusive";
1013  return false;
1014  }
1015  workspace_ = optarg;
1016  }
1017  if (options_mgr_->GetValue("CVMFS_WORKSPACE", &optarg))
1018  workspace_ = optarg;
1020 
1021  // If workspace and alien cache are the same directory, we need to open
1022  // permission now to 0770 to avoid a race when fixing it later
1023  const int mode = 0770;
1024  if (!MkdirDeep(workspace_, mode, false)) {
1025  boot_error_ = "cannot create workspace directory " + workspace_;
1027  return false;
1028  }
1029 
1030  if (!LockWorkspace())
1031  return false;
1032  if (!SetupCwd())
1033  return false;
1034  if (!SetupCrashGuard())
1035  return false;
1036 
1037  return true;
1038 }
1039 
1040 
1043  if (uuid_cache_ == NULL) {
1045  "failed to load/store %s/uuid", workspace_.c_str());
1047  assert(uuid_cache_ != NULL);
1048  }
1049 }
1050 
1051 
1057  if ((cache_mgr_ != NULL) && (cache_mgr_->id() == kPosixCacheManager)) {
1058  PosixCacheManager *posix_cache_mgr =
1059  reinterpret_cast<PosixCacheManager *>(cache_mgr_);
1060  posix_cache_mgr->TearDown2ReadOnly();
1061  }
1062 
1063  unlink(path_crash_guard_.c_str());
1064  LogCvmfs(kLogCache, kLogSyslog, "switch to read-only cache mode");
1065  SetLogMicroSyslog("");
1066 }
1067 
1068 
1069 void FileSystem::RemapCatalogFd(int from, int to) {
1070  sqlite::RegisterFdMapping(from, to);
1071 }
1072 
1073 
1076  string instance;
1077  if (options_mgr_->GetValue("CVMFS_CACHE_PRIMARY", &instance) &&
1078  !instance.empty())
1079  {
1080  if (!CheckInstanceName(instance))
1081  return false;
1082  cache_mgr_instance_ = instance;
1083  }
1084 
1086  return cache_mgr_ != NULL;
1087 }
1088 
1089 
1090 //------------------------------------------------------------------------------
1091 
1092 
1093 const char *MountPoint::kDefaultAuthzSearchPath = "/usr/libexec/cvmfs/authz";
1094 const char *MountPoint::kDefaultBlacklist = "/etc/cvmfs/blacklist";
1095 
1097  blacklist_paths_.clear();
1098  string blacklist;
1099  if (!options_mgr_->GetValue("CVMFS_BLACKLIST", &blacklist))
1100  blacklist = kDefaultBlacklist;
1101  blacklist_paths_.push_back(blacklist);
1102 
1103  bool append = false;
1104  if (FileExists(blacklist)) {
1105  if (!signature_mgr_->LoadBlacklist(blacklist, append)) {
1106  boot_error_ = "failed to load blacklist " + blacklist;
1108  return false;
1109  }
1110  append = true;
1111  }
1112 
1113  string config_repository_path;
1114  if (options_mgr_->HasConfigRepository(fqrn_, &config_repository_path)) {
1115  blacklist = config_repository_path + "blacklist";
1116  blacklist_paths_.push_back(blacklist);
1117  if (FileExists(blacklist)) {
1118  if (!signature_mgr_->LoadBlacklist(blacklist, append)) {
1119  boot_error_ = "failed to load blacklist from config repository";
1121  return false;
1122  }
1123  }
1124  }
1125 
1126  return true;
1127 }
1128 
1129 
1135  bool result = true;
1136  bool append = false;
1137  for (unsigned i = 0; i < blacklist_paths_.size(); ++i) {
1138  string blacklist = blacklist_paths_[i];
1139  if (FileExists(blacklist)) {
1140  bool retval = signature_mgr_->LoadBlacklist(blacklist, append);
1141  // TODO(jblomer): this can leave us with a half-loaded blacklist
1142  if (!retval)
1143  return false;
1144  append = true;
1145  }
1146  }
1147  return result;
1148 }
1149 
1150 
1156  const string &fqrn,
1157  FileSystem *file_system,
1158  OptionsManager *options_mgr)
1159 {
1160  if (options_mgr == NULL)
1161  options_mgr = file_system->options_mgr();
1162  UniquePtr<MountPoint> mountpoint(new MountPoint(
1163  fqrn, file_system, options_mgr));
1164 
1165  // At this point, we have a repository name, the type (fuse or library) and
1166  // an options manager (which can be the same than the FileSystem's one).
1167 
1168  mountpoint->CreateStatistics();
1169  mountpoint->CreateAuthz();
1170  mountpoint->backoff_throttle_ = new BackoffThrottle();
1171 
1172  if (!mountpoint->CreateSignatureManager() || !mountpoint->CheckBlacklists())
1173  return mountpoint.Release();
1174  if (!mountpoint->CreateDownloadManagers())
1175  return mountpoint.Release();
1176  if (!mountpoint->CreateResolvConfWatcher()) {
1177  return mountpoint.Release();
1178  }
1179  mountpoint->CreateFetchers();
1180  if (!mountpoint->CreateCatalogManager())
1181  return mountpoint.Release();
1182  if (!mountpoint->CreateTracer())
1183  return mountpoint.Release();
1184 
1185  mountpoint->ReEvaluateAuthz();
1186  mountpoint->CreateTables();
1187  if (!mountpoint->SetupBehavior())
1188  return mountpoint.Release();
1189 
1190  mountpoint->boot_status_ = loader::kFailOk;
1191  return mountpoint.Release();
1192 }
1193 
1194 
1196  string optarg;
1197  string authz_helper;
1198  if (options_mgr_->GetValue("CVMFS_AUTHZ_HELPER", &optarg))
1199  authz_helper = optarg;
1200  string authz_search_path(kDefaultAuthzSearchPath);
1201  if (options_mgr_->GetValue("CVMFS_AUTHZ_SEARCH_PATH", &optarg))
1202  authz_search_path = optarg;
1203 
1205  fqrn_,
1206  authz_helper,
1207  authz_search_path,
1208  options_mgr_);
1209  assert(authz_fetcher_ != NULL);
1210 
1213  statistics_);
1214  assert(authz_session_mgr_ != NULL);
1215 
1217  assert(authz_attachment_ != NULL);
1218 }
1219 
1220 
1222  string optarg;
1223 
1225 
1227  if (!SetupOwnerMaps())
1228  return false;
1229  shash::Any root_hash;
1230  if (!DetermineRootHash(&root_hash))
1231  return false;
1232 
1233  bool retval;
1234  if (root_hash.IsNull()) {
1235  retval = catalog_mgr_->Init();
1236  } else {
1237  fixed_catalog_ = true;
1238  bool alt_root_path =
1239  options_mgr_->GetValue("CVMFS_ALT_ROOT_PATH", &optarg) &&
1240  options_mgr_->IsOn(optarg);
1241  retval = catalog_mgr_->InitFixed(root_hash, alt_root_path);
1242  }
1243  if (!retval) {
1244  boot_error_ = "Failed to initialize root file catalog";
1246  return false;
1247  }
1248 
1250  boot_error_ = "repository revision blacklisted";
1252  return false;
1253  }
1254 
1255  if (options_mgr_->GetValue("CVMFS_AUTO_UPDATE", &optarg) &&
1256  !options_mgr_->IsOn(optarg))
1257  {
1258  fixed_catalog_ = true;
1259  }
1260 
1261  if (options_mgr_->GetValue("CVMFS_CATALOG_WATERMARK", &optarg)) {
1263  } else {
1264  unsigned soft_limit;
1265  unsigned hard_limit;
1266  GetLimitNoFile(&soft_limit, &hard_limit);
1267  catalog_mgr_->SetCatalogWatermark(soft_limit / 4);
1268  }
1269 
1270  if (catalog_mgr_->volatile_flag()) {
1271  LogCvmfs(kLogCvmfs, kLogDebug, "content of repository flagged as VOLATILE");
1272  }
1273 
1274  return true;
1275 }
1276 
1277 
1279  string optarg;
1282  perf::StatisticsTemplate("download", statistics_));
1284 
1285  if (options_mgr_->GetValue("CVMFS_SERVER_URL", &optarg)) {
1286  download_mgr_->SetHostChain(optarg);
1287  }
1288 
1290  SetupHttpTuning();
1291 
1292  string forced_proxy_template;
1293  if (options_mgr_->GetValue("CVMFS_PROXY_TEMPLATE", &optarg))
1294  forced_proxy_template = optarg;
1296  forced_proxy_template);
1297 
1298  string proxies;
1299  if (options_mgr_->GetValue("CVMFS_HTTP_PROXY", &optarg))
1300  proxies = optarg;
1302  proxies,
1303  file_system_->workspace() + "/proxies" + GetUniqFileSuffix(),
1304  download_mgr_);
1305  if (proxies == "") {
1306  boot_error_ = "failed to discover HTTP proxy servers";
1308  return false;
1309  }
1310  string fallback_proxies;
1311  if (options_mgr_->GetValue("CVMFS_FALLBACK_PROXY", &optarg))
1312  fallback_proxies = optarg;
1313  download_mgr_->SetProxyChain(proxies, fallback_proxies,
1315 
1316  bool do_geosort = options_mgr_->GetValue("CVMFS_USE_GEOAPI", &optarg) &&
1317  options_mgr_->IsOn(optarg);
1318  if (do_geosort) {
1320  }
1321  if (options_mgr_->GetValue("CVMFS_MAX_SERVERS", &optarg)) {
1322  unsigned max_servers = String2Uint64(optarg);
1323  std::vector<std::string> host_chain;
1324  download_mgr_->GetHostInfo(&host_chain, NULL, NULL);
1325  if (max_servers > 0 && max_servers < host_chain.size()) {
1326  host_chain.resize(max_servers);
1327  download_mgr_->SetHostChain(host_chain);
1328  }
1329  }
1330 
1331  if (options_mgr_->GetValue("CVMFS_USE_SSL_SYSTEM_CA", &optarg) &&
1332  options_mgr_->IsOn(optarg)) {
1334  }
1335 
1336  if (options_mgr_->GetValue("CVMFS_PROXY_SHARD", &optarg) &&
1337  options_mgr_->IsOn(optarg)) {
1339  }
1340 
1341  return SetupExternalDownloadMgr(do_geosort);
1342 }
1343 
1345  std::string roaming_value;
1346  options_mgr_->GetValue("CVMFS_DNS_ROAMING", &roaming_value);
1347  if (options_mgr_->IsDefined("CVMFS_DNS_ROAMING") &&
1348  options_mgr_->IsOn(roaming_value)) {
1350  "DNS roaming is enabled for this repository.");
1351  // Create a file watcher to update the DNS settings of the download
1352  // managers when there are changes to /etc/resolv.conf
1354 
1355  if (resolv_conf_watcher_) {
1356  ResolvConfEventHandler *handler =
1358  resolv_conf_watcher_->RegisterHandler("/etc/resolv.conf", handler);
1359  }
1360  } else {
1362  "DNS roaming is disabled for this repository.");
1363  }
1364  return true;
1365 }
1366 
1368  fetcher_ = new cvmfs::Fetcher(
1370  download_mgr_,
1373 
1374  const bool is_external_data = true;
1379  perf::StatisticsTemplate("fetch-external", statistics_),
1380  is_external_data);
1381 }
1382 
1383 
1385  string optarg;
1387  signature_mgr_->Init();
1388 
1389  string public_keys;
1390  if (options_mgr_->GetValue("CVMFS_PUBLIC_KEY", &optarg)) {
1391  public_keys = optarg;
1392  } else if (options_mgr_->GetValue("CVMFS_KEYS_DIR", &optarg)) {
1393  // Collect .pub files from CVMFS_KEYS_DIR
1394  public_keys = JoinStrings(FindFilesBySuffix(optarg, ".pub"), ":");
1395  } else {
1396  public_keys =
1397  JoinStrings(FindFilesBySuffix("/etc/cvmfs/keys", ".pub"), ":");
1398  }
1399 
1400  if (!signature_mgr_->LoadPublicRsaKeys(public_keys)) {
1401  boot_error_ = "failed to load public key(s)";
1403  return false;
1404  }
1405  LogCvmfs(kLogCvmfs, kLogDebug, "CernVM-FS: using public key(s) %s",
1406  public_keys.c_str());
1407 
1408  if (options_mgr_->GetValue("CVMFS_TRUSTED_CERTS", &optarg)) {
1409  if (!signature_mgr_->LoadTrustedCaCrl(optarg)) {
1410  boot_error_ = "failed to load trusted certificates";
1412  return false;
1413  }
1414  }
1415 
1416  return true;
1417 }
1418 
1419 
1423  return;
1424 
1425  // TODO(jblomer): this should be registered by the tracker
1426  statistics_->Register("inode_tracker.n_insert",
1427  "overall number of accessed inodes");
1428  statistics_->Register("inode_tracker.n_remove",
1429  "overall number of evicted inodes");
1430  statistics_->Register("inode_tracker.no_reference",
1431  "currently active inodes");
1432  statistics_->Register("inode_tracker.n_hit_inode",
1433  "overall number of inode lookups");
1434  statistics_->Register("inode_tracker.n_hit_path",
1435  "overall number of successful path lookups");
1436  statistics_->Register("inode_tracker.n_miss_path",
1437  "overall number of unsuccessful path lookups");
1438 
1439  statistics_->Register("nentry_tracker.n_insert",
1440  "overall number of added negative cache entries");
1441  statistics_->Register("nentry_tracker.n_remove",
1442  "overall number of evicted negative cache entries");
1443  statistics_->Register("nentry_tracker.n_prune",
1444  "overall number of prune calls");
1445 }
1446 
1447 
1450  // Libcvmfs simplified tables
1453  return;
1454  }
1455 
1456  chunk_tables_ = new ChunkTables();
1457 
1458  string optarg;
1459  uint64_t mem_cache_size = kDefaultMemcacheSize;
1460  if (options_mgr_->GetValue("CVMFS_MEMCACHE_SIZE", &optarg))
1461  mem_cache_size = String2Uint64(optarg) * 1024 * 1024;
1462 
1463  const double memcache_unit_size =
1464  (static_cast<double>(kInodeCacheFactor) * lru::Md5PathCache::GetEntrySize())
1466  const unsigned memcache_num_units =
1467  mem_cache_size / static_cast<unsigned>(memcache_unit_size);
1468  // Number of cache entries must be a multiple of 64
1469  const unsigned mask_64 = ~((1 << 6) - 1);
1470  inode_cache_ = new lru::InodeCache(memcache_num_units & mask_64, statistics_);
1471  path_cache_ = new lru::PathCache(memcache_num_units & mask_64, statistics_);
1472  md5path_cache_ = new lru::Md5PathCache((memcache_num_units * 7) & mask_64,
1473  statistics_);
1474 
1477 }
1478 
1488  string optarg;
1489  tracer_ = new Tracer();
1490  if (options_mgr_->GetValue("CVMFS_TRACEFILE", &optarg)) {
1492  boot_error_ = "tracer is only supported in the fuse module";
1494  return false;
1495  }
1496  string tracebuffer_file = optarg;
1497  uint64_t tracebuffer_size = kTracerBufferSize;
1498  uint64_t tracebuffer_threshold = kTracerFlushThreshold;
1499 
1500  if (options_mgr_->GetValue("CVMFS_TRACEBUFFER", &optarg)) {
1501  tracebuffer_size = String2Uint64(optarg);
1502  }
1503  if (options_mgr_->GetValue("CVMFS_TRACEBUFFER_THRESHOLD",
1504  &optarg)) {
1505  tracebuffer_threshold = String2Uint64(optarg);
1506  }
1507  assert(tracebuffer_size <= INT_MAX
1508  && tracebuffer_threshold <= INT_MAX);
1510  "Initialising tracer with buffer size %" PRIu64 " and threshold %" PRIu64,
1511  tracebuffer_size, tracebuffer_threshold);
1512  tracer_->Activate(tracebuffer_size, tracebuffer_threshold,
1513  tracebuffer_file);
1514  }
1515  return true;
1516 }
1517 
1518 
1520  string optarg;
1521  if (options_mgr_->GetValue("CVMFS_ROOT_HASH", &optarg)) {
1522  *root_hash = MkFromHexPtr(shash::HexPtr(optarg), shash::kSuffixCatalog);
1523  return true;
1524  }
1525 
1526  if (!options_mgr_->IsDefined("CVMFS_REPOSITORY_TAG") &&
1527  !options_mgr_->IsDefined("CVMFS_REPOSITORY_DATE"))
1528  {
1529  root_hash->SetNull();
1530  return true;
1531  }
1532 
1533  string history_path;
1534  if (!FetchHistory(&history_path))
1535  return false;
1536  UnlinkGuard history_file(history_path);
1538  history::SqliteHistory::Open(history_path));
1539  if (!tag_db.IsValid()) {
1541  "failed to open history database (%s)", history_path.c_str());
1542  boot_error_ = "failed to open history database";
1544  return false;
1545  }
1546 
1548  bool retval;
1549  if (!options_mgr_->GetValue("CVMFS_REPOSITORY_TAG", &repository_tag_)) {
1550  string repository_date;
1551  // options_mgr_->IsDefined("CVMFS_REPOSITORY_DATE") must be true
1552  options_mgr_->GetValue("CVMFS_REPOSITORY_DATE", &repository_date);
1553  time_t repository_utctime = IsoTimestamp2UtcTime(repository_date);
1554  if (repository_utctime == 0) {
1555  boot_error_ = "invalid timestamp in CVMFS_REPOSITORY_DATE: " +
1556  repository_date + ". Use YYYY-MM-DDTHH:MM:SSZ";
1558  return false;
1559  }
1560  retval = tag_db->GetByDate(repository_utctime, &tag);
1561  if (!retval) {
1562  boot_error_ = "no repository state as early as utc timestamp " +
1563  StringifyTime(repository_utctime, true);
1565  return false;
1566  }
1568  "time stamp %s UTC resolved to tag '%s'",
1569  StringifyTime(repository_utctime, true).c_str(),
1570  tag.name.c_str());
1571  repository_tag_ = tag.name;
1572  } else {
1573  retval = tag_db->GetByName(repository_tag_, &tag);
1574  if (!retval) {
1575  boot_error_ = "no such tag: " + repository_tag_;
1577  return false;
1578  }
1579  }
1580  LogCvmfs(kLogCvmfs, kLogDebug, "mounting tag %s", tag.name.c_str());
1581 
1582  *root_hash = tag.root_hash;
1583  return true;
1584 }
1585 
1586 
1587 bool MountPoint::FetchHistory(std::string *history_path) {
1588  manifest::Failures retval_mf;
1589  manifest::ManifestEnsemble ensemble;
1590  retval_mf = manifest::Fetch("", fqrn_, 0, NULL, signature_mgr_, download_mgr_,
1591  &ensemble);
1592  if (retval_mf != manifest::kFailOk) {
1593  boot_error_ = "Failed to fetch manifest";
1595  return false;
1596  }
1597  shash::Any history_hash = ensemble.manifest->history();
1598  if (history_hash.IsNull()) {
1599  boot_error_ = "No history";
1601  return false;
1602  }
1603 
1604  int fd = fetcher_->Fetch(
1605  history_hash,
1607  "tag database for " + fqrn_,
1610  if (fd < 0) {
1611  boot_error_ = "failed to download history: " + StringifyInt(-fd);
1613  return false;
1614  }
1615  // We have the custom sqlite vfs driver installed
1616  *history_path = "@" + StringifyInt(fd);
1617  return true;
1618 }
1619 
1620 
1622  unsigned max_ttl;
1623  {
1624  MutexLockGuard lock_guard(lock_max_ttl_);
1625  max_ttl = max_ttl_sec_;
1626  }
1627  const unsigned catalog_ttl_sec = catalog_mgr_->GetTTL();
1628 
1629  return max_ttl ? std::min(max_ttl, catalog_ttl_sec) : catalog_ttl_sec;
1630 }
1631 
1632 
1634  MutexLockGuard lock_guard(lock_max_ttl_);
1635  return max_ttl_sec_ / 60;
1636 }
1637 
1638 
1644  return "." + file_system_->name() + "-" + fqrn_;
1645 }
1646 
1647 
1649  const string &fqrn,
1650  FileSystem *file_system,
1651  OptionsManager *options_mgr)
1652  : fqrn_(fqrn)
1653  , uuid_(cvmfs::Uuid::Create(""))
1654  , file_system_(file_system)
1655  , options_mgr_(options_mgr)
1656  , statistics_(NULL)
1657  , authz_fetcher_(NULL)
1658  , authz_session_mgr_(NULL)
1659  , authz_attachment_(NULL)
1660  , backoff_throttle_(NULL)
1661  , signature_mgr_(NULL)
1662  , download_mgr_(NULL)
1663  , external_download_mgr_(NULL)
1664  , fetcher_(NULL)
1665  , external_fetcher_(NULL)
1666  , inode_annotation_(NULL)
1667  , catalog_mgr_(NULL)
1668  , chunk_tables_(NULL)
1669  , simple_chunk_tables_(NULL)
1670  , inode_cache_(NULL)
1671  , path_cache_(NULL)
1672  , md5path_cache_(NULL)
1673  , tracer_(NULL)
1674  , inode_tracker_(NULL)
1675  , nentry_tracker_(NULL)
1676  , resolv_conf_watcher_(NULL)
1677  , max_ttl_sec_(kDefaultMaxTtlSec)
1678  , kcache_timeout_sec_(static_cast<double>(kDefaultKCacheTtlSec))
1679  , fixed_catalog_(false)
1680  , enforce_acls_(false)
1681  , has_membership_req_(false)
1682  , talk_socket_path_(std::string("./cvmfs_io.") + fqrn)
1683  , talk_socket_uid_(0)
1684  , talk_socket_gid_(0)
1685 {
1686  int retval = pthread_mutex_init(&lock_max_ttl_, NULL);
1687  assert(retval == 0);
1688 }
1689 
1690 
1692  pthread_mutex_destroy(&lock_max_ttl_);
1693 
1694  delete nentry_tracker_;
1695  delete inode_tracker_;
1696  delete tracer_;
1697  delete md5path_cache_;
1698  delete path_cache_;
1699  delete inode_cache_;
1700  delete simple_chunk_tables_;
1701  delete chunk_tables_;
1702 
1703  delete catalog_mgr_;
1704  delete inode_annotation_;
1705  delete external_fetcher_;
1706  delete fetcher_;
1707  if (external_download_mgr_ != NULL) {
1709  delete external_download_mgr_;
1710  }
1711  if (download_mgr_ != NULL) {
1712  download_mgr_->Fini();
1713  delete download_mgr_;
1714  }
1715  if (signature_mgr_ != NULL) {
1716  signature_mgr_->Fini();
1717  delete signature_mgr_;
1718  }
1719 
1720  if (resolv_conf_watcher_ != NULL) {
1722  delete resolv_conf_watcher_;
1723  }
1724 
1725  delete backoff_throttle_;
1726  delete authz_attachment_;
1727  delete authz_session_mgr_;
1728  delete authz_fetcher_;
1729  delete statistics_;
1730  delete uuid_;
1731 }
1732 
1733 
1735  string old_membership_req = membership_req_;
1737  if (old_membership_req != membership_req_) {
1740  }
1741 }
1742 
1743 
1744 void MountPoint::SetMaxTtlMn(unsigned value_minutes) {
1745  MutexLockGuard lock_guard(lock_max_ttl_);
1746  max_ttl_sec_ = value_minutes * 60;
1747 }
1748 
1749 
1751  string optarg;
1752 
1753  if (options_mgr_->GetValue("CVMFS_MAX_TTL", &optarg))
1754  SetMaxTtlMn(String2Uint64(optarg));
1755 
1756  if (options_mgr_->GetValue("CVMFS_KCACHE_TIMEOUT", &optarg)) {
1757  // Can be negative and should then be interpreted as 0.0
1759  std::max(0.0, static_cast<double>(String2Int64(optarg)));
1760  }
1761  LogCvmfs(kLogCvmfs, kLogDebug, "kernel caches expire after %d seconds",
1762  static_cast<int>(kcache_timeout_sec_));
1763 
1764  bool hide_magic_xattrs = false;
1765  if (options_mgr_->GetValue("CVMFS_HIDE_MAGIC_XATTRS", &optarg)
1766  && options_mgr_->IsOn(optarg))
1767  {
1768  hide_magic_xattrs = true;
1769  }
1770  magic_xattr_mgr_ = new MagicXattrManager(this, hide_magic_xattrs);
1771 
1772 
1773  if (options_mgr_->GetValue("CVMFS_ENFORCE_ACLS", &optarg)
1774  && options_mgr_->IsOn(optarg))
1775  {
1776  enforce_acls_ = true;
1777  }
1778 
1779  if (options_mgr_->GetValue("CVMFS_TALK_SOCKET", &optarg)) {
1780  talk_socket_path_ = optarg;
1781  }
1782  if (options_mgr_->GetValue("CVMFS_TALK_OWNER", &optarg)) {
1783  bool retval = GetUidOf(optarg, &talk_socket_uid_, &talk_socket_gid_);
1784  if (!retval) {
1785  boot_error_ = "unknown owner of cvmfs_talk socket: " + optarg;
1787  return false;
1788  }
1789  }
1790 
1791  return true;
1792 }
1793 
1794 
1800  string optarg;
1801  unsigned dns_timeout_ms = download::DownloadManager::kDnsDefaultTimeoutMs;
1802  unsigned dns_retries = download::DownloadManager::kDnsDefaultRetries;
1803  if (options_mgr_->GetValue("CVMFS_DNS_TIMEOUT", &optarg))
1804  dns_timeout_ms = String2Uint64(optarg) * 1000;
1805  if (options_mgr_->GetValue("CVMFS_DNS_RETRIES", &optarg))
1806  dns_retries = String2Uint64(optarg);
1807  manager->SetDnsParameters(dns_retries, dns_timeout_ms);
1808 
1809  // Rest has to be after SetDnsParameters because SetDnsParameters might
1810  // construct a new resolver object
1811 
1812  unsigned dns_min_ttl = dns::Resolver::kDefaultMinTtl;
1813  unsigned dns_max_ttl = dns::Resolver::kDefaultMaxTtl;
1814  if (options_mgr_->GetValue("CVMFS_DNS_MIN_TTL", &optarg))
1815  dns_min_ttl = String2Uint64(optarg);
1816  if (options_mgr_->GetValue("CVMFS_DNS_MAX_TTL", &optarg))
1817  dns_max_ttl = String2Uint64(optarg);
1818  manager->SetDnsTtlLimits(dns_min_ttl, dns_max_ttl);
1819 
1820  if (options_mgr_->GetValue("CVMFS_DNS_SERVER", &optarg)) {
1821  download_mgr_->SetDnsServer(optarg);
1822  }
1823 
1824  if (options_mgr_->GetValue("CVMFS_IPFAMILY_PREFER", &optarg)) {
1825  switch (String2Int64(optarg)) {
1826  case 4:
1828  break;
1829  case 6:
1831  break;
1832  }
1833  }
1834  if (options_mgr_->GetValue("CVMFS_MAX_IPADDR_PER_PROXY", &optarg))
1835  manager->SetMaxIpaddrPerProxy(String2Uint64(optarg));
1836 }
1837 
1838 
1840  string optarg;
1842  download_mgr_->Clone(perf::StatisticsTemplate("download-external",
1843  statistics_));
1844 
1845  unsigned timeout;
1846  unsigned timeout_direct;
1847  download_mgr_->GetTimeout(&timeout, &timeout_direct);
1848  if (options_mgr_->GetValue("CVMFS_EXTERNAL_TIMEOUT", &optarg)) {
1849  timeout = String2Uint64(optarg);
1850  }
1851  if (options_mgr_->GetValue("CVMFS_EXTERNAL_TIMEOUT_DIRECT", &optarg)) {
1852  timeout_direct = String2Uint64(optarg);
1853  }
1854  external_download_mgr_->SetTimeout(timeout, timeout_direct);
1855 
1856  if (options_mgr_->GetValue("CVMFS_EXTERNAL_URL", &optarg)) {
1858  if (dogeosort) {
1859  std::vector<std::string> host_chain;
1860  external_download_mgr_->GetHostInfo(&host_chain, NULL, NULL);
1861  download_mgr_->GeoSortServers(&host_chain);
1862  external_download_mgr_->SetHostChain(host_chain);
1863  }
1864  } else {
1866  }
1867 
1868  if (options_mgr_->GetValue("CVMFS_EXTERNAL_MAX_SERVERS", &optarg)) {
1869  unsigned max_servers = String2Uint64(optarg);
1870  std::vector<std::string> host_chain;
1871  external_download_mgr_->GetHostInfo(&host_chain, NULL, NULL);
1872  if (max_servers > 0 && max_servers < host_chain.size()) {
1873  host_chain.resize(max_servers);
1874  external_download_mgr_->SetHostChain(host_chain);
1875  }
1876  }
1877 
1878  string proxies = "DIRECT";
1879  if (options_mgr_->GetValue("CVMFS_EXTERNAL_HTTP_PROXY", &optarg)) {
1881  optarg,
1882  file_system_->workspace() + "/proxies-external" + GetUniqFileSuffix(),
1884  if (proxies == "") {
1885  boot_error_ = "failed to discover external HTTP proxy servers";
1887  return false;
1888  }
1889  }
1890  string fallback_proxies;
1891  if (options_mgr_->GetValue("CVMFS_EXTERNAL_FALLBACK_PROXY", &optarg))
1892  fallback_proxies = optarg;
1894  proxies, fallback_proxies, download::DownloadManager::kSetProxyBoth);
1895 
1896  return true;
1897 }
1898 
1899 
1901  string optarg;
1902 
1903  // TODO(jblomer): avoid double default settings
1904 
1905  unsigned timeout = kDefaultTimeoutSec;
1906  unsigned timeout_direct = kDefaultTimeoutSec;
1907  if (options_mgr_->GetValue("CVMFS_TIMEOUT", &optarg))
1908  timeout = String2Uint64(optarg);
1909  if (options_mgr_->GetValue("CVMFS_TIMEOUT_DIRECT", &optarg))
1910  timeout_direct = String2Uint64(optarg);
1911  download_mgr_->SetTimeout(timeout, timeout_direct);
1912 
1913  unsigned max_retries = kDefaultRetries;
1914  unsigned backoff_init = kDefaultBackoffInitMs;
1915  unsigned backoff_max = kDefaultBackoffMaxMs;
1916  if (options_mgr_->GetValue("CVMFS_MAX_RETRIES", &optarg))
1917  max_retries = String2Uint64(optarg);
1918  if (options_mgr_->GetValue("CVMFS_BACKOFF_INIT", &optarg))
1919  backoff_init = String2Uint64(optarg) * 1000;
1920  if (options_mgr_->GetValue("CVMFS_BACKOFF_MAX", &optarg))
1921  backoff_max = String2Uint64(optarg) * 1000;
1922  download_mgr_->SetRetryParameters(max_retries, backoff_init, backoff_max);
1923 
1924  if (options_mgr_->GetValue("CVMFS_LOW_SPEED_LIMIT", &optarg))
1926  if (options_mgr_->GetValue("CVMFS_PROXY_RESET_AFTER", &optarg))
1928  if (options_mgr_->GetValue("CVMFS_HOST_RESET_AFTER", &optarg))
1930 
1931  if (options_mgr_->GetValue("CVMFS_FOLLOW_REDIRECTS", &optarg) &&
1932  options_mgr_->IsOn(optarg))
1933  {
1935  }
1936  if (options_mgr_->GetValue("CVMFS_SEND_INFO_HEADER", &optarg) &&
1937  options_mgr_->IsOn(optarg))
1938  {
1940  }
1941 }
1942 
1943 
1945  string optarg;
1946 
1947  if (file_system_->IsNfsSource()) {
1949  } else {
1951  }
1952  if (options_mgr_->GetValue("CVMFS_INITIAL_GENERATION", &optarg)) {
1954  }
1955 
1958  }
1959 }
1960 
1961 
1963  string optarg;
1964  catalog::OwnerMap uid_map;
1965  catalog::OwnerMap gid_map;
1966 
1967  if (options_mgr_->GetValue("CVMFS_UID_MAP", &optarg)) {
1968  if (!uid_map.Read(optarg)) {
1969  boot_error_ = "failed to parse uid map " + optarg;
1971  return false;
1972  }
1973  }
1974  if (options_mgr_->GetValue("CVMFS_GID_MAP", &optarg)) {
1975  if (!gid_map.Read(optarg)) {
1976  boot_error_ = "failed to parse gid map " + optarg;
1978  return false;
1979  }
1980  }
1981  catalog_mgr_->SetOwnerMaps(uid_map, gid_map);
1982 
1983  // TODO(jblomer): make local to catalog manager
1984  if (options_mgr_->GetValue("CVMFS_CLAIM_OWNERSHIP", &optarg) &&
1985  options_mgr_->IsOn(optarg))
1986  {
1987  g_claim_ownership = true;
1988  }
1989 
1990  return true;
1991 }
IoErrorInfo io_error_info_
Definition: mountpoint.h:316
OptionsManager * options_mgr()
Definition: mountpoint.h:223
#define LogCvmfs(source, mask,...)
Definition: logging.h:20
std::string exe_path()
Definition: mountpoint.h:196
static const unsigned kDnsDefaultTimeoutMs
Definition: download.h:393
bool GetVOMSAuthz(std::string *authz) const
void SetLogSyslogFacility(const int local_facility)
Definition: logging.cc:182
FileSystem * file_system_
Definition: mountpoint.h:542
Counter * Register(const std::string &name, const std::string &desc)
Definition: statistics.cc:139
void SetCounter(perf::Counter *c)
Definition: mountpoint.cc:95
void RegisterFdMapping(int from, int to)
Definition: sqlitevfs.cc:541
std::string nfs_maps_dir_
Definition: mountpoint.h:373
void SetLogSyslogLevel(const int level)
Definition: logging.cc:150
bool IsNull() const
Definition: hash.h:382
bool foreground_
Definition: mountpoint.h:304
void Activate(const int buffer_size, const int flush_threshold, const std::string &trace_file)
Definition: tracer.cc:25
download::DownloadManager * download_mgr_
Definition: repository.h:140
struct stat64 platform_stat64
Log2Histogram * hist_fs_forget_multi_
Definition: mountpoint.h:321
void SetupInodeAnnotation()
Definition: mountpoint.cc:1944
bool SetupCwd()
Definition: mountpoint.cc:775
catalog::InodeAnnotation * inode_annotation_
Definition: mountpoint.h:558
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:539
std::string workspace_fullpath_
Definition: mountpoint.h:343
bool DetermineNfsMode()
Definition: mountpoint.cc:341
static SqliteHistory * Open(const std::string &file_name)
void SetHostChain(const std::string &host_list)
static const unsigned kTracerFlushThreshold
Definition: mountpoint.h:509
vector< string > SplitString(const string &str, const char delim, const unsigned max_chunks)
Definition: string.cc:288
virtual uint64_t GetSize()
Definition: quota_posix.cc:674
static Publisher * Create(const SettingsPublisher &settings)
uid_t talk_socket_uid_
Definition: mountpoint.h:585
void SetLowSpeedLimit(const unsigned low_speed_limit)
Definition: download.cc:1887
Log2Histogram * hist_fs_opendir_
Definition: mountpoint.h:324
bool LockWorkspace()
Definition: mountpoint.cc:451
bool CreateTracer()
Definition: mountpoint.cc:1487
bool wait_workspace_
Definition: mountpoint.h:303
virtual bool Cleanup(const uint64_t leave_size)
Definition: quota_posix.cc:125
double kcache_timeout_sec_
Definition: mountpoint.h:574
signature::SignatureManager * signature_mgr_
Definition: mountpoint.h:553
void CreateFile(const std::string &path, const int mode, const bool ignore_failure)
Definition: posix.cc:313
perf::Counter * n_fs_lookup_
Definition: mountpoint.h:308
std::string name
Definition: history.h:113
AuthzSessionManager * authz_session_mgr_
Definition: mountpoint.h:550
static const unsigned kDefaultRetries
Definition: mountpoint.h:502
string JoinStrings(const vector< string > &strings, const string &joint)
Definition: string.cc:318
perf::Statistics * statistics_
Definition: mountpoint.h:317
download::DownloadManager * download_mgr_
Definition: mountpoint.h:554
static const unsigned kDefaultTimeoutSec
Definition: mountpoint.h:501
std::string exe_path_
Definition: mountpoint.h:297
bool CheckInstanceName(const std::string &instance)
Definition: mountpoint.cc:107
perf::Statistics * statistics_
Definition: mountpoint.h:548
Log2Histogram * hist_fs_readlink_
Definition: mountpoint.h:323
void SetProxyChain(const std::string &proxy_list, const std::string &fallback_proxy_list, const ProxySetModes set_mode)
Definition: download.cc:2407
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:586
void SetupSqlite()
Definition: mountpoint.cc:975
bool IsOn(const std::string &param_value) const
Definition: options.cc:409
std::string GetUniqFileSuffix()
Definition: mountpoint.cc:1643
download::DownloadManager * external_download_mgr_
Definition: mountpoint.h:555
MagicXattrManager * magic_xattr_mgr_
Definition: mountpoint.h:568
CacheManager * SetupCacheMgr(const std::string &instance)
Definition: mountpoint.cc:560
const SettingsPublisher & settings() const
Definition: repository.h:314
perf::Statistics * statistics_
Definition: repository.h:138
void SetupHttpTuning()
Definition: mountpoint.cc:1900
static const char * kDefaultBlacklist
Definition: mountpoint.h:510
virtual bool AcquireQuotaManager(QuotaManager *quota_mgr)
Definition: cache_extern.cc:85
unsigned max_ttl_sec_
Definition: mountpoint.h:572
static const unsigned kDefaultMaxTtl
Definition: dns.h:182
bool CreateDownloadManagers()
Definition: mountpoint.cc:1278
std::string talk_socket_path_
Definition: mountpoint.h:584
perf::Counter * n_fs_stat_
Definition: mountpoint.h:310
perf::Counter * no_open_files_
Definition: mountpoint.h:314
assert((mem||(size==0))&&"Out Of Memory")
void SetupLogging()
Definition: mountpoint.cc:802
int fd_workspace_lock_
Definition: mountpoint.h:344
void CreateStatistics()
Definition: mountpoint.cc:1420
bool UnregisterVfsRdOnly()
Definition: sqlitevfs.cc:522
CacheManager * SetupRamCacheMgr(const std::string &instance)
Definition: mountpoint.cc:663
static void LogSqliteError(void *user_data __attribute__((unused)), int sqlite_extended_error, const char *message)
Definition: mountpoint.cc:482
static void CleanupInstance()
Definition: sqlitemem.cc:170
static const unsigned kNfsMaps
Definition: mountpoint.h:179
std::string workspace_
Definition: mountpoint.h:337
string StringifyTime(const time_t seconds, const bool utc)
Definition: string.cc:105
PosixCacheSettings DeterminePosixCacheSettings(const std::string &instance)
Definition: mountpoint.cc:264
void SetDnsServer(const std::string &address)
Definition: download.cc:1816
int platform_stat(const char *path, platform_stat64 *buf)
void AssignGlobalArenas()
Definition: sqlitemem.cc:137
bool has_membership_req_
Definition: mountpoint.h:582
virtual CacheManagerIds id()=0
void SetLogMicroSyslog(const std::string &filename)
Definition: logging.cc:267
void ReEvaluateAuthz()
Definition: mountpoint.cc:1734
file_watcher::FileWatcher * platform_file_watcher()
bool HasConfigRepository(const std::string &fqrn, std::string *config_path)
Definition: options.cc:256
std::set< std::string > constructed_instances_
Definition: mountpoint.h:372
bool DetermineRootHash(shash::Any *root_hash)
Definition: mountpoint.cc:1519
#define SetLogDebugFile(filename)
void SetTimeout(const unsigned seconds_proxy, const unsigned seconds_direct)
Definition: download.cc:1873
bool CreateCatalogManager()
Definition: mountpoint.cc:1221
glue::NentryTracker * nentry_tracker_
Definition: mountpoint.h:567
struct cvmcache_object_info __attribute__
Definition: atomic.h:24
void RemapCatalogFd(int from, int to)
Definition: mountpoint.cc:1069
static const unsigned kNfsNone
Definition: mountpoint.h:175
std::string path_crash_guard_
Definition: mountpoint.h:350
IntegerMap< uint64_t > OwnerMap
Definition: catalog.h:41
catalog::WritableCatalogManager * catalog_mgr_
Definition: repository.h:387
bool SetupWorkspace()
Definition: mountpoint.cc:992
static const char * kDefaultAuthzSearchPath
Definition: mountpoint.h:493
Type type()
Definition: mountpoint.h:225
FileSystem(const FileSystemInfo &fs_info)
Definition: mountpoint.cc:363
static const unsigned kLibPathCacheSize
Definition: mountpoint.h:481
std::string boot_error_
Definition: mountpoint.h:85
OptionsManager * options_mgr_
Definition: mountpoint.h:546
Log2Histogram * hist_fs_getattr_
Definition: mountpoint.h:322
bool IsValid(const std::string &input) const
Definition: sanitizer.cc:114
Log2Histogram * hist_fs_releasedir_
Definition: mountpoint.h:325
Definition: tracer.h:35
bool FileExists(const std::string &path)
Definition: posix.cc:816
bool LoadTrustedCaCrl(const std::string &path_list)
Definition: signature.cc:552
void SetDnsTtlLimits(const unsigned min_seconds, const unsigned max_seconds)
Definition: download.cc:1852
std::string cache_path()
Definition: cache_posix.h:105
perf::Counter * n_fs_readlink_
Definition: mountpoint.h:312
void Init(const unsigned max_pool_handles, const perf::StatisticsTemplate &statistics)
Definition: download.cc:1600
uint64_t platform_memsize()
int64_t String2Int64(const string &value)
Definition: string.cc:222
void SetMaxTtlMn(unsigned value_minutes)
Definition: mountpoint.cc:1744
static const unsigned kDefaultBackoffInitMs
Definition: mountpoint.h:503
perf::Counter * n_fs_forget_
Definition: mountpoint.h:313
MountPoint(const std::string &fqrn, FileSystem *file_system, OptionsManager *options_mgr)
Definition: mountpoint.cc:1648
void GetLimitNoFile(unsigned *soft_limit, unsigned *hard_limit)
Definition: posix.cc:1495
Tracer * tracer_
Definition: mountpoint.h:565
void SetProxyGroupResetDelay(const unsigned seconds)
Definition: download.cc:2704
static CacheManager * Create(CacheManager *upper_cache, CacheManager *lower_cache)
static bool g_alive
Definition: mountpoint.h:233
static const unsigned kDefaultNumConnections
Definition: mountpoint.h:497
void TearDown2ReadOnly()
Definition: mountpoint.cc:1056
gid_t g_gid
Definition: globals.cc:14
uuid_t uuid
Definition: uuid.h:39
static const unsigned kNfsMapsHa
Definition: mountpoint.h:183
lru::Md5PathCache * md5path_cache_
Definition: mountpoint.h:564
std::string name_
Definition: mountpoint.h:296
std::string Dump()
Definition: options.cc:447
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:581
perf::Counter * n_fs_read_
Definition: mountpoint.h:311
signature::SignatureManager * signature_mgr_
Definition: repository.h:139
static const char * kDefaultCacheMgrInstance
Definition: mountpoint.h:237
bool HasSuffix(const std::string &str, const std::string &suffix, const bool ignore_case)
Definition: string.cc:279
virtual uint64_t GetCapacity()
Definition: quota_posix.cc:582
bool found_previous_crash_
Definition: mountpoint.h:356
const char kSuffixCatalog
Definition: hash.h:53
loader::Failures boot_status_
Definition: mountpoint.h:84
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:1074
bool CheckPosixCacheSettings(const PosixCacheSettings &settings)
Definition: mountpoint.cc:124
bool IsNfsSource()
Definition: mountpoint.h:188
ChunkTables * chunk_tables_
Definition: mountpoint.h:560
CacheManager * cache_mgr()
Definition: mountpoint.h:194
uid_t g_uid
Definition: globals.cc:13
void SetupDnsTuning(download::DownloadManager *manager)
Definition: mountpoint.cc:1799
cvmfs::Uuid * uuid_cache_
Definition: mountpoint.h:383
unsigned GetEffectiveTtlSec()
Definition: mountpoint.cc:1621
int TryLockFile(const std::string &path)
Definition: posix.cc:938
bool MkdirDeep(const std::string &path, const mode_t mode, bool verify_writable)
Definition: posix.cc:871
Any MkFromHexPtr(const HexPtr hex, const char suffix)
Definition: hash.cc:83
int LockFile(const std::string &path)
Definition: posix.cc:996
void SetIpPreference(const dns::IpPreference preference)
Definition: download.cc:1862
static const unsigned kDefaultBackoffMaxMs
Definition: mountpoint.h:504
lru::InodeCache * inode_cache_
Definition: mountpoint.h:562
CacheManager * SetupPosixCacheMgr(const std::string &instance)
Definition: mountpoint.cc:633
perf::Counter * n_fs_open_
Definition: mountpoint.h:306
static uint64_t RoundUp8(const uint64_t size)
Definition: smalloc.h:37
bool SetupPosixQuotaMgr(const PosixCacheSettings &settings, CacheManager *cache_mgr)
Definition: mountpoint.cc:913
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:377
void SetRetryParameters(const unsigned max_retries, const unsigned backoff_init_ms, const unsigned backoff_max_ms)
Definition: download.cc:2723
string StringifyInt(const int64_t value)
Definition: string.cc:78
Type type_
Definition: mountpoint.h:298
static const unsigned kInodeCacheFactor
Definition: mountpoint.h:485
void SetMaxIpaddrPerProxy(unsigned limit)
Definition: download.cc:2734
DownloadManager * Clone(const perf::StatisticsTemplate &statistics)
Definition: download.cc:2767
void Inc(class Counter *counter)
Definition: statistics.h:50
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
Definition: string.cc:265
Log2Histogram * hist_fs_readdir_
Definition: mountpoint.h:326
bool GetValue(const std::string &key, std::string *value) const
Definition: options.cc:376
cvmfs::Uuid * uuid_
Definition: mountpoint.h:538
OptionsManager * options_mgr_
Definition: cvmfs.cc:145
bool LoadBlacklist(const std::string &path_blacklist, bool append)
Definition: signature.cc:508
BackoffThrottle * backoff_throttle_
Definition: mountpoint.h:552
AuthzAttachment * authz_attachment_
Definition: mountpoint.h:551
void SetProxyTemplates(const std::string &direct, const std::string &forced)
Definition: download.cc:2740
SimpleChunkTables * simple_chunk_tables_
Definition: mountpoint.h:561
bool InitFixed(const shash::Any &root_hash, bool alternative_path)
static const unsigned kDefaultNfiles
Definition: mountpoint.h:236
static FileSystem * Create(const FileSystemInfo &fs_info)
Definition: mountpoint.cc:164
bool has_custom_sqlitevfs_
Definition: mountpoint.h:394
bool ReloadBlacklists()
Definition: mountpoint.cc:1134
std::string name()
Definition: mountpoint.h:219
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:206
pthread_mutex_t lock_max_ttl_
Definition: mountpoint.h:573
void CreateAuthz()
Definition: mountpoint.cc:1195
bool g_raw_symlinks
Definition: globals.cc:12
static const char * kDefaultCacheBase
Definition: mountpoint.h:234
void SetNull()
Definition: hash.h:399
string ResolveProxyDescription(const string &cvmfs_proxies, const std::string &path_fallback_cache, DownloadManager *download_manager)
Definition: wpad.cc:206
uint64_t String2Uint64(const string &value)
Definition: string.cc:228
static const unsigned kTracerBufferSize
Definition: mountpoint.h:508
void SetupUuid()
Definition: mountpoint.cc:1041
catalog::ClientCatalogManager * catalog_mgr_
Definition: mountpoint.h:559
bool CreateSignatureManager()
Definition: mountpoint.cc:1384
std::string fqrn_
Definition: mountpoint.h:537
unsigned GetMaxTtlMn()
Definition: mountpoint.cc:1633
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:1369
bool SetupBehavior()
Definition: mountpoint.cc:1750
static ExternalCacheManager * Create(int fd_connection, unsigned max_open_fds, const std::string &ident)
AuthzFetcher * authz_fetcher_
Definition: mountpoint.h:549
bool FetchHistory(std::string *history_path)
Definition: mountpoint.cc:1587
perf::Statistics * statistics()
Definition: mountpoint.h:224
bool enforce_acls_
Definition: mountpoint.h:576
bool IsHaNfsSource()
Definition: mountpoint.h:189
void CreateTables()
Definition: mountpoint.cc:1448
shash::Any history() const
Definition: manifest.h:127
bool SetupCrashGuard()
Definition: mountpoint.cc:754
static const unsigned kDefaultQuotaLimit
Definition: mountpoint.h:235
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:552
Definition: mutex.h:42
Log2Histogram * hist_fs_lookup_
Definition: mountpoint.h:319
shash::Any root_hash
Definition: history.h:114
bool LoadPublicRsaKeys(const std::string &path_list)
Definition: signature.cc:277
void RegisterHandler(const std::string &file_path, EventHandler *handler)
Definition: file_watcher.cc:35
void GetTimeout(unsigned *seconds_proxy, unsigned *seconds_direct)
Definition: download.cc:1896
static const unsigned kDefaultMemcacheSize
Definition: mountpoint.h:489
FileSystem * file_system_
Definition: cvmfs.cc:120
std::string repository_tag_
Definition: mountpoint.h:577
static const unsigned kDefaultMinTtl
Definition: dns.h:177
bool SetupOwnerMaps()
Definition: mountpoint.cc:1962
void SetDnsParameters(const unsigned retries, const unsigned timeout_ms)
Definition: download.cc:1834
bool CreateResolvConfWatcher()
Definition: mountpoint.cc:1344
static ExternalQuotaManager * Create(ExternalCacheManager *cache_mgr)
Log2Histogram * hist_fs_read_
Definition: mountpoint.h:328
void SetCatalogWatermark(unsigned limit)
static bool g_is_enabled
Definition: algorithm.h:184
bool SetupNfsMaps()
Definition: mountpoint.cc:820
bool CheckBlacklists()
Definition: mountpoint.cc:1096
std::vector< std::string > blacklist_paths_
Definition: mountpoint.h:578
cvmfs::Fetcher * fetcher_
Definition: mountpoint.h:556
file_watcher::FileWatcher * resolv_conf_watcher_
Definition: mountpoint.h:570
static const unsigned kDnsDefaultRetries
Definition: download.h:392
bool GeoSortServers(std::vector< std::string > *servers, std::vector< uint64_t > *output_order=NULL)
Definition: download.cc:2126
bool SetupExternalDownloadMgr(bool dogeosort)
Definition: mountpoint.cc:1839
void SetOwnerMaps(const OwnerMap &uid_map, const OwnerMap &gid_map)
CacheManager * SetupExternalCacheMgr(const std::string &instance)
Definition: mountpoint.cc:594
static void CleanupInstance()
Definition: clientctx.cc:17
perf::Counter * n_fs_lookup_negative_
Definition: mountpoint.h:309
Log2Histogram * hist_fs_open_
Definition: mountpoint.h:327
virtual bool AcquireQuotaManager(QuotaManager *quota_mgr)=0
std::string cache_mgr_instance_
Definition: mountpoint.h:367
std::string path_workspace_lock_
Definition: mountpoint.h:345
virtual void IncGeneration(const uint64_t by)=0
Log2Histogram * hist_fs_release_
Definition: mountpoint.h:329
void SetLogSyslogPrefix(const std::string &prefix)
Definition: logging.cc:240
std::string MakeCanonicalPath(const std::string &path)
Definition: posix.cc:96
OptionsManager * options_mgr_
Definition: mountpoint.h:302
perf::Counter * no_open_dirs_
Definition: mountpoint.h:315
glue::InodeTracker * inode_tracker_
Definition: mountpoint.h:566
bool fixed_catalog_
Definition: mountpoint.h:575
static PluginHandle * CreatePlugin(const std::string &locator, const std::vector< std::string > &cmd_line)
bool IsDefined(const std::string &key)
Definition: options.cc:370
void GetHostInfo(std::vector< std::string > *host_chain, std::vector< int > *rtt, unsigned *current_host)
Definition: download.cc:1940
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:713
std::vector< std::string > FindFilesBySuffix(const std::string &dir, const std::string &suffix)
Definition: posix.cc:1149
std::string workspace()
Definition: mountpoint.h:227
bool g_claim_ownership
Definition: globals.cc:11
lru::PathCache * path_cache_
Definition: mountpoint.h:563
CacheManager * cache_mgr_
Definition: mountpoint.h:378
void SetCredentialsAttachment(CredentialsAttachment *ca)
Definition: download.cc:1800
static ClientCtx * GetInstance()
Definition: clientctx.cc:44
virtual bool AcquireQuotaManager(QuotaManager *quota_mgr)
Definition: cache_ram.cc:70
cvmfs::Uuid * uuid_cache()
Definition: mountpoint.h:226
cvmfs::Fetcher * external_fetcher_
Definition: mountpoint.h:557
perf::Counter * n_fs_dir_open_
Definition: mountpoint.h:307
static const uint64_t kSizeUnknown
Definition: cache.h:72
std::string MkCacheParm(const std::string &generic_parameter, const std::string &instance)
Definition: mountpoint.cc:517
void UnlockFile(const int filedes)
Definition: posix.cc:1020
NfsMaps * nfs_maps_
Definition: mountpoint.h:389
void CreateFetchers()
Definition: mountpoint.cc:1367
void SetInodeAnnotation(InodeAnnotation *new_annotation)
int Fetch(const shash::Any &id, const uint64_t size, const std::string &name, const zlib::Algorithms compression_algorithm, const CacheManager::ObjectType object_type, const std::string &alt_url="", off_t range_offset=-1)
Definition: fetch.cc:81
virtual void SetInodeResidue(unsigned residue_class, unsigned remainder)
Definition: nfs_maps.h:31
void SetHostResetDelay(const unsigned seconds)
Definition: download.cc:2714
static MountPoint * Create(const std::string &fqrn, FileSystem *file_system, OptionsManager *options_mgr=NULL)
Definition: mountpoint.cc:1155
Log2Histogram * hist_fs_forget_
Definition: mountpoint.h:320
static PosixCacheManager * Create(const std::string &cache_path, const bool alien_cache, const RenameWorkarounds rename_workaround=kRenameNormal)
Definition: cache_posix.cc:230