CernVM-FS  2.12.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 #include <cstdio>
11 #include <cstdlib>
12 
13 #include "util/concurrency.h"
14 #include "util/exception.h"
15 #include "util/logging.h"
16 #include "xattr.h"
17 
18 using namespace std; // NOLINT
19 
20 namespace catalog {
21 
22 const double WritableCatalog::kMaximalFreePageRatio = 0.20;
23 const double WritableCatalog::kMaximalRowIdWasteRatio = 0.25;
24 
25 
26 WritableCatalog::WritableCatalog(const string &path,
27  const shash::Any &catalog_hash,
28  Catalog *parent,
29  const bool is_not_root) :
30  Catalog(PathString(path.data(), path.length()),
31  catalog_hash, // This is 0 for a newly created catalog!
32  parent,
33  is_not_root),
34  sql_insert_(NULL),
35  sql_unlink_(NULL),
36  sql_touch_(NULL),
37  sql_update_(NULL),
38  sql_chunk_insert_(NULL),
39  sql_chunks_remove_(NULL),
40  sql_chunks_count_(NULL),
41  sql_max_link_id_(NULL),
42  sql_inc_linkcount_(NULL),
43  dirty_(false)
44 {
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 =
55  new WritableCatalog(root_path, catalog_hash, 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 
143  const DirectoryEntry &entry,
144  const XattrList &xattrs,
145  const string &entry_path,
146  const string &parent_path)
147 {
148  SetDirty();
149 
150  LogCvmfs(kLogCatalog, kLogVerboseMsg, "add entry '%s' to '%s'",
151  entry_path.c_str(),
152  mountpoint().c_str());
153 
154  shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
155  shash::Md5 parent_hash((shash::AsciiPtr(parent_path)));
156  DirectoryEntry effective_entry(entry);
157  effective_entry.set_has_xattrs(!xattrs.IsEmpty());
158 
159  bool retval =
160  sql_insert_->BindPathHash(path_hash) &&
161  sql_insert_->BindParentPathHash(parent_hash) &&
162  sql_insert_->BindDirent(effective_entry);
163  assert(retval);
164  if (xattrs.IsEmpty()) {
165  retval = sql_insert_->BindXattrEmpty();
166  } else {
167  retval = sql_insert_->BindXattr(xattrs);
168  }
169  assert(retval);
170  retval = sql_insert_->Execute();
171  assert(retval);
172  sql_insert_->Reset();
173 
174  delta_counters_.Increment(effective_entry);
175 }
176 
177 
184 void WritableCatalog::RemoveEntry(const string &file_path) {
185  DirectoryEntry entry;
186  bool retval = LookupPath(PathString(file_path), &entry);
187  assert(retval);
188 
189  SetDirty();
190 
191  // If the entry used to be a chunked file... remove the chunks
192  if (entry.IsChunkedFile()) {
193  RemoveFileChunks(file_path);
194  }
195 
196  // remove the entry itself
197  shash::Md5 path_hash = shash::Md5(shash::AsciiPtr(file_path));
198  retval =
199  sql_unlink_->BindPathHash(path_hash) &&
200  sql_unlink_->Execute();
201  assert(retval);
202  sql_unlink_->Reset();
203 
204  delta_counters_.Decrement(entry);
205 }
206 
207 
208 void WritableCatalog::IncLinkcount(const string &path_within_group,
209  const int delta)
210 {
211  SetDirty();
212 
213  shash::Md5 path_hash = shash::Md5(shash::AsciiPtr(path_within_group));
214 
215  bool retval =
216  sql_inc_linkcount_->BindPathHash(path_hash) &&
217  sql_inc_linkcount_->BindDelta(delta) &&
219  assert(retval);
221 }
222 
223 
225  const XattrList &xattrs,
226  const shash::Md5 &path_hash) {
227  SetDirty();
228 
229  catalog::DirectoryEntry prev_entry;
230  bool retval = LookupMd5Path(path_hash, &prev_entry);
231  assert(retval);
232 
233  retval = sql_touch_->BindPathHash(path_hash) &&
234  sql_touch_->BindDirentBase(entry);
235  assert(retval);
236  if (xattrs.IsEmpty()) {
237  retval = sql_touch_->BindXattrEmpty();
238  if (prev_entry.HasXattrs())
239  delta_counters_.self.xattrs--;
240  } else {
241  retval = sql_touch_->BindXattr(xattrs);
242  if (!prev_entry.HasXattrs())
243  delta_counters_.self.xattrs++;
244  }
245  assert(retval);
246  retval = sql_touch_->Execute();
247  assert(retval);
248  sql_touch_->Reset();
249 }
250 
251 
253  const shash::Md5 &path_hash) {
254  SetDirty();
255 
256  bool retval =
257  sql_update_->BindPathHash(path_hash) &&
258  sql_update_->BindDirent(entry) &&
259  sql_update_->Execute();
260  assert(retval);
261  sql_update_->Reset();
262 }
263 
264 void WritableCatalog::AddFileChunk(const std::string &entry_path,
265  const FileChunk &chunk) {
266  SetDirty();
267 
268  shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
269 
270  LogCvmfs(kLogCatalog, kLogVerboseMsg, "adding chunk for %s from offset %ld "
271  "and chunk size: %ld bytes",
272  entry_path.c_str(),
273  chunk.offset(),
274  chunk.offset() + chunk.size());
275 
276  delta_counters_.self.file_chunks++;
277 
278  bool retval =
279  sql_chunk_insert_->BindPathHash(path_hash) &&
282  assert(retval);
284 }
285 
286 
291 void WritableCatalog::RemoveFileChunks(const std::string &entry_path) {
292  shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
293  bool retval;
294 
295  // subtract the number of chunks from the statistics counters
296  retval =
297  sql_chunks_count_->BindPathHash(path_hash) &&
299  assert(retval);
300  const int chunks_count = sql_chunks_count_->GetChunkCount();
301  delta_counters_.self.file_chunks -= chunks_count;
303 
304  // remove the chunks associated to `entry_path`
305  retval =
306  sql_chunks_remove_->BindPathHash(path_hash) &&
308  assert(retval);
310 }
311 
312 
317  database().SetProperty("last_modified", static_cast<uint64_t>(time(NULL)));
318 }
319 
320 
325  SetRevision(GetRevision() + 1);
326 }
327 
328 
329 void WritableCatalog::SetRevision(const uint64_t new_revision) {
330  database().SetProperty("revision", new_revision);
331 }
332 
333 
334 void WritableCatalog::SetBranch(const std::string &branch_name) {
335  database().SetProperty("branch", branch_name);
336 }
337 
338 
339 void WritableCatalog::SetTTL(const uint64_t new_ttl) {
340  database().SetProperty("TTL", new_ttl);
341 }
342 
343 
344 bool WritableCatalog::SetVOMSAuthz(const std::string &voms_authz) {
345  return database().SetVOMSAuthz(voms_authz);
346 }
347 
348 
353  database().SetProperty("previous_revision", hash.ToString());
354 }
355 
356 
360 void WritableCatalog::Partition(WritableCatalog *new_nested_catalog) {
361  // Create connection between parent and child catalogs
362  MakeTransitionPoint(new_nested_catalog->mountpoint().ToString());
363  new_nested_catalog->MakeNestedRoot();
364  delta_counters_.subtree.directories++; // Root directory in nested catalog
365 
366  // Move the present directory tree into the newly created nested catalog
367  // if we hit nested catalog mountpoints on the way, we return them through
368  // the passed list
369  vector<string> GrandChildMountpoints;
370  MoveToNested(new_nested_catalog->mountpoint().ToString(), new_nested_catalog,
371  &GrandChildMountpoints);
372 
373  // Nested catalog mountpoints found in the moved directory structure are now
374  // links to nested catalogs of the newly created nested catalog.
375  // Move these references into the new nested catalog
376  MoveCatalogsToNested(GrandChildMountpoints, new_nested_catalog);
377 }
378 
379 
380 void WritableCatalog::MakeTransitionPoint(const string &mountpoint) {
381  // Find the directory entry to edit
382  DirectoryEntry transition_entry;
383  bool retval = LookupPath(PathString(mountpoint.data(), mountpoint.length()),
384  &transition_entry);
385  assert(retval);
386 
387  assert(transition_entry.IsDirectory() &&
388  !transition_entry.IsNestedCatalogRoot());
389 
390  transition_entry.set_is_nested_catalog_mountpoint(true);
391  UpdateEntry(transition_entry, mountpoint);
392 }
393 
394 
396  DirectoryEntry root_entry;
397  bool retval = LookupPath(mountpoint(), &root_entry);
398  assert(retval);
399 
400  assert(root_entry.IsDirectory() && !root_entry.IsNestedCatalogMountpoint());
401 
402  root_entry.set_is_nested_catalog_root(true);
403  UpdateEntry(root_entry, mountpoint().ToString());
404 }
405 
406 
408  const string directory,
409  WritableCatalog *new_nested_catalog,
410  vector<string> *grand_child_mountpoints)
411 {
412  // After creating a new nested catalog we have to move all elements
413  // now contained by the new one. List and move them recursively.
414  DirectoryEntryList listing;
415  const bool resolve_magic_symlinks = false;
416  bool retval = ListingPath(PathString(directory), &listing,
417  resolve_magic_symlinks);
418  assert(retval);
419 
420  // Go through the listing
421  XattrList empty_xattrs;
422  for (DirectoryEntryList::const_iterator i = listing.begin(),
423  iEnd = listing.end(); i != iEnd; ++i)
424  {
425  const string full_path = i->GetFullPath(directory);
426 
427  // The entries are first inserted into the new catalog
428  if (i->HasXattrs()) {
429  XattrList xattrs;
430  retval = LookupXattrsPath(PathString(full_path), &xattrs);
431  assert(retval);
432  assert(!xattrs.IsEmpty());
433  new_nested_catalog->AddEntry(*i, xattrs, full_path);
434  } else {
435  new_nested_catalog->AddEntry(*i, empty_xattrs, full_path);
436  }
437 
438  // Then we check if we have some special cases:
439  if (i->IsNestedCatalogMountpoint()) {
440  grand_child_mountpoints->push_back(full_path);
441  } else if (i->IsDirectory()) {
442  // Recurse deeper into the directory tree
443  MoveToNestedRecursively(full_path, new_nested_catalog,
444  grand_child_mountpoints);
445  } else if (i->IsChunkedFile()) {
446  MoveFileChunksToNested(full_path, i->hash_algorithm(),
447  new_nested_catalog);
448  }
449 
450  // Remove the entry from the current catalog
451  RemoveEntry(full_path);
452  }
453 }
454 
455 
457  const vector<string> &nested_catalogs,
458  WritableCatalog *new_nested_catalog)
459 {
460  for (vector<string>::const_iterator i = nested_catalogs.begin(),
461  iEnd = nested_catalogs.end(); i != iEnd; ++i)
462  {
463  shash::Any hash_nested;
464  uint64_t size_nested;
465  bool retval = FindNested(PathString(*i), &hash_nested, &size_nested);
466  assert(retval);
467 
468  Catalog *attached_reference = NULL;
469  RemoveNestedCatalog(*i, &attached_reference);
470 
471  new_nested_catalog->InsertNestedCatalog(*i, attached_reference,
472  hash_nested, size_nested);
473  }
474 }
475 
476 
478  const std::string &full_path,
480  WritableCatalog *new_nested_catalog)
481 {
482  FileChunkList chunks;
483  ListPathChunks(PathString(full_path), algorithm, &chunks);
484  assert(chunks.size() > 0);
485 
486  for (unsigned i = 0; i < chunks.size(); ++i) {
487  new_nested_catalog->AddFileChunk(full_path, *chunks.AtPtr(i));
488  }
489 }
490 
491 
502 void WritableCatalog::InsertNestedCatalog(const string &mountpoint,
503  Catalog *attached_reference,
504  const shash::Any content_hash,
505  const uint64_t size)
506 {
507  const string hash_string = (!content_hash.IsNull()) ?
508  content_hash.ToString() : "";
509 
510  SqlCatalog stmt(database(), "INSERT INTO nested_catalogs (path, sha1, size) "
511  "VALUES (:p, :sha1, :size);");
512  bool retval =
513  stmt.BindText(1, mountpoint) &&
514  stmt.BindText(2, hash_string) &&
515  stmt.BindInt64(3, size) &&
516  stmt.Execute();
517  assert(retval);
518 
519  // If a reference of the in-memory object of the newly referenced
520  // catalog was passed, we add this to our own children
521  if (attached_reference != NULL)
522  AddChild(attached_reference);
523 
525 
526  delta_counters_.self.nested_catalogs++;
527 }
528 
529 
536  const string &mountpoint,
537  const shash::Any content_hash,
538  const uint64_t size)
539 {
540  SqlCatalog stmt(database(),
541  "INSERT INTO bind_mountpoints (path, sha1, size) "
542  "VALUES (:p, :sha1, :size);");
543  bool retval =
544  stmt.BindText(1, mountpoint) &&
545  stmt.BindText(2, content_hash.ToString()) &&
546  stmt.BindInt64(3, size) &&
547  stmt.Execute();
548  assert(retval);
549 }
550 
551 
561 void WritableCatalog::RemoveNestedCatalog(const string &mountpoint,
562  Catalog **attached_reference)
563 {
564  shash::Any dummy;
565  uint64_t dummy_size;
566  bool retval = FindNested(PathString(mountpoint.data(), mountpoint.length()),
567  &dummy, &dummy_size);
568  assert(retval);
569 
570  SqlCatalog stmt(database(),
571  "DELETE FROM nested_catalogs WHERE path = :p;");
572  retval =
573  stmt.BindText(1, mountpoint) &&
574  stmt.Execute();
575  assert(retval);
576 
577  // If the reference was successfully deleted, we also have to check whether
578  // there is also an attached reference in our in-memory data.
579  // In this case we remove the child and return it through **attached_reference
580  Catalog *child = FindChild(PathString(mountpoint));
581  if (child != NULL)
582  RemoveChild(child);
583  if (attached_reference != NULL)
584  *attached_reference = child;
585 
587 
588  delta_counters_.self.nested_catalogs--;
589 }
590 
591 
597 void WritableCatalog::RemoveBindMountpoint(const std::string &mountpoint) {
598  shash::Any dummy;
599  uint64_t dummy_size;
600  bool retval = FindNested(PathString(mountpoint.data(), mountpoint.length()),
601  &dummy, &dummy_size);
602  assert(retval);
603 
604  SqlCatalog stmt(database(),
605  "DELETE FROM bind_mountpoints WHERE path = :p;");
606  retval =
607  stmt.BindText(1, mountpoint) &&
608  stmt.Execute();
609  assert(retval);
610 }
611 
612 
620 void WritableCatalog::UpdateNestedCatalog(const std::string &path,
621  const shash::Any &hash,
622  const uint64_t size,
623  const DeltaCounters &child_counters) {
624  MutexLockGuard guard(lock_);
625  SetDirty();
626 
627  child_counters.PopulateToParent(&delta_counters_);
628 
629  const string hash_str = hash.ToString();
630  const string sql = "UPDATE nested_catalogs SET sha1 = :sha1, size = :size "
631  "WHERE path = :path;";
632  SqlCatalog stmt(database(), sql);
633 
634  bool retval =
635  stmt.BindText(1, hash_str) &&
636  stmt.BindInt64(2, size) &&
637  stmt.BindText(3, path) &&
638  stmt.Execute();
639 
641 
642  assert(retval);
643 }
644 
645 
647  assert(!IsRoot() && HasParent());
649 
650  CopyToParent();
651 
652  // Copy the nested catalog references
654 
655  // Fix counters in parent
657  Counters &counters = GetWritableCounters();
658  counters.ApplyDelta(delta_counters_);
659  counters.MergeIntoParent(&parent->delta_counters_);
660 
661  // Remove the nested catalog reference for this nested catalog.
662  // From now on this catalog will be dangling!
663  parent->RemoveNestedCatalog(this->mountpoint().ToString(), NULL);
664 }
665 
666 
668  assert(!IsRoot() && HasParent());
670 
671  // Remove the nested catalog reference for this nested catalog.
672  // From now on this catalog will be dangling!
673  parent->RemoveNestedCatalog(this->mountpoint().ToString(), NULL);
676 }
677 
678 
681 
682  // Obtain a list of all nested catalog references
683  const NestedCatalogList nested_catalog_references = ListOwnNestedCatalogs();
684 
685  // Go through the list and update the databases
686  // simultaneously we are checking if the referenced catalogs are currently
687  // attached and update the in-memory data structures as well
688  for (NestedCatalogList::const_iterator i = nested_catalog_references.begin(),
689  iEnd = nested_catalog_references.end(); i != iEnd; ++i)
690  {
691  Catalog *child = FindChild(i->mountpoint);
692  parent->InsertNestedCatalog(
693  i->mountpoint.ToString(), child, i->hash, i->size);
694  parent->delta_counters_.self.nested_catalogs--; // Will be fixed later
695  }
696 }
697 
699  // We could simply copy all entries from this database to the 'other' database
700  // BUT: 1. this would create collisions in hardlink group IDs.
701  // therefore we first update all hardlink group IDs to fit behind the
702  // ones in the 'other' database
703  // 2. the root entry of the nested catalog is present twice:
704  // 1. in the parent directory (as mount point) and
705  // 2. in the nested catalog (as root entry)
706  // therefore we delete the mount point from the parent before merging
707 
709 
710  // Update hardlink group IDs in this nested catalog.
711  // To avoid collisions we add the maximal present hardlink group ID in parent
712  // to all hardlink group IDs in the nested catalog.
713  const uint64_t offset = static_cast<uint64_t>(parent->GetMaxLinkId()) << 32;
714  const string update_link_ids =
715  "UPDATE catalog SET hardlinks = hardlinks + " + StringifyInt(offset) +
716  " WHERE hardlinks > (1 << 32);";
717 
718  SqlCatalog sql_update_link_ids(database(), update_link_ids);
719  bool retval = sql_update_link_ids.Execute();
720  assert(retval);
721 
722  // Remove the nested catalog root.
723  // It is already present in the parent.
724  RemoveEntry(this->mountpoint().ToString());
725 
726  // Now copy all DirectoryEntries to the 'other' catalog.
727  // There will be no data collisions, as we resolved them beforehand
728  if (dirty_)
729  Commit();
730  if (parent->dirty_)
731  parent->Commit();
732  SqlCatalog sql_attach(database(), "ATTACH '" + parent->database_path() + "' "
733  "AS other;");
734  retval = sql_attach.Execute();
735  assert(retval);
736  retval = SqlCatalog(database(), "INSERT INTO other.catalog "
737  "SELECT * FROM main.catalog;").Execute();
738  assert(retval);
739  retval = SqlCatalog(database(), "INSERT INTO other.chunks "
740  "SELECT * FROM main.chunks;").Execute();
741  assert(retval);
742  retval = SqlCatalog(database(), "DETACH other;").Execute();
743  assert(retval);
744  parent->SetDirty();
745 
746  // Change the just copied nested catalog root to an ordinary directory
747  // (the nested catalog is merged into it's parent)
748  DirectoryEntry old_root_entry;
749  retval = parent->LookupPath(this->mountpoint(), &old_root_entry);
750  assert(retval);
751 
752  assert(old_root_entry.IsDirectory() &&
753  old_root_entry.IsNestedCatalogMountpoint() &&
754  !old_root_entry.IsNestedCatalogRoot());
755 
756  // Remove the nested catalog root mark
757  old_root_entry.set_is_nested_catalog_mountpoint(false);
758  parent->UpdateEntry(old_root_entry, this->mountpoint().ToString());
759 }
760 
761 
766  const bool retval = delta_counters_.WriteToDatabase(database()) &&
768  assert(retval);
769 }
770 
771 
777  const CatalogDatabase &db = database();
778  bool needs_defragmentation = false;
779  double ratio = 0.0;
780  std::string reason;
781 
782  if ((ratio = db.GetFreePageRatio()) > kMaximalFreePageRatio) {
783  needs_defragmentation = true;
784  reason = "free pages";
785  } else if ((ratio = db.GetRowIdWasteRatio()) > kMaximalRowIdWasteRatio) {
786  needs_defragmentation = true;
787  reason = "wasted row IDs";
788  }
789 
790  if (needs_defragmentation) {
792  "Note: Catalog at %s gets defragmented (%.2f%% %s)... ",
793  (IsRoot()) ? "/" : mountpoint().c_str(),
794  ratio * 100.0,
795  reason.c_str());
796  if (!db.Vacuum()) {
797  PANIC(kLogStderr, "failed (SQLite: %s)", db.GetLastErrorMsg().c_str());
798  }
799  LogCvmfs(kLogCatalog, kLogStdout, "done");
800  }
801 }
802 
803 } // namespace catalog
void MoveFileChunksToNested(const std::string &full_path, const shash::Algorithms algorithm, WritableCatalog *new_nested_catalog)
Definition: catalog_rw.cc:477
void RemoveFileChunks(const std::string &entry_path)
Definition: catalog_rw.cc:291
const Counters & GetCounters() const
Definition: catalog.h:175
bool IsNull() const
Definition: hash.h:383
std::string GetLastErrorMsg() const
Definition: sql_impl.h:335
SqlDirentInsert * sql_insert_
Definition: catalog_rw.h:151
bool Execute()
Definition: sql.cc:42
bool IsRoot() const
Definition: catalog.h:193
bool Reset()
Definition: sql.cc:126
double GetFreePageRatio() const
Definition: sql_impl.h:406
bool BindText(const int index, const std::string &value)
Definition: sql.h:399
std::string database_path() const
Definition: catalog.h:184
bool BindDirentBase(const DirectoryEntryBase &entry)
Definition: catalog_sql.cc:883
bool IsDirectory() const
bool FetchRow()
Definition: sql.cc:62
bool ListPathChunks(const PathString &path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks) const
Definition: catalog.h:147
static const double kMaximalFreePageRatio
Definition: catalog_rw.h:110
bool IsChunkedFile() const
bool HasParent() const
Definition: catalog.h:200
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:620
#define PANIC(...)
Definition: exception.h:29
std::string ToString(const bool with_suffix=false) const
Definition: hash.h:249
void InsertBindMountpoint(const std::string &mountpoint, const shash::Any content_hash, const uint64_t size)
Definition: catalog_rw.cc:535
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:902
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:271
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:502
void RemoveBindMountpoint(const std::string &mountpoint)
Definition: catalog_rw.cc:597
virtual void InitPreparedStatements()
Definition: catalog.cc:98
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:224
assert((mem||(size==0))&&"Out Of Memory")
void Increment(const DirectoryEntry &dirent)
SqlChunksCount * sql_chunks_count_
Definition: catalog_rw.h:157
bool BindPathHash(const shash::Md5 &hash)
bool InitStandalone(const std::string &database_file)
Definition: catalog.cc:122
int GetChunkCount() const
void SetPreviousRevision(const shash::Any &hash)
Definition: catalog_rw.cc:352
Catalog * parent() const
Definition: catalog.h:180
SqlChunkInsert * sql_chunk_insert_
Definition: catalog_rw.h:155
void MoveToNestedRecursively(const std::string dir_structure_root, WritableCatalog *new_nested_catalog, std::vector< std::string > *grand_child_mountpoints)
Definition: catalog_rw.cc:407
Catalog * FindChild(const PathString &mountpoint) const
Definition: catalog.cc:808
SqlChunksRemove * sql_chunks_remove_
Definition: catalog_rw.h:156
void MakeTransitionPoint(const std::string &mountpoint)
Definition: catalog_rw.cc:380
SqlIncLinkcount * sql_inc_linkcount_
Definition: catalog_rw.h:159
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:177
bool WriteToDatabase(const CatalogDatabase &database) const
bool IsNestedCatalogMountpoint() const
bool BindPathHash(const shash::Md5 &hash)
bool BindXattr(const XattrList &xattrs)
Definition: catalog_sql.cc:907
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:528
void AddFileChunk(const std::string &entry_path, const FileChunk &chunk)
Definition: catalog_rw.cc:264
std::vector< DirectoryEntry > DirectoryEntryList
bool BindDelta(const int delta)
atomic_int32 dirty_children_
Definition: catalog_rw.h:166
bool HasXattrs() const
bool BindPathHash(const shash::Md5 &hash)
SqlDirentUpdate * sql_update_
Definition: catalog_rw.h:154
void SetTTL(const uint64_t new_ttl)
Definition: catalog_rw.cc:339
SqlMaxHardlinkGroup * sql_max_link_id_
Definition: catalog_rw.h:158
bool LookupXattrsPath(const PathString &path, XattrList *xattrs) const
Definition: catalog.h:128
bool LookupMd5Path(const shash::Md5 &md5path, DirectoryEntry *dirent) const
Definition: catalog.cc:327
void AddChild(Catalog *child)
Definition: catalog.cc:730
off_t offset() const
Definition: file_chunk.h:42
void PopulateToParent(DeltaCounters *parent) const
bool Vacuum() const
Definition: sql_impl.h:423
bool BindXattr(const XattrList &xattrs)
void Decrement(const DirectoryEntry &dirent)
void ResetNestedCatalogCacheUnprotected()
Definition: catalog.cc:681
bool SetVOMSAuthz(const std::string &)
Definition: catalog_sql.cc:381
PathString mountpoint() const
Definition: catalog.h:179
string StringifyInt(const int64_t value)
Definition: string.cc:78
WritableCatalog(const std::string &path, const shash::Any &catalog_hash, Catalog *parent, const bool is_not_root=false)
Definition: catalog_rw.cc:26
bool CommitTransaction() const
Definition: sql_impl.h:278
bool BindInt64(const int index, const sqlite3_int64 value)
Definition: sql.h:381
void RemoveChild(Catalog *child)
Definition: catalog.cc:743
bool SetProperty(const std::string &key, const T value)
Definition: sql_impl.h:325
static const double kMaximalRowIdWasteRatio
Definition: catalog_rw.h:111
void RemoveNestedCatalog(const std::string &mountpoint, Catalog **attached_reference)
Definition: catalog_rw.cc:561
bool SetVOMSAuthz(const std::string &voms_authz)
Definition: catalog_rw.cc:344
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:153
std::string ToString() const
Definition: shortstring.h:141
std::vector< NestedCatalog > NestedCatalogList
Definition: catalog.h:208
SqlDirentUnlink * sql_unlink_
Definition: catalog_rw.h:152
void SetBranch(const std::string &branch_name)
Definition: catalog_rw.cc:334
const NestedCatalogList ListOwnNestedCatalogs() const
Definition: catalog.cc:656
void Partition(WritableCatalog *new_nested_catalog)
Definition: catalog_rw.cc:360
ShortString< kDefaultMaxPath, 0 > PathString
Definition: shortstring.h:217
void SetRevision(const uint64_t new_revision)
Definition: catalog_rw.cc:329
size_t size() const
Definition: file_chunk.h:43
void MoveCatalogsToNested(const std::vector< std::string > &nested_catalogs, WritableCatalog *new_nested_catalog)
Definition: catalog_rw.cc:456
Definition: mutex.h:42
WritableCatalog * GetWritableParent() const
Definition: catalog_rw.h:136
DeltaCounters delta_counters_
Definition: catalog_rw.h:163
const CatalogDatabase & database() const
Definition: catalog.h:249
bool FindNested(const PathString &mountpoint, shash::Any *hash, uint64_t *size) const
Definition: catalog.cc:690
const int kLogVerboseMsg
bool ReadCatalogCounters()
Definition: catalog.cc:135
Counters & GetWritableCounters()
Definition: catalog.h:247
double GetRowIdWasteRatio() const
Definition: catalog_sql.cc:386
shash::Any hash() const
Definition: catalog.h:186
const char * c_str() const
Definition: shortstring.h:145
void RemoveEntry(const std::string &entry_path)
Definition: catalog_rw.cc:184
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:208
const Item * AtPtr(const size_t index) const
Definition: bigvector.h:55
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:252
void RemoveFromSubtree(const DeltaCounters &child)
bool BindPathHash(const shash::Md5 &hash)
size_t size() const
Definition: bigvector.h:121
bool BindDirent(const DirectoryEntry &entry)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
Definition: logging.cc:528