CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
catalog_rw.cc
Go to the documentation of this file.
1 
5 #define __STDC_FORMAT_MACROS
6 
7 #include "catalog_rw.h"
8 
9 #include <inttypes.h>
10 
11 #include <cstdio>
12 #include <cstdlib>
13 
14 #include "util/concurrency.h"
15 #include "util/exception.h"
16 #include "util/logging.h"
17 #include "xattr.h"
18 
19 using namespace std; // NOLINT
20 
21 namespace catalog {
22 
23 const double WritableCatalog::kMaximalFreePageRatio = 0.20;
24 const double WritableCatalog::kMaximalRowIdWasteRatio = 0.25;
25 
26 
27 WritableCatalog::WritableCatalog(const string &path,
28  const shash::Any &catalog_hash,
29  Catalog *parent,
30  const bool is_not_root)
31  : Catalog(PathString(path.data(), path.length()),
32  catalog_hash, // This is 0 for a newly created catalog!
33  parent,
34  is_not_root)
35  , sql_insert_(NULL)
36  , sql_unlink_(NULL)
37  , sql_touch_(NULL)
38  , sql_update_(NULL)
39  , sql_chunk_insert_(NULL)
40  , sql_chunks_remove_(NULL)
41  , sql_chunks_count_(NULL)
42  , sql_max_link_id_(NULL)
43  , sql_inc_linkcount_(NULL)
44  , dirty_(false) {
45  atomic_init32(&dirty_children_);
46 }
47 
48 
50  const string &file,
51  const shash::Any &catalog_hash,
52  Catalog *parent,
53  const bool is_not_root) {
54  WritableCatalog *catalog = new WritableCatalog(root_path, catalog_hash,
55  parent, is_not_root);
56  const bool successful_init = catalog->InitStandalone(file);
57  if (!successful_init) {
58  delete catalog;
59  return NULL;
60  }
61  return catalog;
62 }
63 
64 
66  // CAUTION HOT!
67  // (see Catalog.h - near the definition of FinalizePreparedStatements)
69 }
70 
71 
73  LogCvmfs(kLogCatalog, kLogVerboseMsg, "opening SQLite transaction for '%s'",
74  mountpoint().c_str());
75  const bool retval = database().BeginTransaction();
76  assert(retval == true);
77 }
78 
79 
81  LogCvmfs(kLogCatalog, kLogVerboseMsg, "closing SQLite transaction for '%s'",
82  mountpoint().c_str());
83  const bool retval = database().CommitTransaction();
84  assert(retval == true);
85  dirty_ = false;
86 }
87 
88 
90  Catalog::InitPreparedStatements(); // polymorphism: up call
91 
92  bool retval = SqlCatalog(database(), "PRAGMA foreign_keys = ON;").Execute();
93  assert(retval);
103 }
104 
105 
107  // no polymorphism: no up call (see Catalog.h -
108  // near the definition of this method)
109  delete sql_insert_;
110  delete sql_unlink_;
111  delete sql_touch_;
112  delete sql_update_;
113  delete sql_chunk_insert_;
114  delete sql_chunks_remove_;
115  delete sql_chunks_count_;
116  delete sql_max_link_id_;
117  delete sql_inc_linkcount_;
118 }
119 
120 
125  int result = -1;
126 
127  if (sql_max_link_id_->FetchRow()) {
128  result = sql_max_link_id_->GetMaxGroupId();
129  }
131 
132  return result;
133 }
134 
135 
142 void WritableCatalog::AddEntry(const DirectoryEntry &entry,
143  const XattrList &xattrs,
144  const string &entry_path,
145  const string &parent_path) {
146  SetDirty();
147 
148  LogCvmfs(kLogCatalog, kLogVerboseMsg, "add entry '%s' to '%s'",
149  entry_path.c_str(), mountpoint().c_str());
150 
151  shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
152  shash::Md5 parent_hash((shash::AsciiPtr(parent_path)));
153  DirectoryEntry effective_entry(entry);
154  effective_entry.set_has_xattrs(!xattrs.IsEmpty());
155 
156  bool retval = sql_insert_->BindPathHash(path_hash)
157  && sql_insert_->BindParentPathHash(parent_hash)
158  && sql_insert_->BindDirent(effective_entry);
159  assert(retval);
160  if (xattrs.IsEmpty()) {
161  retval = sql_insert_->BindXattrEmpty();
162  } else {
163  retval = sql_insert_->BindXattr(xattrs);
164  }
165  assert(retval);
166  retval = sql_insert_->Execute();
167  assert(retval);
168  sql_insert_->Reset();
169 
170  delta_counters_.Increment(effective_entry);
171 }
172 
173 
180 void WritableCatalog::RemoveEntry(const string &file_path) {
181  DirectoryEntry entry;
182  bool retval = LookupPath(PathString(file_path), &entry);
183  assert(retval);
184 
185  SetDirty();
186 
187  // If the entry used to be a chunked file... remove the chunks
188  if (entry.IsChunkedFile()) {
189  RemoveFileChunks(file_path);
190  }
191 
192  // remove the entry itself
193  shash::Md5 path_hash = shash::Md5(shash::AsciiPtr(file_path));
194  retval = sql_unlink_->BindPathHash(path_hash) && sql_unlink_->Execute();
195  assert(retval);
196  sql_unlink_->Reset();
197 
198  delta_counters_.Decrement(entry);
199 }
200 
201 
202 void WritableCatalog::IncLinkcount(const string &path_within_group,
203  const int delta) {
204  SetDirty();
205 
206  shash::Md5 path_hash = shash::Md5(shash::AsciiPtr(path_within_group));
207 
208  bool retval = sql_inc_linkcount_->BindPathHash(path_hash)
209  && sql_inc_linkcount_->BindDelta(delta)
211  assert(retval);
213 }
214 
215 
217  const XattrList &xattrs,
218  const shash::Md5 &path_hash) {
219  SetDirty();
220 
221  catalog::DirectoryEntry prev_entry;
222  bool retval = LookupMd5Path(path_hash, &prev_entry);
223  assert(retval);
224 
225  retval = sql_touch_->BindPathHash(path_hash)
226  && sql_touch_->BindDirentBase(entry);
227  assert(retval);
228  if (xattrs.IsEmpty()) {
229  retval = sql_touch_->BindXattrEmpty();
230  if (prev_entry.HasXattrs())
231  delta_counters_.self.xattrs--;
232  } else {
233  retval = sql_touch_->BindXattr(xattrs);
234  if (!prev_entry.HasXattrs())
235  delta_counters_.self.xattrs++;
236  }
237  assert(retval);
238  retval = sql_touch_->Execute();
239  assert(retval);
240  sql_touch_->Reset();
241 }
242 
243 
245  const shash::Md5 &path_hash) {
246  SetDirty();
247 
248  bool retval = sql_update_->BindPathHash(path_hash)
249  && sql_update_->BindDirent(entry) && sql_update_->Execute();
250  assert(retval);
251  sql_update_->Reset();
252 }
253 
254 void WritableCatalog::AddFileChunk(const std::string &entry_path,
255  const FileChunk &chunk) {
256  SetDirty();
257 
258  shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
259 
261  "adding chunk for %s from offset %ld "
262  "and chunk size: %ld bytes",
263  entry_path.c_str(), chunk.offset(), chunk.offset() + chunk.size());
264 
265  delta_counters_.self.file_chunks++;
266 
267  bool retval = sql_chunk_insert_->BindPathHash(path_hash)
270  assert(retval);
272 }
273 
274 
279 void WritableCatalog::RemoveFileChunks(const std::string &entry_path) {
280  shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
281  bool retval;
282 
283  // subtract the number of chunks from the statistics counters
284  retval = sql_chunks_count_->BindPathHash(path_hash)
286  assert(retval);
287  const int chunks_count = sql_chunks_count_->GetChunkCount();
288  delta_counters_.self.file_chunks -= chunks_count;
290 
291  // remove the chunks associated to `entry_path`
292  retval = sql_chunks_remove_->BindPathHash(path_hash)
294  assert(retval);
296 }
297 
298 
303  database().SetProperty("last_modified", static_cast<uint64_t>(time(NULL)));
304 }
305 
306 
311 
312 
313 void WritableCatalog::SetRevision(const uint64_t new_revision) {
314  database().SetProperty("revision", new_revision);
315 }
316 
317 
318 void WritableCatalog::SetBranch(const std::string &branch_name) {
319  database().SetProperty("branch", branch_name);
320 }
321 
322 
323 void WritableCatalog::SetTTL(const uint64_t new_ttl) {
324  database().SetProperty("TTL", new_ttl);
325 }
326 
327 
328 bool WritableCatalog::SetVOMSAuthz(const std::string &voms_authz) {
329  return database().SetVOMSAuthz(voms_authz);
330 }
331 
332 
337  database().SetProperty("previous_revision", hash.ToString());
338 }
339 
340 
344 void WritableCatalog::Partition(WritableCatalog *new_nested_catalog) {
345  // Create connection between parent and child catalogs
346  MakeTransitionPoint(new_nested_catalog->mountpoint().ToString());
347  new_nested_catalog->MakeNestedRoot();
348  delta_counters_.subtree.directories++; // Root directory in nested catalog
349 
350  // Move the present directory tree into the newly created nested catalog
351  // if we hit nested catalog mountpoints on the way, we return them through
352  // the passed list
353  vector<string> GrandChildMountpoints;
354  MoveToNested(new_nested_catalog->mountpoint().ToString(), new_nested_catalog,
355  &GrandChildMountpoints);
356 
357  // Nested catalog mountpoints found in the moved directory structure are now
358  // links to nested catalogs of the newly created nested catalog.
359  // Move these references into the new nested catalog
360  MoveCatalogsToNested(GrandChildMountpoints, new_nested_catalog);
361 }
362 
363 
364 void WritableCatalog::MakeTransitionPoint(const string &mountpoint) {
365  // Find the directory entry to edit
366  DirectoryEntry transition_entry;
367  bool retval = LookupPath(PathString(mountpoint.data(), mountpoint.length()),
368  &transition_entry);
369  assert(retval);
370 
371  assert(transition_entry.IsDirectory()
372  && !transition_entry.IsNestedCatalogRoot());
373 
374  transition_entry.set_is_nested_catalog_mountpoint(true);
375  UpdateEntry(transition_entry, mountpoint);
376 }
377 
378 
380  DirectoryEntry root_entry;
381  bool retval = LookupPath(mountpoint(), &root_entry);
382  assert(retval);
383 
384  assert(root_entry.IsDirectory() && !root_entry.IsNestedCatalogMountpoint());
385 
386  root_entry.set_is_nested_catalog_root(true);
387  UpdateEntry(root_entry, mountpoint().ToString());
388 }
389 
390 
392  const string directory,
393  WritableCatalog *new_nested_catalog,
394  vector<string> *grand_child_mountpoints) {
395  // After creating a new nested catalog we have to move all elements
396  // now contained by the new one. List and move them recursively.
397  DirectoryEntryList listing;
398  const bool resolve_magic_symlinks = false;
399  bool retval = ListingPath(PathString(directory), &listing,
400  resolve_magic_symlinks);
401  assert(retval);
402 
403  // Go through the listing
404  XattrList empty_xattrs;
405  for (DirectoryEntryList::const_iterator i = listing.begin(),
406  iEnd = listing.end();
407  i != iEnd;
408  ++i) {
409  const string full_path = i->GetFullPath(directory);
410 
411  // The entries are first inserted into the new catalog
412  if (i->HasXattrs()) {
413  XattrList xattrs;
414  retval = LookupXattrsPath(PathString(full_path), &xattrs);
415  assert(retval);
416  assert(!xattrs.IsEmpty());
417  new_nested_catalog->AddEntry(*i, xattrs, full_path);
418  } else {
419  new_nested_catalog->AddEntry(*i, empty_xattrs, full_path);
420  }
421 
422  // Then we check if we have some special cases:
423  if (i->IsNestedCatalogMountpoint()) {
424  grand_child_mountpoints->push_back(full_path);
425  } else if (i->IsDirectory()) {
426  // Recurse deeper into the directory tree
427  MoveToNestedRecursively(full_path, new_nested_catalog,
428  grand_child_mountpoints);
429  } else if (i->IsChunkedFile()) {
430  MoveFileChunksToNested(full_path, i->hash_algorithm(),
431  new_nested_catalog);
432  }
433 
434  // Remove the entry from the current catalog
435  RemoveEntry(full_path);
436  }
437 }
438 
439 
441  const vector<string> &nested_catalogs,
442  WritableCatalog *new_nested_catalog) {
443  for (vector<string>::const_iterator i = nested_catalogs.begin(),
444  iEnd = nested_catalogs.end();
445  i != iEnd;
446  ++i) {
447  shash::Any hash_nested;
448  uint64_t size_nested;
449  bool retval = FindNested(PathString(*i), &hash_nested, &size_nested);
450  assert(retval);
451 
452  Catalog *attached_reference = NULL;
453  RemoveNestedCatalog(*i, &attached_reference);
454 
455  new_nested_catalog->InsertNestedCatalog(*i, attached_reference, hash_nested,
456  size_nested);
457  }
458 }
459 
460 
462  const std::string &full_path,
464  WritableCatalog *new_nested_catalog) {
465  FileChunkList chunks;
466  ListPathChunks(PathString(full_path), algorithm, &chunks);
467  assert(chunks.size() > 0);
468 
469  for (unsigned i = 0; i < chunks.size(); ++i) {
470  new_nested_catalog->AddFileChunk(full_path, *chunks.AtPtr(i));
471  }
472 }
473 
474 
485 void WritableCatalog::InsertNestedCatalog(const string &mountpoint,
486  Catalog *attached_reference,
487  const shash::Any content_hash,
488  const uint64_t size) {
489  const string hash_string = (!content_hash.IsNull()) ? content_hash.ToString()
490  : "";
491 
492  SqlCatalog stmt(database(), "INSERT INTO nested_catalogs (path, sha1, size) "
493  "VALUES (:p, :sha1, :size);");
494  bool retval = stmt.BindText(1, mountpoint) && stmt.BindText(2, hash_string)
495  && stmt.BindInt64(3, size) && stmt.Execute();
496  assert(retval);
497 
498  // If a reference of the in-memory object of the newly referenced
499  // catalog was passed, we add this to our own children
500  if (attached_reference != NULL)
501  AddChild(attached_reference);
502 
504 
505  delta_counters_.self.nested_catalogs++;
506 }
507 
508 
514 void WritableCatalog::InsertBindMountpoint(const string &mountpoint,
515  const shash::Any content_hash,
516  const uint64_t size) {
517  SqlCatalog stmt(database(),
518  "INSERT INTO bind_mountpoints (path, sha1, size) "
519  "VALUES (:p, :sha1, :size);");
520  bool retval = stmt.BindText(1, mountpoint)
521  && stmt.BindText(2, content_hash.ToString())
522  && stmt.BindInt64(3, size) && stmt.Execute();
523  assert(retval);
524 }
525 
526 
536 void WritableCatalog::RemoveNestedCatalog(const string &mountpoint,
537  Catalog **attached_reference) {
538  shash::Any dummy;
539  uint64_t dummy_size;
540  bool retval = FindNested(PathString(mountpoint.data(), mountpoint.length()),
541  &dummy, &dummy_size);
542  assert(retval);
543 
544  SqlCatalog stmt(database(), "DELETE FROM nested_catalogs WHERE path = :p;");
545  retval = stmt.BindText(1, mountpoint) && stmt.Execute();
546  assert(retval);
547 
548  // If the reference was successfully deleted, we also have to check whether
549  // there is also an attached reference in our in-memory data.
550  // In this case we remove the child and return it through **attached_reference
551  Catalog *child = FindChild(PathString(mountpoint));
552  if (child != NULL)
553  RemoveChild(child);
554  if (attached_reference != NULL)
555  *attached_reference = child;
556 
558 
559  delta_counters_.self.nested_catalogs--;
560 }
561 
562 
568 void WritableCatalog::RemoveBindMountpoint(const std::string &mountpoint) {
569  shash::Any dummy;
570  uint64_t dummy_size;
571  bool retval = FindNested(PathString(mountpoint.data(), mountpoint.length()),
572  &dummy, &dummy_size);
573  assert(retval);
574 
575  SqlCatalog stmt(database(), "DELETE FROM bind_mountpoints WHERE path = :p;");
576  retval = stmt.BindText(1, mountpoint) && stmt.Execute();
577  assert(retval);
578 }
579 
580 
588 void WritableCatalog::UpdateNestedCatalog(const std::string &path,
589  const shash::Any &hash,
590  const uint64_t size,
591  const DeltaCounters &child_counters) {
592  MutexLockGuard guard(lock_);
593  SetDirty();
594 
595  child_counters.PopulateToParent(&delta_counters_);
596 
597  const string hash_str = hash.ToString();
598  const string sql = "UPDATE nested_catalogs SET sha1 = :sha1, size = :size "
599  "WHERE path = :path;";
600  SqlCatalog stmt(database(), sql);
601 
602  bool retval = stmt.BindText(1, hash_str) && stmt.BindInt64(2, size)
603  && stmt.BindText(3, path) && stmt.Execute();
604 
606 
607  assert(retval);
608 }
609 
610 
612  assert(!IsRoot() && HasParent());
614 
615  CopyToParent();
616 
617  // Copy the nested catalog references
619 
620  // Fix counters in parent
622  Counters &counters = GetWritableCounters();
623  counters.ApplyDelta(delta_counters_);
624  counters.MergeIntoParent(&parent->delta_counters_);
625 
626  // Remove the nested catalog reference for this nested catalog.
627  // From now on this catalog will be dangling!
628  parent->RemoveNestedCatalog(this->mountpoint().ToString(), NULL);
629 }
630 
631 
633  assert(!IsRoot() && HasParent());
635 
636  // Remove the nested catalog reference for this nested catalog.
637  // From now on this catalog will be dangling!
638  parent->RemoveNestedCatalog(this->mountpoint().ToString(), NULL);
641 }
642 
643 
646 
647  // Obtain a list of all nested catalog references
648  const NestedCatalogList nested_catalog_references = ListOwnNestedCatalogs();
649 
650  // Go through the list and update the databases
651  // simultaneously we are checking if the referenced catalogs are currently
652  // attached and update the in-memory data structures as well
653  for (NestedCatalogList::const_iterator i = nested_catalog_references.begin(),
654  iEnd = nested_catalog_references.end();
655  i != iEnd;
656  ++i) {
657  Catalog *child = FindChild(i->mountpoint);
658  parent->InsertNestedCatalog(i->mountpoint.ToString(), child, i->hash,
659  i->size);
660  parent->delta_counters_.self.nested_catalogs--; // Will be fixed later
661  }
662 }
663 
665  // We could simply copy all entries from this database to the 'other' database
666  // BUT: 1. this would create collisions in hardlink group IDs.
667  // therefore we first update all hardlink group IDs to fit behind the
668  // ones in the 'other' database
669  // 2. the root entry of the nested catalog is present twice:
670  // 1. in the parent directory (as mount point) and
671  // 2. in the nested catalog (as root entry)
672  // therefore we delete the mount point from the parent before merging
673 
675 
676  // Update hardlink group IDs in this nested catalog.
677  // To avoid collisions we add the maximal present hardlink group ID in parent
678  // to all hardlink group IDs in the nested catalog.
679  const uint64_t offset = static_cast<uint64_t>(parent->GetMaxLinkId()) << 32;
680  const string update_link_ids = "UPDATE catalog SET hardlinks = hardlinks + "
681  + StringifyInt(offset)
682  + " WHERE hardlinks > (1 << 32);";
683 
684  SqlCatalog sql_update_link_ids(database(), update_link_ids);
685  bool retval = sql_update_link_ids.Execute();
686  assert(retval);
687 
688  // Remove the nested catalog root.
689  // It is already present in the parent.
690  RemoveEntry(this->mountpoint().ToString());
691 
692  // Now copy all DirectoryEntries to the 'other' catalog.
693  // There will be no data collisions, as we resolved them beforehand
694  if (dirty_)
695  Commit();
696  if (parent->dirty_)
697  parent->Commit();
698  SqlCatalog sql_attach(database(), "ATTACH '" + parent->database_path()
699  + "' "
700  "AS other;");
701  retval = sql_attach.Execute();
702  assert(retval);
703  retval = SqlCatalog(database(), "INSERT INTO other.catalog "
704  "SELECT * FROM main.catalog;")
705  .Execute();
706  assert(retval);
707  retval = SqlCatalog(database(), "INSERT INTO other.chunks "
708  "SELECT * FROM main.chunks;")
709  .Execute();
710  assert(retval);
711  retval = SqlCatalog(database(), "DETACH other;").Execute();
712  assert(retval);
713  parent->SetDirty();
714 
715  // Change the just copied nested catalog root to an ordinary directory
716  // (the nested catalog is merged into it's parent)
717  DirectoryEntry old_root_entry;
718  retval = parent->LookupPath(this->mountpoint(), &old_root_entry);
719  assert(retval);
720 
721  assert(old_root_entry.IsDirectory()
722  && old_root_entry.IsNestedCatalogMountpoint()
723  && !old_root_entry.IsNestedCatalogRoot());
724 
725  // Remove the nested catalog root mark
726  old_root_entry.set_is_nested_catalog_mountpoint(false);
727  parent->UpdateEntry(old_root_entry, this->mountpoint().ToString());
728 }
729 
730 
735  const bool retval = delta_counters_.WriteToDatabase(database())
736  && ReadCatalogCounters();
737  assert(retval);
738 }
739 
740 
746  const CatalogDatabase &db = database();
747  bool needs_defragmentation = false;
748  double ratio = 0.0;
749  std::string reason;
750 
751  if ((ratio = db.GetFreePageRatio()) > kMaximalFreePageRatio) {
752  needs_defragmentation = true;
753  reason = "free pages";
754  } else if ((ratio = db.GetRowIdWasteRatio()) > kMaximalRowIdWasteRatio) {
755  needs_defragmentation = true;
756  reason = "wasted row IDs";
757  }
758 
759  if (needs_defragmentation) {
761  "Note: Catalog at %s gets defragmented (%.2f%% %s)... ",
762  (IsRoot()) ? "/" : mountpoint().c_str(), ratio * 100.0,
763  reason.c_str());
764  if (!db.Vacuum()) {
765  PANIC(kLogStderr, "failed (SQLite: %s)", db.GetLastErrorMsg().c_str());
766  }
767  LogCvmfs(kLogCatalog, kLogStdout, "done");
768  }
769 }
770 
771 } // namespace catalog
void MoveFileChunksToNested(const std::string &full_path, const shash::Algorithms algorithm, WritableCatalog *new_nested_catalog)
Definition: catalog_rw.cc:461
void RemoveFileChunks(const std::string &entry_path)
Definition: catalog_rw.cc:279
const Counters & GetCounters() const
Definition: catalog.h:171
bool IsNull() const
Definition: hash.h:371
std::string GetLastErrorMsg() const
Definition: sql_impl.h:327
SqlDirentInsert * sql_insert_
Definition: catalog_rw.h:145
bool Execute()
Definition: sql.cc:41
bool IsRoot() const
Definition: catalog.h:189
bool Reset()
Definition: sql.cc:127
double GetFreePageRatio() const
Definition: sql_impl.h:398
bool BindText(const int index, const std::string &value)
Definition: sql.h:394
std::string database_path() const
Definition: catalog.h:180
bool BindDirentBase(const DirectoryEntryBase &entry)
Definition: catalog_sql.cc:887
bool IsDirectory() const
bool FetchRow()
Definition: sql.cc:61
bool ListPathChunks(const PathString &path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks) const
Definition: catalog.h:144
static const double kMaximalFreePageRatio
Definition: catalog_rw.h:108
bool IsChunkedFile() const
bool HasParent() const
Definition: catalog.h:196
bool BindDirent(const DirectoryEntry &entry)
uint32_t GetMaxLinkId() const
Definition: catalog_rw.cc:124
void UpdateNestedCatalog(const std::string &path, const shash::Any &hash, const uint64_t size, const DeltaCounters &child_counters)
Definition: catalog_rw.cc:588
#define PANIC(...)
Definition: exception.h:29
std::string ToString(const bool with_suffix=false) const
Definition: hash.h:241
void InsertBindMountpoint(const std::string &mountpoint, const shash::Any content_hash, const uint64_t size)
Definition: catalog_rw.cc:514
void set_is_nested_catalog_root(const bool val)
bool BindFileChunk(const FileChunk &chunk)
bool LookupPath(const PathString &path, DirectoryEntry *dirent) const
Definition: catalog.h:124
bool BindPathHash(const shash::Md5 &hash)
Definition: catalog_sql.cc:903
void ApplyDelta(const DeltaCounters &delta)
bool ListingPath(const PathString &path, DirectoryEntryList *listing, const bool expand_symlink=true) const
Definition: catalog.h:132
bool BeginTransaction() const
Definition: sql_impl.h:268
bool BindPathHash(const shash::Md5 &hash)
static DeltaCounters Diff(const Counters &from, const Counters &to)
bool IsEmpty() const
Definition: xattr.h:40
void InsertNestedCatalog(const std::string &mountpoint, Catalog *attached_reference, const shash::Any content_hash, const uint64_t size)
Definition: catalog_rw.cc:485
void RemoveBindMountpoint(const std::string &mountpoint)
Definition: catalog_rw.cc:568
virtual void InitPreparedStatements()
Definition: catalog.cc:96
pthread_mutex_t * lock_
Definition: catalog.h:232
void TouchEntry(const DirectoryEntryBase &entry, const XattrList &xattrs, const shash::Md5 &path_hash)
Definition: catalog_rw.cc:216
assert((mem||(size==0))&&"Out Of Memory")
void Increment(const DirectoryEntry &dirent)
SqlChunksCount * sql_chunks_count_
Definition: catalog_rw.h:151
bool BindPathHash(const shash::Md5 &hash)
bool InitStandalone(const std::string &database_file)
Definition: catalog.cc:120
int GetChunkCount() const
void SetPreviousRevision(const shash::Any &hash)
Definition: catalog_rw.cc:336
Catalog * parent() const
Definition: catalog.h:176
SqlChunkInsert * sql_chunk_insert_
Definition: catalog_rw.h:149
void MoveToNestedRecursively(const std::string dir_structure_root, WritableCatalog *new_nested_catalog, std::vector< std::string > *grand_child_mountpoints)
Definition: catalog_rw.cc:391
Catalog * FindChild(const PathString &mountpoint) const
Definition: catalog.cc:798
SqlChunksRemove * sql_chunks_remove_
Definition: catalog_rw.h:150
void MakeTransitionPoint(const std::string &mountpoint)
Definition: catalog_rw.cc:364
SqlIncLinkcount * sql_inc_linkcount_
Definition: catalog_rw.h:153
char algorithm
void MoveToNested(const std::string &dir_structure_root, WritableCatalog *new_nested_catalog, std::vector< std::string > *grand_child_mountpoints)
Definition: catalog_rw.h:171
bool WriteToDatabase(const CatalogDatabase &database) const
bool IsNestedCatalogMountpoint() const
bool BindPathHash(const shash::Md5 &hash)
bool BindXattr(const XattrList &xattrs)
Definition: catalog_sql.cc:908
Algorithms
Definition: hash.h:41
static WritableCatalog * AttachFreely(const std::string &root_path, const std::string &file, const shash::Any &catalog_hash, Catalog *parent=NULL, const bool is_not_root=false)
Definition: catalog_rw.cc:49
bool IsNestedCatalogRoot() const
uint64_t GetRevision() const
Definition: catalog.cc:517
void AddFileChunk(const std::string &entry_path, const FileChunk &chunk)
Definition: catalog_rw.cc:254
std::vector< DirectoryEntry > DirectoryEntryList
bool BindDelta(const int delta)
atomic_int32 dirty_children_
Definition: catalog_rw.h:160
bool HasXattrs() const
bool BindPathHash(const shash::Md5 &hash)
SqlDirentUpdate * sql_update_
Definition: catalog_rw.h:148
void SetTTL(const uint64_t new_ttl)
Definition: catalog_rw.cc:323
SqlMaxHardlinkGroup * sql_max_link_id_
Definition: catalog_rw.h:152
bool LookupXattrsPath(const PathString &path, XattrList *xattrs) const
Definition: catalog.h:128
bool LookupMd5Path(const shash::Md5 &md5path, DirectoryEntry *dirent) const
Definition: catalog.cc:323
void AddChild(Catalog *child)
Definition: catalog.cc:719
off_t offset() const
Definition: file_chunk.h:38
void PopulateToParent(DeltaCounters *parent) const
bool Vacuum() const
Definition: sql_impl.h:415
bool BindXattr(const XattrList &xattrs)
void Decrement(const DirectoryEntry &dirent)
void ResetNestedCatalogCacheUnprotected()
Definition: catalog.cc:671
bool SetVOMSAuthz(const std::string &)
Definition: catalog_sql.cc:394
PathString mountpoint() const
Definition: catalog.h:175
string StringifyInt(const int64_t value)
Definition: string.cc:77
WritableCatalog(const std::string &path, const shash::Any &catalog_hash, Catalog *parent, const bool is_not_root=false)
Definition: catalog_rw.cc:27
bool CommitTransaction() const
Definition: sql_impl.h:274
bool BindInt64(const int index, const sqlite3_int64 value)
Definition: sql.h:376
void RemoveChild(Catalog *child)
Definition: catalog.cc:732
bool SetProperty(const std::string &key, const T value)
Definition: sql_impl.h:320
static const double kMaximalRowIdWasteRatio
Definition: catalog_rw.h:109
void RemoveNestedCatalog(const std::string &mountpoint, Catalog **attached_reference)
Definition: catalog_rw.cc:536
bool SetVOMSAuthz(const std::string &voms_authz)
Definition: catalog_rw.cc:328
void AddEntry(const DirectoryEntry &entry, const XattrList &xattr, const std::string &entry_path, const std::string &parent_path)
SqlDirentTouch * sql_touch_
Definition: catalog_rw.h:147
std::string ToString() const
Definition: shortstring.h:139
std::vector< NestedCatalog > NestedCatalogList
Definition: catalog.h:204
SqlDirentUnlink * sql_unlink_
Definition: catalog_rw.h:146
void SetBranch(const std::string &branch_name)
Definition: catalog_rw.cc:318
const NestedCatalogList ListOwnNestedCatalogs() const
Definition: catalog.cc:646
void Partition(WritableCatalog *new_nested_catalog)
Definition: catalog_rw.cc:344
ShortString< kDefaultMaxPath, 0 > PathString
Definition: shortstring.h:213
void SetRevision(const uint64_t new_revision)
Definition: catalog_rw.cc:313
size_t size() const
Definition: file_chunk.h:39
void MoveCatalogsToNested(const std::vector< std::string > &nested_catalogs, WritableCatalog *new_nested_catalog)
Definition: catalog_rw.cc:440
Definition: mutex.h:42
WritableCatalog * GetWritableParent() const
Definition: catalog_rw.h:130
DeltaCounters delta_counters_
Definition: catalog_rw.h:157
const CatalogDatabase & database() const
Definition: catalog.h:249
bool FindNested(const PathString &mountpoint, shash::Any *hash, uint64_t *size) const
Definition: catalog.cc:680
const int kLogVerboseMsg
bool ReadCatalogCounters()
Definition: catalog.cc:133
Counters & GetWritableCounters()
Definition: catalog.h:247
double GetRowIdWasteRatio() const
Definition: catalog_sql.cc:399
shash::Any hash() const
Definition: catalog.h:182
const char * c_str() const
Definition: shortstring.h:143
void RemoveEntry(const std::string &entry_path)
Definition: catalog_rw.cc:180
bool BindParentPathHash(const shash::Md5 &hash)
static void size_t size
Definition: smalloc.h:54
void MergeIntoParent(DeltaCounters *parent_delta) const
void IncLinkcount(const std::string &path_within_group, const int delta)
Definition: catalog_rw.cc:202
const Item * AtPtr(const size_t index) const
Definition: bigvector.h:53
void set_is_nested_catalog_mountpoint(const bool val)
bool BindPathHash(const shash::Md5 &hash)
void UpdateEntry(const DirectoryEntry &entry, const shash::Md5 &path_hash)
Definition: catalog_rw.cc:244
void RemoveFromSubtree(const DeltaCounters &child)
bool BindPathHash(const shash::Md5 &hash)
size_t size() const
Definition: bigvector.h:117
bool BindDirent(const DirectoryEntry &entry)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
Definition: logging.cc:545