CernVM-FS  2.13.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 = new Catalog(
35  PathString(imaginary_mountpoint.data(), imaginary_mountpoint.length()),
36  catalog_hash,
37  parent,
38  is_nested);
39  const bool successful_init = catalog->InitStandalone(file);
40  if (!successful_init) {
41  delete catalog;
42  return NULL;
43  }
44  return catalog;
45 }
46 
47 
48 Catalog::Catalog(const PathString &mountpoint,
49  const shash::Any &catalog_hash,
50  Catalog *parent,
51  const bool is_nested)
52  : catalog_hash_(catalog_hash)
53  , mountpoint_(mountpoint)
54  , is_regular_mountpoint_(mountpoint_ == root_prefix_)
55  , volatile_flag_(false)
56  , is_root_(parent == NULL && !is_nested)
57  , managed_database_(false)
58  , parent_(parent)
59  , nested_catalog_cache_dirty_(true)
60  , voms_authz_status_(kVomsUnknown)
61  , initialized_(false) {
62  max_row_id_ = 0;
63  inode_annotation_ = NULL;
64  lock_ = reinterpret_cast<pthread_mutex_t *>(smalloc(sizeof(pthread_mutex_t)));
65  int retval = pthread_mutex_init(lock_, NULL);
66  assert(retval == 0);
67 
68  database_ = NULL;
69  uid_map_ = NULL;
70  gid_map_ = NULL;
71  sql_listing_ = NULL;
72  sql_lookup_md5path_ = NULL;
73  sql_lookup_nested_ = NULL;
74  sql_list_nested_ = NULL;
75  sql_own_list_nested_ = NULL;
76  sql_all_chunks_ = NULL;
77  sql_chunks_listing_ = NULL;
78  sql_lookup_xattrs_ = NULL;
79 }
80 
81 
83  pthread_mutex_destroy(lock_);
84  free(lock_);
86  delete database_;
87 }
88 
89 
105 }
106 
107 
109  delete sql_lookup_xattrs_;
110  delete sql_chunks_listing_;
111  delete sql_all_chunks_;
112  delete sql_listing_;
113  delete sql_lookup_md5path_;
114  delete sql_lookup_nested_;
115  delete sql_list_nested_;
116  delete sql_own_list_nested_;
117 }
118 
119 
120 bool Catalog::InitStandalone(const std::string &database_file) {
121  bool retval = OpenDatabase(database_file);
122  if (!retval) {
123  return false;
124  }
125 
127  inode_range.MakeDummy();
128  set_inode_range(inode_range);
129  return true;
130 }
131 
132 
134  assert(database_ != NULL);
135  bool statistics_loaded;
136  if (database().schema_version() < CatalogDatabase::kLatestSupportedSchema
138  statistics_loaded = counters_.ReadFromDatabase(database(),
140  } else if (database().schema_revision() < 2) {
141  statistics_loaded = counters_.ReadFromDatabase(database(),
143  } else if (database().schema_revision() < 3) {
144  statistics_loaded = counters_.ReadFromDatabase(database(),
146  } else if (database().schema_revision() < 5) {
147  statistics_loaded = counters_.ReadFromDatabase(database(),
149  } else {
150  statistics_loaded = counters_.ReadFromDatabase(database());
151  }
152  return statistics_loaded;
153 }
154 
155 
161 bool Catalog::OpenDatabase(const string &db_path) {
163  if (NULL == database_) {
164  return false;
165  }
166 
168  // Possible fix-up for database layout lacking the content hash of
169  // nested catalogs
170  SqlCatalog sql_has_nested_sha1(
171  database(),
172  "SELECT count(*) FROM sqlite_master "
173  "WHERE type='table' AND name='nested_catalogs' AND sql LIKE '%sha1%';");
174  bool retval = sql_has_nested_sha1.FetchRow();
175  assert(retval == true);
176  bool has_nested_sha1 = sql_has_nested_sha1.RetrieveInt64(0);
177  if (!has_nested_sha1) {
178  database_->EnforceSchema(0.9, 0);
179  }
180  }
181 
183 
184  // Set the database file ownership if requested
185  if (managed_database_) {
187  }
188 
189  // Find out the maximum row id of this database file
190  SqlCatalog sql_max_row_id(database(), "SELECT MAX(rowid) FROM catalog;");
191  if (!sql_max_row_id.FetchRow()) {
193  "Cannot retrieve maximal row id for database file %s "
194  "(SqliteErrorcode: %d)",
195  db_path.c_str(), sql_max_row_id.GetLastError());
196  return false;
197  }
198  max_row_id_ = sql_max_row_id.RetrieveInt64(0);
199 
200  // Get root prefix
201  if (database_->HasProperty("root_prefix")) {
202  const std::string root_prefix = database_->GetProperty<std::string>(
203  "root_prefix");
204  root_prefix_.Assign(root_prefix.data(), root_prefix.size());
206  "found root prefix %s in root catalog file %s",
207  root_prefix_.c_str(), db_path.c_str());
209  } else {
210  LogCvmfs(kLogCatalog, kLogDebug, "no root prefix for root catalog file %s",
211  db_path.c_str());
212  }
213 
214  // Get volatile content flag
215  volatile_flag_ = database_->GetPropertyDefault<bool>("volatile",
217 
218  // Read Catalog Counter Statistics
219  if (!ReadCatalogCounters()) {
221  "failed to load statistics counters for catalog %s (file %s)",
222  mountpoint_.c_str(), db_path.c_str());
223  return false;
224  }
225 
226  if (HasParent()) {
227  parent_->AddChild(this);
228  }
229 
230  initialized_ = true;
231  return true;
232 }
233 
234 
240  return shash::Md5(path.GetChars(), path.GetLength());
241 
242  assert(path.GetLength() >= mountpoint_.GetLength());
243  // Piecewise hash calculation: root_prefix plus tail of path
244  shash::Any result(shash::kMd5);
246  ctx.buffer = alloca(ctx.size);
247  shash::Init(ctx);
249  reinterpret_cast<const unsigned char *>(root_prefix_.GetChars()),
251  ctx);
252  shash::Update(reinterpret_cast<const unsigned char *>(path.GetChars())
254  path.GetLength() - mountpoint_.GetLength(),
255  ctx);
256  shash::Final(ctx, &result);
257  return result.CastToMd5();
258 }
259 
260 
266  return path;
267 
268  assert(path.GetLength() >= mountpoint_.GetLength());
269  PathString result = root_prefix_;
270  PathString suffix = path.Suffix(mountpoint_.GetLength());
271  result.Append(suffix.GetChars(), suffix.GetLength());
272  return result;
273 }
274 
275 
283  return path;
284 
285  assert(path.GetLength() >= root_prefix_.GetLength());
286  PathString result = mountpoint_;
287  PathString suffix = path.Suffix(root_prefix_.GetLength());
288  result.Append(suffix.GetChars(), suffix.GetLength());
289  return result;
290 }
291 
292 
300 bool Catalog::LookupEntry(const shash::Md5 &md5path, const bool expand_symlink,
301  DirectoryEntry *dirent) const {
303 
306  bool found = sql_lookup_md5path_->FetchRow();
307  if (found && (dirent != NULL)) {
308  *dirent = sql_lookup_md5path_->GetDirent(this, expand_symlink);
309  FixTransitionPoint(md5path, dirent);
310  }
312 
313  return found;
314 }
315 
316 
323 bool Catalog::LookupMd5Path(const shash::Md5 &md5path,
324  DirectoryEntry *dirent) const {
325  return LookupEntry(md5path, true, dirent);
326 }
327 
328 
330  LinkString *raw_symlink) const {
331  DirectoryEntry dirent;
332  bool result = (LookupEntry(NormalizePath(path), false, &dirent));
333  if (result)
334  raw_symlink->Assign(dirent.symlink());
335  return result;
336 }
337 
338 
340  XattrList *xattrs) const {
342 
345  bool found = sql_lookup_xattrs_->FetchRow();
346  if (found && (xattrs != NULL)) {
347  *xattrs = sql_lookup_xattrs_->GetXattrs();
348  }
350 
351  return found;
352 }
353 
354 
362  StatEntryList *listing) const {
364 
365  DirectoryEntry dirent;
366  StatEntry entry;
367 
369  sql_listing_->BindPathHash(md5path);
370  while (sql_listing_->FetchRow()) {
371  dirent = sql_listing_->GetDirent(this);
372  if (dirent.IsHidden())
373  continue;
374  FixTransitionPoint(md5path, &dirent);
375  entry.name = dirent.name();
376  entry.info = dirent.GetStatStructure();
377  listing->PushBack(entry);
378  }
379  sql_listing_->Reset();
380 
381  return true;
382 }
383 
384 
394  DirectoryEntryList *listing,
395  const bool expand_symlink) const {
397 
399 
400  sql_listing_->BindPathHash(md5path);
401  while (sql_listing_->FetchRow()) {
402  DirectoryEntry dirent = sql_listing_->GetDirent(this, expand_symlink);
403  FixTransitionPoint(md5path, &dirent);
404  listing->push_back(dirent);
405  }
406  sql_listing_->Reset();
407 
408  return true;
409 }
410 
411 
413 
414 
416  zlib::Algorithms *compression_alg) {
417  return sql_all_chunks_->Next(hash, compression_alg);
418 }
419 
420 
422 
423 
430  const shash::Algorithms interpret_hashes_as,
431  FileChunkList *chunks) const {
432  assert(IsInitialized() && chunks->IsEmpty());
433 
435 
437  while (sql_chunks_listing_->FetchRow()) {
438  chunks->PushBack(sql_chunks_listing_->GetFileChunk(interpret_hashes_as));
439  }
441 
442  return true;
443 }
444 
445 
450  if (!referenced_hashes_.empty()) {
451  return referenced_hashes_;
452  }
453 
454  // retrieve all referenced content hashes of both files and file chunks
455  SqlListContentHashes list_content_hashes(database());
456  while (list_content_hashes.FetchRow()) {
457  referenced_hashes_.push_back(list_content_hashes.GetHash());
458  }
459 
460  return referenced_hashes_;
461 }
462 
463 
465  managed_database_ = true;
466  if (NULL != database_) {
468  }
469 }
470 
471 
473  managed_database_ = false;
474  if (NULL != database_) {
476  }
477 }
478 
479 
480 uint64_t Catalog::GetTTL() const {
482  return database().GetPropertyDefault<uint64_t>("TTL", kDefaultTTL);
483 }
484 
485 
488  return database().HasProperty("TTL");
489 }
490 
491 
492 bool Catalog::GetVOMSAuthz(string *authz) const {
493  bool result;
496  if (authz) {
497  *authz = voms_authz_;
498  }
499  result = true;
500  } else if (voms_authz_status_ == kVomsNone) {
501  result = false;
502  } else {
503  if (database().HasProperty("voms_authz")) {
504  voms_authz_ = database().GetProperty<string>("voms_authz");
505  if (authz) {
506  *authz = voms_authz_;
507  }
509  } else {
511  }
512  result = (voms_authz_status_ == kVomsPresent);
513  }
514  return result;
515 }
516 
517 uint64_t Catalog::GetRevision() const {
519  return database().GetPropertyDefault<uint64_t>("revision", 0);
520 }
521 
522 uint64_t Catalog::GetLastModified() const {
523  const std::string prop_name = "last_modified";
524  return (database().HasProperty(prop_name))
525  ? database().GetProperty<int>(prop_name)
526  : 0u;
527 }
528 
529 
530 uint64_t Catalog::GetNumChunks() const {
531  return counters_.Get("self_regular") + counters_.Get("self_chunks");
532 }
533 
534 
535 uint64_t Catalog::GetNumEntries() const {
536  const string sql = "SELECT count(*) FROM catalog;";
537 
539  SqlCatalog stmt(database(), sql);
540  return (stmt.FetchRow()) ? stmt.RetrieveInt64(0) : 0;
541 }
542 
543 
546  const std::string hash_string = database().GetPropertyDefault<std::string>(
547  "previous_revision", "");
548  return (!hash_string.empty())
549  ? shash::MkFromHexPtr(shash::HexPtr(hash_string),
551  : shash::Any();
552 }
553 
554 
556  sqlite::MemStatistics stats;
557  {
559  database().GetMemStatistics(&stats);
560  }
561  return string(mountpoint().GetChars(), mountpoint().GetLength()) + ": "
562  + StringifyInt(stats.lookaside_slots_used) + " / "
563  + StringifyInt(stats.lookaside_slots_max) + " slots -- "
564  + StringifyInt(stats.lookaside_hit) + " hits, "
565  + StringifyInt(stats.lookaside_miss_size) + " misses-size, "
566  + StringifyInt(stats.lookaside_miss_full) + " misses-full -- "
567  + StringifyInt(stats.page_cache_used / 1024) + " kB pages -- "
568  + StringifyInt(stats.page_cache_hit) + " hits, "
569  + StringifyInt(stats.page_cache_miss) + " misses -- "
570  + StringifyInt(stats.schema_used / 1024) + " kB schema -- "
571  + StringifyInt(stats.stmt_used / 1024) + " kB statements";
572 }
573 
574 
583 inode_t Catalog::GetMangledInode(const uint64_t row_id,
584  const uint64_t hardlink_group) const {
586 
587  if (inode_range_.IsDummy()) {
589  }
590 
591  inode_t inode = row_id + inode_range_.offset;
592 
593  // Hardlinks are encoded in catalog-wide unique hard link group ids.
594  // These ids must be resolved to actual inode relationships at runtime.
595  if (hardlink_group > 0) {
596  HardlinkGroupMap::const_iterator inode_iter = hardlink_groups_.find(
597  hardlink_group);
598 
599  // Use cached entry if possible
600  if (inode_iter == hardlink_groups_.end()) {
601  hardlink_groups_[hardlink_group] = inode;
602  } else {
603  inode = inode_iter->second;
604  }
605  }
606 
607  if (inode_annotation_) {
608  inode = inode_annotation_->Annotate(inode);
609  }
610 
611  return inode;
612 }
613 
614 
622 
624  LogCvmfs(kLogCatalog, kLogDebug, "refreshing nested catalog cache of '%s'",
625  mountpoint().c_str());
626  while (sql_list_nested_->FetchRow()) {
627  NestedCatalog nested;
630  nested.size = sql_list_nested_->GetSize();
631  nested_catalog_cache_.push_back(nested);
632  }
635  }
636 
637  return nested_catalog_cache_;
638 }
639 
640 
647  NestedCatalogList result;
648 
650 
651  while (sql_own_list_nested_->FetchRow()) {
652  NestedCatalog nested;
655  nested.size = sql_own_list_nested_->GetSize();
656  result.push_back(nested);
657  }
659 
660  return result;
661 }
662 
663 
672  nested_catalog_cache_.clear();
674 }
675 
676 
680 bool Catalog::FindNested(const PathString &mountpoint, shash::Any *hash,
681  uint64_t *size) const {
683  PathString normalized_mountpoint = NormalizePath2(mountpoint);
684  sql_lookup_nested_->BindSearchPath(normalized_mountpoint);
685  bool found = sql_lookup_nested_->FetchRow();
686  if (found && (hash != NULL)) {
688  *size = sql_lookup_nested_->GetSize();
689  }
691 
692  return found;
693 }
694 
695 
702  // Since annotated inodes could come back to the catalog in order to
703  // get stripped, exchanging the annotation is not allowed
704  assert((inode_annotation_ == NULL) || (inode_annotation_ == new_annotation));
705  inode_annotation_ = new_annotation;
706 }
707 
708 
709 void Catalog::SetOwnerMaps(const OwnerMap *uid_map, const OwnerMap *gid_map) {
710  uid_map_ = (uid_map && uid_map->HasEffect()) ? uid_map : NULL;
711  gid_map_ = (gid_map && gid_map->HasEffect()) ? gid_map : NULL;
712 }
713 
714 
720  assert(NULL == FindChild(child->mountpoint()));
721 
723  children_[child->mountpoint()] = child;
724  child->set_parent(this);
725 }
726 
727 
733  assert(NULL != FindChild(child->mountpoint()));
734 
736  child->set_parent(NULL);
737  children_.erase(child->mountpoint());
738 }
739 
740 
742  CatalogList result;
743 
745  for (NestedCatalogMap::const_iterator i = children_.begin(),
746  iEnd = children_.end();
747  i != iEnd;
748  ++i) {
749  result.push_back(i->second);
750  }
751 
752  return result;
753 }
754 
755 
764  // Check if this catalog fits the beginning of the path.
765  if (!path.StartsWith(mountpoint_))
766  return NULL;
767 
768  PathString remaining(path.Suffix(mountpoint_.GetLength()));
769  remaining.Append("/", 1);
770 
771  // now we recombine the path elements successively
772  // in order to find a child which serves a part of the path
773  PathString path_prefix(mountpoint_);
774  Catalog *result = NULL;
775  // Skip the first '/'
776  path_prefix.Append("/", 1);
777  const char *c = remaining.GetChars() + 1;
778  for (unsigned i = 1; i < remaining.GetLength(); ++i, ++c) {
779  if (*c == '/') {
780  result = FindChild(path_prefix);
781 
782  // If we found a child serving a part of the path we can stop searching.
783  // Remaining sub path elements are possibly served by a grand child.
784  if (result != NULL)
785  break;
786  }
787  path_prefix.Append(c, 1);
788  }
789 
790  return result;
791 }
792 
793 
798 Catalog *Catalog::FindChild(const PathString &mountpoint) const {
799  NestedCatalogMap::const_iterator nested_iter;
800 
802  nested_iter = children_.find(mountpoint);
803  Catalog *result = (nested_iter == children_.end()) ? NULL
804  : nested_iter->second;
805 
806  return result;
807 }
808 
809 
818  DirectoryEntry *dirent) const {
819  if (!HasParent())
820  return;
821 
822  if (dirent->IsNestedCatalogRoot()) {
823  // Normal nested catalog
824  DirectoryEntry parent_dirent;
825  const bool retval = parent_->LookupMd5Path(md5path, &parent_dirent);
826  assert(retval);
827  dirent->set_inode(parent_dirent.inode());
828  } else if (md5path == kMd5PathEmpty) {
829  // Bind mountpoint
830  DirectoryEntry parent_dirent;
831  const bool retval = parent_->LookupPath(mountpoint_, &parent_dirent);
832  assert(retval);
833  dirent->set_inode(parent_dirent.inode());
834  }
835 }
836 
837 } // namespace catalog
bool BindSearchPath(const PathString &path)
Definition: catalog_sql.cc:953
InodeRange inode_range() const
Definition: catalog.h:178
PathString PlantPath(const PathString &path) const
Definition: catalog.cc:281
void DropFileOwnership()
Definition: sql_impl.h:342
struct stat info
shash::Any GetHash() const
Definition: catalog_sql.cc:664
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:415
HardlinkGroupMap hardlink_groups_
Definition: catalog.h:230
bool Reset()
Definition: sql.cc:127
struct cvmcache_context * ctx
string * mountpoint_
Definition: auto_umount.cc:26
void EnforceSchema(float version, unsigned revision)
Definition: sql.h:225
int page_cache_used
Bytes used for caching pages.
Definition: sql.h:34
void set_inode(const inode_t inode)
bool FetchRow()
Definition: sql.cc:61
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:194
bool BindPathHash(const shash::Md5 &hash)
bool HasParent() const
Definition: catalog.h:196
bool LookupXattrsMd5Path(const shash::Md5 &md5path, XattrList *xattrs) const
Definition: catalog.cc:339
const OwnerMap * gid_map_
Definition: catalog.h:326
bool OpenDatabase(const std::string &db_path)
Definition: catalog.cc:161
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:334
PathString NormalizePath2(const PathString &path) const
Definition: catalog.cc:264
Catalog * parent_
Definition: catalog.h:311
int lookaside_miss_size
Definition: sql.h:32
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:739
bool AllChunksBegin()
Definition: catalog.cc:412
NameString name
bool managed_database_
Definition: catalog.h:309
int lookaside_slots_used
Definition: sql.h:29
Catalog * FindSubtree(const PathString &path) const
Definition: catalog.cc:763
virtual void InitPreparedStatements()
Definition: catalog.cc:96
pthread_mutex_t * lock_
Definition: catalog.h:232
inode_t inode() const
shash::Any GetPreviousRevision() const
Definition: catalog.cc:544
uint64_t inode_t
uint64_t GetTTL() const
Definition: catalog.cc:480
assert((mem||(size==0))&&"Out Of Memory")
float schema_version() const
Definition: sql.h:147
shash::Any GetContentHash() const
Definition: catalog_sql.cc:958
CatalogList GetChildren() const
Definition: catalog.cc:741
bool InitStandalone(const std::string &database_file)
Definition: catalog.cc:120
int stmt_used
Bytes used for prepared statmements (lookaside + heap)
Definition: sql.h:38
std::string PrintMemStatistics() const
Definition: catalog.cc:555
bool ListMd5PathChunks(const shash::Md5 &md5path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks) const
Definition: catalog.cc:429
Catalog * FindChild(const PathString &mountpoint) const
Definition: catalog.cc:798
void SetInodeAnnotation(InodeAnnotation *new_annotation)
Definition: catalog.cc:700
bool IsDummy() const
Definition: catalog.h:62
const NestedCatalogList & ListNestedCatalogs() const
Definition: catalog.cc:620
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:393
bool LookupEntry(const shash::Md5 &md5path, const bool expand_symlink, DirectoryEntry *dirent) const
Definition: catalog.cc:300
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:108
T GetProperty(const std::string &key) const
Definition: sql_impl.h:301
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:166
T GetPropertyDefault(const std::string &key, const T default_value) const
Definition: sql_impl.h:313
InodeAnnotation * inode_annotation_
Definition: catalog.h:322
bool GetVOMSAuthz(std::string *authz) const
Definition: catalog.cc:492
Algorithms
Definition: hash.h:41
std::vector< shash::Any > HashVector
Definition: catalog.h:97
bool IsNestedCatalogRoot() const
uint64_t GetNumEntries() const
Definition: catalog.cc:535
uint64_t GetRevision() const
Definition: catalog.cc:517
std::vector< DirectoryEntry > DirectoryEntryList
int GetLastError() const
Definition: sql.h:340
NameString name() const
uint64_t GetLastModified() const
Definition: catalog.cc:522
Algorithms
Definition: compression.h:44
bool HasExplicitTTL() const
Definition: catalog.cc:486
bool AllChunksEnd()
Definition: catalog.cc:421
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:104
const HashVector & GetReferencedObjects() const
Definition: catalog.cc:449
bool LookupMd5Path(const shash::Md5 &md5path, DirectoryEntry *dirent) const
Definition: catalog.cc:323
void AddChild(Catalog *child)
Definition: catalog.cc:719
shash::Md5 NormalizePath(const PathString &path) const
Definition: catalog.cc:238
const char kSuffixCatalog
Definition: hash.h:54
void FixTransitionPoint(const shash::Md5 &md5path, DirectoryEntry *dirent) const
Definition: catalog.cc:817
void ResetNestedCatalogCacheUnprotected()
Definition: catalog.cc:671
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:361
PathString mountpoint() const
Definition: catalog.h:175
void Final(ContextPtr context, Any *any_digest)
Definition: hash.cc:223
bool BindPathHash(const shash::Md5 &hash)
bool BindPathHash(const struct shash::Md5 &hash)
Definition: catalog_sql.cc:831
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:464
string StringifyInt(const int64_t value)
Definition: string.cc:77
SqlLookupPathHash * sql_lookup_md5path_
Definition: catalog.h:329
bool ReadFromDatabase(const CatalogDatabase &database, const LegacyMode::Type legacy=LegacyMode::kNoLegacy)
void * buffer
Definition: hash.h:489
int page_cache_miss
Definition: sql.h:36
void RemoveChild(Catalog *child)
Definition: catalog.cc:732
bool BindPathHash(const struct shash::Md5 &hash)
Definition: catalog_sql.cc:817
PathString root_prefix() const
Definition: catalog.h:181
std::vector< Catalog * > CatalogList
Definition: catalog.h:38
bool is_regular_mountpoint_
Definition: catalog.h:303
bool IsEmpty() const
Definition: bigvector.h:70
bool HasProperty(const std::string &key) const
Definition: sql_impl.h:289
bool IsInitialized() const
Definition: catalog.h:186
void PushBack(const Item &item)
Definition: bigvector.h:58
void set_inode_range(const InodeRange value)
Definition: catalog.h:179
bool IsEqualSchema(const float value, const float compare) const
Definition: sql.h:129
inode_t GetMangledInode(const uint64_t row_id, const uint64_t hardlink_group) const
Definition: catalog.cc:583
std::vector< NestedCatalog > NestedCatalogList
Definition: catalog.h:204
void Update(const unsigned char *buffer, const unsigned buffer_length, ContextPtr context)
Definition: hash.cc:192
const NestedCatalogList ListOwnNestedCatalogs() const
Definition: catalog.cc:646
SqlChunksListing * sql_chunks_listing_
Definition: catalog.h:334
shash::Any GetContentHash() const
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:213
virtual ~Catalog()
Definition: catalog.cc:82
Definition: mutex.h:42
int schema_used
Bytes used to store db schema.
Definition: sql.h:37
uint64_t GetNumChunks() const
Definition: catalog.cc:530
void SetOwnerMaps(const OwnerMap *uid_map, const OwnerMap *gid_map)
Definition: catalog.cc:709
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:680
std::string voms_authz_
Definition: catalog.h:317
int lookaside_miss_full
Definition: sql.h:33
Any MkFromHexPtr(const HexPtr hex, const char suffix)
Definition: hash.cc:82
bool LookupRawSymlink(const PathString &path, LinkString *raw_symlink) const
Definition: catalog.cc:329
bool StartsWith(const ShortString &other) const
Definition: shortstring.h:185
int page_cache_hit
Definition: sql.h:35
bool ReadCatalogCounters()
Definition: catalog.cc:133
void DropDatabaseFileOwnership()
Definition: catalog.cc:472
static const float kLatestSupportedSchema
Definition: catalog_sql.h:44
int lookaside_slots_max
Definition: sql.h:30
void GetMemStatistics(MemStatistics *stats) const
Definition: sql_impl.h:360
unsigned GetLength() const
Definition: shortstring.h:131
unsigned size
Definition: hash.h:490
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:143
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:545