CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
catalog.cc
Go to the documentation of this file.
1 
5 #include "catalog.h"
6 
7 #include <alloca.h>
8 #include <errno.h>
9 
10 #include <algorithm>
11 #include <cassert>
12 
13 #include "catalog_mgr.h"
14 #include "util/concurrency.h"
15 #include "util/logging.h"
16 #include "util/platform.h"
17 #include "util/smalloc.h"
18 
19 using namespace std; // NOLINT
20 
21 namespace catalog {
22 
23 const shash::Md5 Catalog::kMd5PathEmpty("", 0);
24 
25 
29 Catalog* Catalog::AttachFreely(const string &imaginary_mountpoint,
30  const string &file,
31  const shash::Any &catalog_hash,
32  Catalog *parent,
33  const bool is_nested) {
34  Catalog *catalog =
35  new Catalog(PathString(imaginary_mountpoint.data(),
36  imaginary_mountpoint.length()),
37  catalog_hash,
38  parent,
39  is_nested);
40  const bool successful_init = catalog->InitStandalone(file);
41  if (!successful_init) {
42  delete catalog;
43  return NULL;
44  }
45  return catalog;
46 }
47 
48 
49 Catalog::Catalog(const PathString &mountpoint,
50  const shash::Any &catalog_hash,
51  Catalog *parent,
52  const bool is_nested) :
53  catalog_hash_(catalog_hash),
54  mountpoint_(mountpoint),
55  is_regular_mountpoint_(mountpoint_ == root_prefix_),
56  volatile_flag_(false),
57  is_root_(parent == NULL && !is_nested),
58  managed_database_(false),
59  parent_(parent),
60  nested_catalog_cache_dirty_(true),
61  voms_authz_status_(kVomsUnknown),
62  initialized_(false)
63 {
64  max_row_id_ = 0;
65  inode_annotation_ = NULL;
66  lock_ = reinterpret_cast<pthread_mutex_t *>(smalloc(sizeof(pthread_mutex_t)));
67  int retval = pthread_mutex_init(lock_, NULL);
68  assert(retval == 0);
69 
70  database_ = NULL;
71  uid_map_ = NULL;
72  gid_map_ = NULL;
73  sql_listing_ = NULL;
74  sql_lookup_md5path_ = NULL;
75  sql_lookup_nested_ = NULL;
76  sql_list_nested_ = NULL;
77  sql_own_list_nested_ = NULL;
78  sql_all_chunks_ = NULL;
79  sql_chunks_listing_ = NULL;
80  sql_lookup_xattrs_ = NULL;
81 }
82 
83 
85  pthread_mutex_destroy(lock_);
86  free(lock_);
88  delete database_;
89 }
90 
91 
107 }
108 
109 
111  delete sql_lookup_xattrs_;
112  delete sql_chunks_listing_;
113  delete sql_all_chunks_;
114  delete sql_listing_;
115  delete sql_lookup_md5path_;
116  delete sql_lookup_nested_;
117  delete sql_list_nested_;
118  delete sql_own_list_nested_;
119 }
120 
121 
122 bool Catalog::InitStandalone(const std::string &database_file) {
123  bool retval = OpenDatabase(database_file);
124  if (!retval) {
125  return false;
126  }
127 
129  inode_range.MakeDummy();
130  set_inode_range(inode_range);
131  return true;
132 }
133 
134 
136  assert(database_ != NULL);
137  bool statistics_loaded;
138  if (database().schema_version() <
140  {
141  statistics_loaded =
143  } else if (database().schema_revision() < 2) {
144  statistics_loaded =
146  } else if (database().schema_revision() < 3) {
147  statistics_loaded =
149  } else if (database().schema_revision() < 5) {
150  statistics_loaded =
152  } else {
153  statistics_loaded = counters_.ReadFromDatabase(database());
154  }
155  return statistics_loaded;
156 }
157 
158 
164 bool Catalog::OpenDatabase(const string &db_path) {
166  if (NULL == database_) {
167  return false;
168  }
169 
171  // Possible fix-up for database layout lacking the content hash of
172  // nested catalogs
173  SqlCatalog sql_has_nested_sha1(database(),
174  "SELECT count(*) FROM sqlite_master "
175  "WHERE type='table' AND name='nested_catalogs' AND sql LIKE '%sha1%';");
176  bool retval = sql_has_nested_sha1.FetchRow();
177  assert(retval == true);
178  bool has_nested_sha1 = sql_has_nested_sha1.RetrieveInt64(0);
179  if (!has_nested_sha1) {
180  database_->EnforceSchema(0.9, 0);
181  }
182  }
183 
185 
186  // Set the database file ownership if requested
187  if (managed_database_) {
189  }
190 
191  // Find out the maximum row id of this database file
192  SqlCatalog sql_max_row_id(database(), "SELECT MAX(rowid) FROM catalog;");
193  if (!sql_max_row_id.FetchRow()) {
195  "Cannot retrieve maximal row id for database file %s "
196  "(SqliteErrorcode: %d)",
197  db_path.c_str(), sql_max_row_id.GetLastError());
198  return false;
199  }
200  max_row_id_ = sql_max_row_id.RetrieveInt64(0);
201 
202  // Get root prefix
203  if (database_->HasProperty("root_prefix")) {
204  const std::string root_prefix =
205  database_->GetProperty<std::string>("root_prefix");
206  root_prefix_.Assign(root_prefix.data(), root_prefix.size());
208  "found root prefix %s in root catalog file %s",
209  root_prefix_.c_str(), db_path.c_str());
211  } else {
213  "no root prefix for root catalog file %s", db_path.c_str());
214  }
215 
216  // Get volatile content flag
217  volatile_flag_ = database_->GetPropertyDefault<bool>("volatile",
219 
220  // Read Catalog Counter Statistics
221  if (!ReadCatalogCounters()) {
223  "failed to load statistics counters for catalog %s (file %s)",
224  mountpoint_.c_str(), db_path.c_str());
225  return false;
226  }
227 
228  if (HasParent()) {
229  parent_->AddChild(this);
230  }
231 
232  initialized_ = true;
233  return true;
234 }
235 
236 
242  return shash::Md5(path.GetChars(), path.GetLength());
243 
244  assert(path.GetLength() >= mountpoint_.GetLength());
245  // Piecewise hash calculation: root_prefix plus tail of path
246  shash::Any result(shash::kMd5);
248  ctx.buffer = alloca(ctx.size);
249  shash::Init(ctx);
251  reinterpret_cast<const unsigned char *>(root_prefix_.GetChars()),
253  ctx);
255  reinterpret_cast<const unsigned char *>(path.GetChars()) +
257  path.GetLength() - mountpoint_.GetLength(),
258  ctx);
259  shash::Final(ctx, &result);
260  return result.CastToMd5();
261 }
262 
263 
269  return path;
270 
271  assert(path.GetLength() >= mountpoint_.GetLength());
272  PathString result = root_prefix_;
273  PathString suffix = path.Suffix(mountpoint_.GetLength());
274  result.Append(suffix.GetChars(), suffix.GetLength());
275  return result;
276 }
277 
278 
286  return path;
287 
288  assert(path.GetLength() >= root_prefix_.GetLength());
289  PathString result = mountpoint_;
290  PathString suffix = path.Suffix(root_prefix_.GetLength());
291  result.Append(suffix.GetChars(), suffix.GetLength());
292  return result;
293 }
294 
295 
303 bool Catalog::LookupEntry(const shash::Md5 &md5path, const bool expand_symlink,
304  DirectoryEntry *dirent) const
305 {
307 
310  bool found = sql_lookup_md5path_->FetchRow();
311  if (found && (dirent != NULL)) {
312  *dirent = sql_lookup_md5path_->GetDirent(this, expand_symlink);
313  FixTransitionPoint(md5path, dirent);
314  }
316 
317  return found;
318 }
319 
320 
327 bool Catalog::LookupMd5Path(const shash::Md5 &md5path,
328  DirectoryEntry *dirent) const
329 {
330  return LookupEntry(md5path, true, dirent);
331 }
332 
333 
335  LinkString *raw_symlink) const
336 {
337  DirectoryEntry dirent;
338  bool result = (LookupEntry(NormalizePath(path), false, &dirent));
339  if (result)
340  raw_symlink->Assign(dirent.symlink());
341  return result;
342 }
343 
344 
346  const shash::Md5 &md5path,
347  XattrList *xattrs) const
348 {
350 
353  bool found = sql_lookup_xattrs_->FetchRow();
354  if (found && (xattrs != NULL)) {
355  *xattrs = sql_lookup_xattrs_->GetXattrs();
356  }
358 
359  return found;
360 }
361 
362 
370  StatEntryList *listing) const
371 {
373 
374  DirectoryEntry dirent;
375  StatEntry entry;
376 
378  sql_listing_->BindPathHash(md5path);
379  while (sql_listing_->FetchRow()) {
380  dirent = sql_listing_->GetDirent(this);
381  if (dirent.IsHidden())
382  continue;
383  FixTransitionPoint(md5path, &dirent);
384  entry.name = dirent.name();
385  entry.info = dirent.GetStatStructure();
386  listing->PushBack(entry);
387  }
388  sql_listing_->Reset();
389 
390  return true;
391 }
392 
393 
403  DirectoryEntryList *listing,
404  const bool expand_symlink) const
405 {
407 
409 
410  sql_listing_->BindPathHash(md5path);
411  while (sql_listing_->FetchRow()) {
412  DirectoryEntry dirent = sql_listing_->GetDirent(this, expand_symlink);
413  FixTransitionPoint(md5path, &dirent);
414  listing->push_back(dirent);
415  }
416  sql_listing_->Reset();
417 
418  return true;
419 }
420 
421 
423  return sql_all_chunks_->Open();
424 }
425 
426 
428 {
429  return sql_all_chunks_->Next(hash, compression_alg);
430 }
431 
432 
434  return sql_all_chunks_->Close();
435 }
436 
437 
444  const shash::Algorithms interpret_hashes_as,
445  FileChunkList *chunks) const
446 {
447  assert(IsInitialized() && chunks->IsEmpty());
448 
450 
452  while (sql_chunks_listing_->FetchRow()) {
453  chunks->PushBack(sql_chunks_listing_->GetFileChunk(interpret_hashes_as));
454  }
456 
457  return true;
458 }
459 
460 
465  if (!referenced_hashes_.empty()) {
466  return referenced_hashes_;
467  }
468 
469  // retrieve all referenced content hashes of both files and file chunks
470  SqlListContentHashes list_content_hashes(database());
471  while (list_content_hashes.FetchRow()) {
472  referenced_hashes_.push_back(list_content_hashes.GetHash());
473  }
474 
475  return referenced_hashes_;
476 }
477 
478 
480  managed_database_ = true;
481  if (NULL != database_) {
483  }
484 }
485 
486 
488  managed_database_ = false;
489  if (NULL != database_) {
491  }
492 }
493 
494 
495 uint64_t Catalog::GetTTL() const {
497  return database().GetPropertyDefault<uint64_t>("TTL", kDefaultTTL);
498 }
499 
500 
503  return database().HasProperty("TTL");
504 }
505 
506 
507 bool Catalog::GetVOMSAuthz(string *authz) const {
508  bool result;
511  if (authz) {*authz = voms_authz_;}
512  result = true;
513  } else if (voms_authz_status_ == kVomsNone) {
514  result = false;
515  } else {
516  if (database().HasProperty("voms_authz")) {
517  voms_authz_ = database().GetProperty<string>("voms_authz");
518  if (authz) {*authz = voms_authz_;}
520  } else {
522  }
523  result = (voms_authz_status_ == kVomsPresent);
524  }
525  return result;
526 }
527 
528 uint64_t Catalog::GetRevision() const {
530  return database().GetPropertyDefault<uint64_t>("revision", 0);
531 }
532 
533 uint64_t Catalog::GetLastModified() const {
534  const std::string prop_name = "last_modified";
535  return (database().HasProperty(prop_name))
536  ? database().GetProperty<int>(prop_name)
537  : 0u;
538 }
539 
540 
541 uint64_t Catalog::GetNumChunks() const {
542  return counters_.Get("self_regular") + counters_.Get("self_chunks");
543 }
544 
545 
546 uint64_t Catalog::GetNumEntries() const {
547  const string sql = "SELECT count(*) FROM catalog;";
548 
550  SqlCatalog stmt(database(), sql);
551  return (stmt.FetchRow()) ? stmt.RetrieveInt64(0) : 0;
552 }
553 
554 
557  const std::string hash_string =
558  database().GetPropertyDefault<std::string>("previous_revision", "");
559  return (!hash_string.empty())
561  : shash::Any();
562 }
563 
564 
566  sqlite::MemStatistics stats;
567  {
569  database().GetMemStatistics(&stats);
570  }
571  return string(mountpoint().GetChars(), mountpoint().GetLength()) + ": " +
572  StringifyInt(stats.lookaside_slots_used) + " / " +
573  StringifyInt(stats.lookaside_slots_max) + " slots -- " +
574  StringifyInt(stats.lookaside_hit) + " hits, " +
575  StringifyInt(stats.lookaside_miss_size) + " misses-size, " +
576  StringifyInt(stats.lookaside_miss_full) + " misses-full -- " +
577  StringifyInt(stats.page_cache_used / 1024) + " kB pages -- " +
578  StringifyInt(stats.page_cache_hit) + " hits, " +
579  StringifyInt(stats.page_cache_miss) + " misses -- " +
580  StringifyInt(stats.schema_used / 1024) + " kB schema -- " +
581  StringifyInt(stats.stmt_used / 1024) + " kB statements";
582 }
583 
584 
593 inode_t Catalog::GetMangledInode(const uint64_t row_id,
594  const uint64_t hardlink_group) const {
596 
597  if (inode_range_.IsDummy()) {
599  }
600 
601  inode_t inode = row_id + inode_range_.offset;
602 
603  // Hardlinks are encoded in catalog-wide unique hard link group ids.
604  // These ids must be resolved to actual inode relationships at runtime.
605  if (hardlink_group > 0) {
606  HardlinkGroupMap::const_iterator inode_iter =
607  hardlink_groups_.find(hardlink_group);
608 
609  // Use cached entry if possible
610  if (inode_iter == hardlink_groups_.end()) {
611  hardlink_groups_[hardlink_group] = inode;
612  } else {
613  inode = inode_iter->second;
614  }
615  }
616 
617  if (inode_annotation_) {
618  inode = inode_annotation_->Annotate(inode);
619  }
620 
621  return inode;
622 }
623 
624 
632 
634  LogCvmfs(kLogCatalog, kLogDebug, "refreshing nested catalog cache of '%s'",
635  mountpoint().c_str());
636  while (sql_list_nested_->FetchRow()) {
637  NestedCatalog nested;
640  nested.size = sql_list_nested_->GetSize();
641  nested_catalog_cache_.push_back(nested);
642  }
645  }
646 
647  return nested_catalog_cache_;
648 }
649 
650 
657  NestedCatalogList result;
658 
660 
661  while (sql_own_list_nested_->FetchRow()) {
662  NestedCatalog nested;
665  nested.size = sql_own_list_nested_->GetSize();
666  result.push_back(nested);
667  }
669 
670  return result;
671 }
672 
673 
682  nested_catalog_cache_.clear();
684 }
685 
686 
690 bool Catalog::FindNested(const PathString &mountpoint,
691  shash::Any *hash, uint64_t *size) const
692 {
694  PathString normalized_mountpoint = NormalizePath2(mountpoint);
695  sql_lookup_nested_->BindSearchPath(normalized_mountpoint);
696  bool found = sql_lookup_nested_->FetchRow();
697  if (found && (hash != NULL)) {
699  *size = sql_lookup_nested_->GetSize();
700  }
702 
703  return found;
704 }
705 
706 
713  // Since annotated inodes could come back to the catalog in order to
714  // get stripped, exchanging the annotation is not allowed
715  assert((inode_annotation_ == NULL) || (inode_annotation_ == new_annotation));
716  inode_annotation_ = new_annotation;
717 }
718 
719 
720 void Catalog::SetOwnerMaps(const OwnerMap *uid_map, const OwnerMap *gid_map) {
721  uid_map_ = (uid_map && uid_map->HasEffect()) ? uid_map : NULL;
722  gid_map_ = (gid_map && gid_map->HasEffect()) ? gid_map : NULL;
723 }
724 
725 
731  assert(NULL == FindChild(child->mountpoint()));
732 
734  children_[child->mountpoint()] = child;
735  child->set_parent(this);
736 }
737 
738 
744  assert(NULL != FindChild(child->mountpoint()));
745 
747  child->set_parent(NULL);
748  children_.erase(child->mountpoint());
749 }
750 
751 
753  CatalogList result;
754 
756  for (NestedCatalogMap::const_iterator i = children_.begin(),
757  iEnd = children_.end(); i != iEnd; ++i)
758  {
759  result.push_back(i->second);
760  }
761 
762  return result;
763 }
764 
765 
774  // Check if this catalog fits the beginning of the path.
775  if (!path.StartsWith(mountpoint_))
776  return NULL;
777 
778  PathString remaining(path.Suffix(mountpoint_.GetLength()));
779  remaining.Append("/", 1);
780 
781  // now we recombine the path elements successively
782  // in order to find a child which serves a part of the path
783  PathString path_prefix(mountpoint_);
784  Catalog *result = NULL;
785  // Skip the first '/'
786  path_prefix.Append("/", 1);
787  const char *c = remaining.GetChars() + 1;
788  for (unsigned i = 1; i < remaining.GetLength(); ++i, ++c) {
789  if (*c == '/') {
790  result = FindChild(path_prefix);
791 
792  // If we found a child serving a part of the path we can stop searching.
793  // Remaining sub path elements are possibly served by a grand child.
794  if (result != NULL)
795  break;
796  }
797  path_prefix.Append(c, 1);
798  }
799 
800  return result;
801 }
802 
803 
808 Catalog* Catalog::FindChild(const PathString &mountpoint) const {
809  NestedCatalogMap::const_iterator nested_iter;
810 
812  nested_iter = children_.find(mountpoint);
813  Catalog* result =
814  (nested_iter == children_.end()) ? NULL : nested_iter->second;
815 
816  return result;
817 }
818 
819 
828  DirectoryEntry *dirent) const
829 {
830  if (!HasParent())
831  return;
832 
833  if (dirent->IsNestedCatalogRoot()) {
834  // Normal nested catalog
835  DirectoryEntry parent_dirent;
836  const bool retval = parent_->LookupMd5Path(md5path, &parent_dirent);
837  assert(retval);
838  dirent->set_inode(parent_dirent.inode());
839  } else if (md5path == kMd5PathEmpty) {
840  // Bind mountpoint
841  DirectoryEntry parent_dirent;
842  const bool retval = parent_->LookupPath(mountpoint_, &parent_dirent);
843  assert(retval);
844  dirent->set_inode(parent_dirent.inode());
845  }
846 }
847 
848 } // namespace catalog
bool BindSearchPath(const PathString &path)
Definition: catalog_sql.cc:909
InodeRange inode_range() const
Definition: catalog.h:182
PathString PlantPath(const PathString &path) const
Definition: catalog.cc:284
void DropFileOwnership()
Definition: sql_impl.h:350
struct stat info
shash::Any GetHash() const
Definition: catalog_sql.cc:626
SqlAllChunks * sql_all_chunks_
Definition: catalog.h:333
NestedCatalogMap children_
Definition: catalog.h:312
bool AllChunksNext(shash::Any *hash, zlib::Algorithms *compression_alg)
Definition: catalog.cc:427
HardlinkGroupMap hardlink_groups_
Definition: catalog.h:230
bool Reset()
Definition: sql.cc:126
struct cvmcache_context * ctx
string * mountpoint_
Definition: auto_umount.cc:26
void EnforceSchema(float version, unsigned revision)
Definition: sql.h:227
int page_cache_used
Bytes used for caching pages.
Definition: sql.h:35
void set_inode(const inode_t inode)
bool FetchRow()
Definition: sql.cc:62
CatalogDatabase * database_
Definition: catalog.h:291
NestedCatalogList nested_catalog_cache_
Definition: catalog.h:313
bool IsHidden() const
ShortString Suffix(const unsigned start_at) const
Definition: shortstring.h:198
bool BindPathHash(const shash::Md5 &hash)
bool HasParent() const
Definition: catalog.h:200
bool LookupXattrsMd5Path(const shash::Md5 &md5path, XattrList *xattrs) const
Definition: catalog.cc:345
const OwnerMap * gid_map_
Definition: catalog.h:326
bool OpenDatabase(const std::string &db_path)
Definition: catalog.cc:164
const OwnerMap * uid_map_
Definition: catalog.h:325
void Assign(const char *chars, const unsigned length)
Definition: shortstring.h:61
SqlOwnNestedCatalogListing * sql_own_list_nested_
Definition: catalog.h:332
void MakeDummy()
Definition: catalog.h:59
void TakeFileOwnership()
Definition: sql_impl.h:342
PathString NormalizePath2(const PathString &path) const
Definition: catalog.cc:267
Catalog * parent_
Definition: catalog.h:311
int lookaside_miss_size
Definition: sql.h:33
bool LookupPath(const PathString &path, DirectoryEntry *dirent) const
Definition: catalog.h:124
static const shash::Md5 kMd5PathEmpty
Definition: catalog.h:264
DirectoryEntry GetDirent(const Catalog *catalog, const bool expand_symlink=true) const
Definition: catalog_sql.cc:696
bool AllChunksBegin()
Definition: catalog.cc:422
NameString name
bool managed_database_
Definition: catalog.h:309
int lookaside_slots_used
Definition: sql.h:30
Catalog * FindSubtree(const PathString &path) const
Definition: catalog.cc:773
virtual void InitPreparedStatements()
Definition: catalog.cc:98
pthread_mutex_t * lock_
Definition: catalog.h:232
inode_t inode() const
shash::Any GetPreviousRevision() const
Definition: catalog.cc:555
uint64_t inode_t
uint64_t GetTTL() const
Definition: catalog.cc:495
assert((mem||(size==0))&&"Out Of Memory")
float schema_version() const
Definition: sql.h:149
shash::Any GetContentHash() const
Definition: catalog_sql.cc:914
CatalogList GetChildren() const
Definition: catalog.cc:752
bool InitStandalone(const std::string &database_file)
Definition: catalog.cc:122
int stmt_used
Bytes used for prepared statmements (lookaside + heap)
Definition: sql.h:39
std::string PrintMemStatistics() const
Definition: catalog.cc:565
bool ListMd5PathChunks(const shash::Md5 &md5path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks) const
Definition: catalog.cc:443
Catalog * FindChild(const PathString &mountpoint) const
Definition: catalog.cc:808
void SetInodeAnnotation(InodeAnnotation *new_annotation)
Definition: catalog.cc:711
bool IsDummy() const
Definition: catalog.h:62
const NestedCatalogList & ListNestedCatalogs() const
Definition: catalog.cc:630
SqlLookupXattrs * sql_lookup_xattrs_
Definition: catalog.h:335
bool ListingMd5Path(const shash::Md5 &md5path, DirectoryEntryList *listing, const bool expand_symlink=true) const
Definition: catalog.cc:402
bool LookupEntry(const shash::Md5 &md5path, const bool expand_symlink, DirectoryEntry *dirent) const
Definition: catalog.cc:303
static DerivedT * Open(const std::string &filename, const OpenMode open_mode)
Definition: sql_impl.h:73
IntegerMap< uint64_t > OwnerMap
Definition: catalog.h:41
void FinalizePreparedStatements()
Definition: catalog.cc:110
T GetProperty(const std::string &key) const
Definition: sql_impl.h:305
SqlListing * sql_listing_
Definition: catalog.h:328
InodeRange inode_range_
Definition: catalog.h:320
PathString root_prefix_
Definition: catalog.h:294
void Init(ContextPtr context)
Definition: hash.cc:164
T GetPropertyDefault(const std::string &key, const T default_value) const
Definition: sql_impl.h:317
InodeAnnotation * inode_annotation_
Definition: catalog.h:322
bool GetVOMSAuthz(std::string *authz) const
Definition: catalog.cc:507
Algorithms
Definition: hash.h:41
std::vector< shash::Any > HashVector
Definition: catalog.h:97
bool IsNestedCatalogRoot() const
uint64_t GetNumEntries() const
Definition: catalog.cc:546
uint64_t GetRevision() const
Definition: catalog.cc:528
std::vector< DirectoryEntry > DirectoryEntryList
int GetLastError() const
Definition: sql.h:343
NameString name() const
uint64_t GetLastModified() const
Definition: catalog.cc:533
Algorithms
Definition: compression.h:44
bool HasExplicitTTL() const
Definition: catalog.cc:501
bool AllChunksEnd()
Definition: catalog.cc:433
virtual CatalogDatabase::OpenMode DatabaseOpenMode() const
Definition: catalog.h:240
void set_parent(Catalog *catalog)
Definition: catalog.h:251
bool Next(shash::Any *hash, zlib::Algorithms *compression_alg)
SqlNestedCatalogListing * sql_list_nested_
Definition: catalog.h:331
static const float kSchemaEpsilon
Definition: sql.h:105
const HashVector & GetReferencedObjects() const
Definition: catalog.cc:464
bool LookupMd5Path(const shash::Md5 &md5path, DirectoryEntry *dirent) const
Definition: catalog.cc:327
void AddChild(Catalog *child)
Definition: catalog.cc:730
shash::Md5 NormalizePath(const PathString &path) const
Definition: catalog.cc:240
const char kSuffixCatalog
Definition: hash.h:54
void FixTransitionPoint(const shash::Md5 &md5path, DirectoryEntry *dirent) const
Definition: catalog.cc:827
void ResetNestedCatalogCacheUnprotected()
Definition: catalog.cc:681
sqlite3_int64 RetrieveInt64(const int idx_column) const
Definition: sql.h:445
LinkString symlink() const
bool ListingMd5PathStat(const shash::Md5 &md5path, StatEntryList *listing) const
Definition: catalog.cc:369
PathString mountpoint() const
Definition: catalog.h:179
void Final(ContextPtr context, Any *any_digest)
Definition: hash.cc:221
bool BindPathHash(const shash::Md5 &hash)
bool BindPathHash(const struct shash::Md5 &hash)
Definition: catalog_sql.cc:788
static const inode_t kInvalidInode
void Append(const char *chars, const unsigned length)
Definition: shortstring.h:80
PathString mountpoint_
Definition: catalog.h:299
void TakeDatabaseFileOwnership()
Definition: catalog.cc:479
string StringifyInt(const int64_t value)
Definition: string.cc:78
SqlLookupPathHash * sql_lookup_md5path_
Definition: catalog.h:329
bool ReadFromDatabase(const CatalogDatabase &database, const LegacyMode::Type legacy=LegacyMode::kNoLegacy)
void * buffer
Definition: hash.h:501
int page_cache_miss
Definition: sql.h:37
void RemoveChild(Catalog *child)
Definition: catalog.cc:743
bool BindPathHash(const struct shash::Md5 &hash)
Definition: catalog_sql.cc:774
PathString root_prefix() const
Definition: catalog.h:185
std::vector< Catalog * > CatalogList
Definition: catalog.h:38
bool is_regular_mountpoint_
Definition: catalog.h:303
bool IsEmpty() const
Definition: bigvector.h:72
bool HasProperty(const std::string &key) const
Definition: sql_impl.h:293
bool IsInitialized() const
Definition: catalog.h:190
void PushBack(const Item &item)
Definition: bigvector.h:60
void set_inode_range(const InodeRange value)
Definition: catalog.h:183
bool IsEqualSchema(const float value, const float compare) const
Definition: sql.h:131
inode_t GetMangledInode(const uint64_t row_id, const uint64_t hardlink_group) const
Definition: catalog.cc:593
std::vector< NestedCatalog > NestedCatalogList
Definition: catalog.h:208
void Update(const unsigned char *buffer, const unsigned buffer_length, ContextPtr context)
Definition: hash.cc:190
const NestedCatalogList ListOwnNestedCatalogs() const
Definition: catalog.cc:656
SqlChunksListing * sql_chunks_listing_
Definition: catalog.h:334
shash::Any GetContentHash() const
Definition: catalog_sql.cc:969
FileChunk GetFileChunk(const shash::Algorithms interpret_hash_as) const
virtual inode_t Annotate(const inode_t raw_inode)=0
ShortString< kDefaultMaxPath, 0 > PathString
Definition: shortstring.h:217
virtual ~Catalog()
Definition: catalog.cc:84
Definition: mutex.h:42
int schema_used
Bytes used to store db schema.
Definition: sql.h:38
uint64_t GetNumChunks() const
Definition: catalog.cc:541
void SetOwnerMaps(const OwnerMap *uid_map, const OwnerMap *gid_map)
Definition: catalog.cc:720
HashVector referenced_hashes_
Definition: catalog.h:337
const CatalogDatabase & database() const
Definition: catalog.h:249
FieldT Get(const std::string &key) const
bool FindNested(const PathString &mountpoint, shash::Any *hash, uint64_t *size) const
Definition: catalog.cc:690
std::string voms_authz_
Definition: catalog.h:317
int lookaside_miss_full
Definition: sql.h:34
Any MkFromHexPtr(const HexPtr hex, const char suffix)
Definition: hash.cc:83
bool LookupRawSymlink(const PathString &path, LinkString *raw_symlink) const
Definition: catalog.cc:334
bool StartsWith(const ShortString &other) const
Definition: shortstring.h:189
int page_cache_hit
Definition: sql.h:36
bool ReadCatalogCounters()
Definition: catalog.cc:135
void DropDatabaseFileOwnership()
Definition: catalog.cc:487
static const float kLatestSupportedSchema
Definition: catalog_sql.h:44
int lookaside_slots_max
Definition: sql.h:31
void GetMemStatistics(MemStatistics *stats) const
Definition: sql_impl.h:368
unsigned GetLength() const
Definition: shortstring.h:131
unsigned size
Definition: hash.h:502
bool initialized_
Definition: catalog.h:319
uint64_t max_row_id_
Definition: catalog.h:321
uint64_t offset
Definition: catalog.h:50
const char * c_str() const
Definition: shortstring.h:145
bool volatile_flag_
Definition: catalog.h:304
const char * GetChars() const
Definition: shortstring.h:123
static void size_t size
Definition: smalloc.h:54
bool nested_catalog_cache_dirty_
Definition: catalog.h:314
SqlNestedCatalogLookup * sql_lookup_nested_
Definition: catalog.h:330
VomsAuthzStatus voms_authz_status_
Definition: catalog.h:316
static const uint64_t kDefaultTTL
Definition: catalog.h:104
Counters counters_
Definition: catalog.h:323
struct stat GetStatStructure() const
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
Definition: logging.cc:528