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  const bool retval =
93  SqlCatalog(database(), "PRAGMA foreign_keys = ON;").Execute();
94  assert(retval);
104 }
105 
106 
108  // no polymorphism: no up call (see Catalog.h -
109  // near the definition of this method)
110  delete sql_insert_;
111  delete sql_unlink_;
112  delete sql_touch_;
113  delete sql_update_;
114  delete sql_chunk_insert_;
115  delete sql_chunks_remove_;
116  delete sql_chunks_count_;
117  delete sql_max_link_id_;
118  delete sql_inc_linkcount_;
119 }
120 
121 
126  int result = -1;
127 
128  if (sql_max_link_id_->FetchRow()) {
129  result = sql_max_link_id_->GetMaxGroupId();
130  }
132 
133  return result;
134 }
135 
136 
143 void WritableCatalog::AddEntry(const DirectoryEntry &entry,
144  const XattrList &xattrs,
145  const string &entry_path,
146  const string &parent_path) {
147  SetDirty();
148 
149  LogCvmfs(kLogCatalog, kLogVerboseMsg, "add entry '%s' to '%s'",
150  entry_path.c_str(), mountpoint().c_str());
151 
152  const shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
153  const shash::Md5 parent_hash((shash::AsciiPtr(parent_path)));
154  DirectoryEntry effective_entry(entry);
155  effective_entry.set_has_xattrs(!xattrs.IsEmpty());
156 
157  bool retval = sql_insert_->BindPathHash(path_hash)
158  && sql_insert_->BindParentPathHash(parent_hash)
159  && sql_insert_->BindDirent(effective_entry);
160  assert(retval);
161  if (xattrs.IsEmpty()) {
162  retval = sql_insert_->BindXattrEmpty();
163  } else {
164  retval = sql_insert_->BindXattr(xattrs);
165  }
166  assert(retval);
167  retval = sql_insert_->Execute();
168  assert(retval);
169  sql_insert_->Reset();
170 
171  delta_counters_.Increment(effective_entry);
172 }
173 
174 
181 void WritableCatalog::RemoveEntry(const string &file_path) {
182  DirectoryEntry entry;
183  bool retval = LookupPath(PathString(file_path), &entry);
184  assert(retval);
185 
186  SetDirty();
187 
188  // If the entry used to be a chunked file... remove the chunks
189  if (entry.IsChunkedFile()) {
190  RemoveFileChunks(file_path);
191  }
192 
193  // remove the entry itself
194  const shash::Md5 path_hash = shash::Md5(shash::AsciiPtr(file_path));
195  retval = sql_unlink_->BindPathHash(path_hash) && sql_unlink_->Execute();
196  assert(retval);
197  sql_unlink_->Reset();
198 
199  delta_counters_.Decrement(entry);
200 }
201 
202 
203 void WritableCatalog::IncLinkcount(const string &path_within_group,
204  const int delta) {
205  SetDirty();
206 
207  const shash::Md5 path_hash = shash::Md5(shash::AsciiPtr(path_within_group));
208 
209  const bool retval = sql_inc_linkcount_->BindPathHash(path_hash) &&
210  sql_inc_linkcount_->BindDelta(delta) &&
212  assert(retval);
214 }
215 
216 
218  const XattrList &xattrs,
219  const shash::Md5 &path_hash) {
220  SetDirty();
221 
222  catalog::DirectoryEntry prev_entry;
223  bool retval = LookupMd5Path(path_hash, &prev_entry);
224  assert(retval);
225 
226  retval = sql_touch_->BindPathHash(path_hash)
227  && sql_touch_->BindDirentBase(entry);
228  assert(retval);
229  if (xattrs.IsEmpty()) {
230  retval = sql_touch_->BindXattrEmpty();
231  if (prev_entry.HasXattrs())
232  delta_counters_.self.xattrs--;
233  } else {
234  retval = sql_touch_->BindXattr(xattrs);
235  if (!prev_entry.HasXattrs())
236  delta_counters_.self.xattrs++;
237  }
238  assert(retval);
239  retval = sql_touch_->Execute();
240  assert(retval);
241  sql_touch_->Reset();
242 }
243 
244 
246  const shash::Md5 &path_hash) {
247  SetDirty();
248 
249  const bool retval = sql_update_->BindPathHash(path_hash) &&
251  assert(retval);
252  sql_update_->Reset();
253 }
254 
255 void WritableCatalog::AddFileChunk(const std::string &entry_path,
256  const FileChunk &chunk) {
257  SetDirty();
258 
259  const shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
260 
262  "adding chunk for %s from offset %ld "
263  "and chunk size: %ld bytes",
264  entry_path.c_str(), chunk.offset(), chunk.offset() + chunk.size());
265 
266  delta_counters_.self.file_chunks++;
267 
268  const bool retval = sql_chunk_insert_->BindPathHash(path_hash) &&
271  assert(retval);
273 }
274 
275 
280 void WritableCatalog::RemoveFileChunks(const std::string &entry_path) {
281  const shash::Md5 path_hash((shash::AsciiPtr(entry_path)));
282  bool retval;
283 
284  // subtract the number of chunks from the statistics counters
285  retval = sql_chunks_count_->BindPathHash(path_hash)
287  assert(retval);
288  const int chunks_count = sql_chunks_count_->GetChunkCount();
289  delta_counters_.self.file_chunks -= chunks_count;
291 
292  // remove the chunks associated to `entry_path`
293  retval = sql_chunks_remove_->BindPathHash(path_hash)
295  assert(retval);
297 }
298 
299 
304  database().SetProperty("last_modified", static_cast<uint64_t>(time(NULL)));
305 }
306 
307 
312 
313 
314 void WritableCatalog::SetRevision(const uint64_t new_revision) {
315  database().SetProperty("revision", new_revision);
316 }
317 
318 
319 void WritableCatalog::SetBranch(const std::string &branch_name) {
320  database().SetProperty("branch", branch_name);
321 }
322 
323 
324 void WritableCatalog::SetTTL(const uint64_t new_ttl) {
325  database().SetProperty("TTL", new_ttl);
326 }
327 
328 
329 bool WritableCatalog::SetVOMSAuthz(const std::string &voms_authz) {
330  return database().SetVOMSAuthz(voms_authz);
331 }
332 
333 
338  database().SetProperty("previous_revision", hash.ToString());
339 }
340 
341 
345 void WritableCatalog::Partition(WritableCatalog *new_nested_catalog) {
346  // Create connection between parent and child catalogs
347  MakeTransitionPoint(new_nested_catalog->mountpoint().ToString());
348  new_nested_catalog->MakeNestedRoot();
349  delta_counters_.subtree.directories++; // Root directory in nested catalog
350 
351  // Move the present directory tree into the newly created nested catalog
352  // if we hit nested catalog mountpoints on the way, we return them through
353  // the passed list
354  vector<string> GrandChildMountpoints;
355  MoveToNested(new_nested_catalog->mountpoint().ToString(), new_nested_catalog,
356  &GrandChildMountpoints);
357 
358  // Nested catalog mountpoints found in the moved directory structure are now
359  // links to nested catalogs of the newly created nested catalog.
360  // Move these references into the new nested catalog
361  MoveCatalogsToNested(GrandChildMountpoints, new_nested_catalog);
362 }
363 
364 
365 void WritableCatalog::MakeTransitionPoint(const string &mountpoint) {
366  // Find the directory entry to edit
367  DirectoryEntry transition_entry;
368  const bool retval = LookupPath(
369  PathString(mountpoint.data(), mountpoint.length()), &transition_entry);
370  assert(retval);
371 
372  assert(transition_entry.IsDirectory()
373  && !transition_entry.IsNestedCatalogRoot());
374 
375  transition_entry.set_is_nested_catalog_mountpoint(true);
376  UpdateEntry(transition_entry, mountpoint);
377 }
378 
379 
381  DirectoryEntry root_entry;
382  const bool retval = LookupPath(mountpoint(), &root_entry);
383  assert(retval);
384 
385  assert(root_entry.IsDirectory() && !root_entry.IsNestedCatalogMountpoint());
386 
387  root_entry.set_is_nested_catalog_root(true);
388  UpdateEntry(root_entry, mountpoint().ToString());
389 }
390 
391 
393  const string directory,
394  WritableCatalog *new_nested_catalog,
395  vector<string> *grand_child_mountpoints) {
396  // After creating a new nested catalog we have to move all elements
397  // now contained by the new one. List and move them recursively.
398  DirectoryEntryList listing;
399  const bool resolve_magic_symlinks = false;
400  bool retval = ListingPath(PathString(directory), &listing,
401  resolve_magic_symlinks);
402  assert(retval);
403 
404  // Go through the listing
405  const XattrList empty_xattrs;
406  for (DirectoryEntryList::const_iterator i = listing.begin(),
407  iEnd = listing.end();
408  i != iEnd;
409  ++i) {
410  const string full_path = i->GetFullPath(directory);
411 
412  // The entries are first inserted into the new catalog
413  if (i->HasXattrs()) {
414  XattrList xattrs;
415  retval = LookupXattrsPath(PathString(full_path), &xattrs);
416  assert(retval);
417  assert(!xattrs.IsEmpty());
418  new_nested_catalog->AddEntry(*i, xattrs, full_path);
419  } else {
420  new_nested_catalog->AddEntry(*i, empty_xattrs, full_path);
421  }
422 
423  // Then we check if we have some special cases:
424  if (i->IsNestedCatalogMountpoint()) {
425  grand_child_mountpoints->push_back(full_path);
426  } else if (i->IsDirectory()) {
427  // Recurse deeper into the directory tree
428  MoveToNestedRecursively(full_path, new_nested_catalog,
429  grand_child_mountpoints);
430  } else if (i->IsChunkedFile()) {
431  MoveFileChunksToNested(full_path, i->hash_algorithm(),
432  new_nested_catalog);
433  }
434 
435  // Remove the entry from the current catalog
436  RemoveEntry(full_path);
437  }
438 }
439 
440 
442  const vector<string> &nested_catalogs,
443  WritableCatalog *new_nested_catalog) {
444  for (vector<string>::const_iterator i = nested_catalogs.begin(),
445  iEnd = nested_catalogs.end();
446  i != iEnd;
447  ++i) {
448  shash::Any hash_nested;
449  uint64_t size_nested;
450  const bool retval = FindNested(PathString(*i), &hash_nested, &size_nested);
451  assert(retval);
452 
453  Catalog *attached_reference = NULL;
454  RemoveNestedCatalog(*i, &attached_reference);
455 
456  new_nested_catalog->InsertNestedCatalog(*i, attached_reference, hash_nested,
457  size_nested);
458  }
459 }
460 
461 
463  const std::string &full_path,
465  WritableCatalog *new_nested_catalog) {
466  FileChunkList chunks;
467  ListPathChunks(PathString(full_path), algorithm, &chunks);
468  assert(chunks.size() > 0);
469 
470  for (unsigned i = 0; i < chunks.size(); ++i) {
471  new_nested_catalog->AddFileChunk(full_path, *chunks.AtPtr(i));
472  }
473 }
474 
475 
486 void WritableCatalog::InsertNestedCatalog(const string &mountpoint,
487  Catalog *attached_reference,
488  const shash::Any content_hash,
489  const uint64_t size) {
490  const string hash_string = (!content_hash.IsNull()) ? content_hash.ToString()
491  : "";
492 
493  SqlCatalog stmt(database(), "INSERT INTO nested_catalogs (path, sha1, size) "
494  "VALUES (:p, :sha1, :size);");
495  const bool retval = stmt.BindText(1, mountpoint) &&
496  stmt.BindText(2, hash_string) &&
497  stmt.BindInt64(3, size) && stmt.Execute();
498  assert(retval);
499 
500  // If a reference of the in-memory object of the newly referenced
501  // catalog was passed, we add this to our own children
502  if (attached_reference != NULL)
503  AddChild(attached_reference);
504 
506 
507  delta_counters_.self.nested_catalogs++;
508 }
509 
510 
516 void WritableCatalog::InsertBindMountpoint(const string &mountpoint,
517  const shash::Any content_hash,
518  const uint64_t size) {
519  SqlCatalog stmt(database(),
520  "INSERT INTO bind_mountpoints (path, sha1, size) "
521  "VALUES (:p, :sha1, :size);");
522  const bool retval = stmt.BindText(1, mountpoint) &&
523  stmt.BindText(2, content_hash.ToString()) &&
524  stmt.BindInt64(3, size) && stmt.Execute();
525  assert(retval);
526 }
527 
528 
538 void WritableCatalog::RemoveNestedCatalog(const string &mountpoint,
539  Catalog **attached_reference) {
540  shash::Any dummy;
541  uint64_t dummy_size;
542  bool retval = FindNested(PathString(mountpoint.data(), mountpoint.length()),
543  &dummy, &dummy_size);
544  assert(retval);
545 
546  SqlCatalog stmt(database(), "DELETE FROM nested_catalogs WHERE path = :p;");
547  retval = stmt.BindText(1, mountpoint) && stmt.Execute();
548  assert(retval);
549 
550  // If the reference was successfully deleted, we also have to check whether
551  // there is also an attached reference in our in-memory data.
552  // In this case we remove the child and return it through **attached_reference
553  Catalog *child = FindChild(PathString(mountpoint));
554  if (child != NULL)
555  RemoveChild(child);
556  if (attached_reference != NULL)
557  *attached_reference = child;
558 
560 
561  delta_counters_.self.nested_catalogs--;
562 }
563 
564 
570 void WritableCatalog::RemoveBindMountpoint(const std::string &mountpoint) {
571  shash::Any dummy;
572  uint64_t dummy_size;
573  bool retval = FindNested(PathString(mountpoint.data(), mountpoint.length()),
574  &dummy, &dummy_size);
575  assert(retval);
576 
577  SqlCatalog stmt(database(), "DELETE FROM bind_mountpoints WHERE path = :p;");
578  retval = stmt.BindText(1, mountpoint) && stmt.Execute();
579  assert(retval);
580 }
581 
582 
590 void WritableCatalog::UpdateNestedCatalog(const std::string &path,
591  const shash::Any &hash,
592  const uint64_t size,
593  const DeltaCounters &child_counters) {
594  const MutexLockGuard guard(lock_);
595  SetDirty();
596 
597  child_counters.PopulateToParent(&delta_counters_);
598 
599  const string hash_str = hash.ToString();
600  const string sql = "UPDATE nested_catalogs SET sha1 = :sha1, size = :size "
601  "WHERE path = :path;";
602  SqlCatalog stmt(database(), sql);
603 
604  const bool retval = stmt.BindText(1, hash_str) && stmt.BindInt64(2, size) &&
605  stmt.BindText(3, path) && stmt.Execute();
606 
608 
609  assert(retval);
610 }
611 
612 
614  assert(!IsRoot() && HasParent());
616 
617  CopyToParent();
618 
619  // Copy the nested catalog references
621 
622  // Fix counters in parent
624  Counters &counters = GetWritableCounters();
625  counters.ApplyDelta(delta_counters_);
626  counters.MergeIntoParent(&parent->delta_counters_);
627 
628  // Remove the nested catalog reference for this nested catalog.
629  // From now on this catalog will be dangling!
630  parent->RemoveNestedCatalog(this->mountpoint().ToString(), NULL);
631 }
632 
633 
635  assert(!IsRoot() && HasParent());
637 
638  // Remove the nested catalog reference for this nested catalog.
639  // From now on this catalog will be dangling!
640  parent->RemoveNestedCatalog(this->mountpoint().ToString(), NULL);
643 }
644 
645 
648 
649  // Obtain a list of all nested catalog references
650  const NestedCatalogList nested_catalog_references = ListOwnNestedCatalogs();
651 
652  // Go through the list and update the databases
653  // simultaneously we are checking if the referenced catalogs are currently
654  // attached and update the in-memory data structures as well
655  for (NestedCatalogList::const_iterator i = nested_catalog_references.begin(),
656  iEnd = nested_catalog_references.end();
657  i != iEnd;
658  ++i) {
659  Catalog *child = FindChild(i->mountpoint);
660  parent->InsertNestedCatalog(i->mountpoint.ToString(), child, i->hash,
661  i->size);
662  parent->delta_counters_.self.nested_catalogs--; // Will be fixed later
663  }
664 }
665 
667  // We could simply copy all entries from this database to the 'other' database
668  // BUT: 1. this would create collisions in hardlink group IDs.
669  // therefore we first update all hardlink group IDs to fit behind the
670  // ones in the 'other' database
671  // 2. the root entry of the nested catalog is present twice:
672  // 1. in the parent directory (as mount point) and
673  // 2. in the nested catalog (as root entry)
674  // therefore we delete the mount point from the parent before merging
675 
677 
678  // Update hardlink group IDs in this nested catalog.
679  // To avoid collisions we add the maximal present hardlink group ID in parent
680  // to all hardlink group IDs in the nested catalog.
681  const uint64_t offset = static_cast<uint64_t>(parent->GetMaxLinkId()) << 32;
682  const string update_link_ids = "UPDATE catalog SET hardlinks = hardlinks + "
683  + StringifyInt(offset)
684  + " WHERE hardlinks > (1 << 32);";
685 
686  SqlCatalog sql_update_link_ids(database(), update_link_ids);
687  bool retval = sql_update_link_ids.Execute();
688  assert(retval);
689 
690  // Remove the nested catalog root.
691  // It is already present in the parent.
692  RemoveEntry(this->mountpoint().ToString());
693 
694  // Now copy all DirectoryEntries to the 'other' catalog.
695  // There will be no data collisions, as we resolved them beforehand
696  if (dirty_)
697  Commit();
698  if (parent->dirty_)
699  parent->Commit();
700  SqlCatalog sql_attach(database(), "ATTACH '" + parent->database_path()
701  + "' "
702  "AS other;");
703  retval = sql_attach.Execute();
704  assert(retval);
705  retval = SqlCatalog(database(), "INSERT INTO other.catalog "
706  "SELECT * FROM main.catalog;")
707  .Execute();
708  assert(retval);
709  retval = SqlCatalog(database(), "INSERT INTO other.chunks "
710  "SELECT * FROM main.chunks;")
711  .Execute();
712  assert(retval);
713  retval = SqlCatalog(database(), "DETACH other;").Execute();
714  assert(retval);
715  parent->SetDirty();
716 
717  // Change the just copied nested catalog root to an ordinary directory
718  // (the nested catalog is merged into it's parent)
719  DirectoryEntry old_root_entry;
720  retval = parent->LookupPath(this->mountpoint(), &old_root_entry);
721  assert(retval);
722 
723  assert(old_root_entry.IsDirectory()
724  && old_root_entry.IsNestedCatalogMountpoint()
725  && !old_root_entry.IsNestedCatalogRoot());
726 
727  // Remove the nested catalog root mark
728  old_root_entry.set_is_nested_catalog_mountpoint(false);
729  parent->UpdateEntry(old_root_entry, this->mountpoint().ToString());
730 }
731 
732 
737  const bool retval = delta_counters_.WriteToDatabase(database())
738  && ReadCatalogCounters();
739  assert(retval);
740 }
741 
742 
748  const CatalogDatabase &db = database();
749  bool needs_defragmentation = false;
750  double ratio = 0.0;
751  std::string reason;
752 
753  if ((ratio = db.GetFreePageRatio()) > kMaximalFreePageRatio) {
754  needs_defragmentation = true;
755  reason = "free pages";
756  } else if ((ratio = db.GetRowIdWasteRatio()) > kMaximalRowIdWasteRatio) {
757  needs_defragmentation = true;
758  reason = "wasted row IDs";
759  }
760 
761  if (needs_defragmentation) {
763  "Note: Catalog at %s gets defragmented (%.2f%% %s)... ",
764  (IsRoot()) ? "/" : mountpoint().c_str(), ratio * 100.0,
765  reason.c_str());
766  if (!db.Vacuum()) {
767  PANIC(kLogStderr, "failed (SQLite: %s)", db.GetLastErrorMsg().c_str());
768  }
769  LogCvmfs(kLogCatalog, kLogStdout, "done");
770  }
771 }
772 
773 } // namespace catalog
void MoveFileChunksToNested(const std::string &full_path, const shash::Algorithms algorithm, WritableCatalog *new_nested_catalog)
Definition: catalog_rw.cc:462
void RemoveFileChunks(const std::string &entry_path)
Definition: catalog_rw.cc:280
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:886
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:125
void UpdateNestedCatalog(const std::string &path, const shash::Any &hash, const uint64_t size, const DeltaCounters &child_counters)
Definition: catalog_rw.cc:590
#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:516
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: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:486
void RemoveBindMountpoint(const std::string &mountpoint)
Definition: catalog_rw.cc:570
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:217
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:337
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:392
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:365
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: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:517
void AddFileChunk(const std::string &entry_path, const FileChunk &chunk)
Definition: catalog_rw.cc:255
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:324
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:393
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:538
bool SetVOMSAuthz(const std::string &voms_authz)
Definition: catalog_rw.cc:329
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:319
const NestedCatalogList ListOwnNestedCatalogs() const
Definition: catalog.cc:646
void Partition(WritableCatalog *new_nested_catalog)
Definition: catalog_rw.cc:345
ShortString< kDefaultMaxPath, 0 > PathString
Definition: shortstring.h:213
void SetRevision(const uint64_t new_revision)
Definition: catalog_rw.cc:314
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:441
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:398
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:181
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:203
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:245
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