![]() |
CernVM-FS
2.11.0
|
#include <catalog.h>
Public Types | |
typedef std::vector< CatalogT * > | CatalogList |
typedef CatalogT | catalog_t |
Public Member Functions | |
AbstractCatalogManager (perf::Statistics *statistics) | |
virtual | ~AbstractCatalogManager () |
void | SetInodeAnnotation (InodeAnnotation *new_annotation) |
virtual bool | Init () |
LoadError | Remount (const bool dry_run) |
LoadError | ChangeRoot (const shash::Any &root_hash) |
void | DetachNested () |
bool | LookupPath (const PathString &path, const LookupOptions options, DirectoryEntry *entry) |
bool | LookupPath (const std::string &path, const LookupOptions options, DirectoryEntry *entry) |
bool | LookupXattrs (const PathString &path, XattrList *xattrs) |
bool | LookupNested (const PathString &path, PathString *mountpoint, shash::Any *hash, uint64_t *size) |
bool | ListCatalogSkein (const PathString &path, std::vector< PathString > *result_list) |
bool | Listing (const PathString &path, DirectoryEntryList *listing, const bool expand_symlink) |
bool | Listing (const PathString &path, DirectoryEntryList *listing) |
bool | Listing (const std::string &path, DirectoryEntryList *listing) |
bool | ListingStat (const PathString &path, StatEntryList *listing) |
bool | ListFileChunks (const PathString &path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks) |
void | SetOwnerMaps (const OwnerMap &uid_map, const OwnerMap &gid_map) |
void | SetCatalogWatermark (unsigned limit) |
shash::Any | GetNestedCatalogHash (const PathString &mountpoint) |
Statistics | statistics () const |
uint64_t | inode_gauge () |
bool | volatile_flag () const |
uint64_t | GetRevision () const |
uint64_t | GetTTL () const |
bool | HasExplicitTTL () const |
bool | GetVOMSAuthz (std::string *authz) const |
int | GetNumCatalogs () const |
std::string | PrintHierarchy () const |
std::string | PrintAllMemStatistics () const |
inode_t | GetRootInode () const |
CatalogT * | GetRootCatalog () const |
inode_t | MangleInode (const inode_t inode) const |
catalog::Counters | LookupCounters (const PathString &path, std::string *subcatalog_path, shash::Any *hash) |
Static Public Attributes | |
static const inode_t | kInodeOffset = 255 |
Protected Member Functions | |
virtual LoadError | LoadCatalog (const PathString &mountpoint, const shash::Any &hash, std::string *catalog_path, shash::Any *catalog_hash)=0 |
virtual void | UnloadCatalog (const CatalogT *catalog) |
virtual void | ActivateCatalog (CatalogT *catalog) |
const std::vector< CatalogT * > & | GetCatalogs () const |
virtual CatalogT * | CreateCatalog (const PathString &mountpoint, const shash::Any &catalog_hash, CatalogT *parent_catalog)=0 |
CatalogT * | MountCatalog (const PathString &mountpoint, const shash::Any &hash, CatalogT *parent_catalog) |
bool | MountSubtree (const PathString &path, const CatalogT *entry_point, bool can_listing, CatalogT **leaf_catalog) |
CatalogT * | LoadFreeCatalog (const PathString &mountpoint, const shash::Any &hash) |
bool | AttachCatalog (const std::string &db_path, CatalogT *new_catalog) |
void | DetachCatalog (CatalogT *catalog) |
void | DetachSubtree (CatalogT *catalog) |
void | DetachSiblings (const PathString ¤t_tree) |
void | DetachAll () |
bool | IsAttached (const PathString &root_path, CatalogT **attached_catalog) const |
CatalogT * | FindCatalog (const PathString &path) const |
void | ReadLock () const |
void | WriteLock () const |
void | Unlock () const |
virtual void | EnforceSqliteMemLimit () |
![]() | |
SingleCopy () | |
Private Member Functions | |
void | CheckInodeWatermark () |
std::string | PrintHierarchyRecursively (const CatalogT *catalog, const int level) const |
std::string | PrintMemStatsRecursively (const CatalogT *catalog) const |
InodeRange | AcquireInodes (uint64_t size) |
void | ReleaseInodes (const InodeRange chunk) |
Private Attributes | |
CatalogList | catalogs_ |
int | inode_watermark_status_ |
uint64_t | inode_gauge_ |
uint64_t | revision_cache_ |
unsigned | catalog_watermark_ |
bool | volatile_flag_ |
bool | has_authz_cache_ |
std::string | authz_cache_ |
uint64_t | incarnation_ |
InodeAnnotation * | inode_annotation_ |
pthread_rwlock_t * | rwlock_ |
Statistics | statistics_ |
pthread_key_t | pkey_sqlitemem_ |
OwnerMap | uid_map_ |
OwnerMap | gid_map_ |
This class provides the read-only interface to a tree of catalogs representing a (subtree of a) repository. Mostly lookup functions filling DirectoryEntry objects. Reloading of expired catalogs, attaching of nested catalogs and delegating of lookups to the appropriate catalog is done transparently.
The loading / creating of catalogs is up to derived classes.
CatalogT is either Catalog or MockCatalog.
Usage: DerivedCatalogManager *catalog_manager = new DerivedCatalogManager(); catalog_manager->Init(); catalog_manager->Lookup(<inode>, &<result_entry>);
typedef CatalogT catalog::AbstractCatalogManager< CatalogT >::catalog_t |
Definition at line 123 of file catalog_mgr.h.
typedef std::vector<CatalogT*> catalog::AbstractCatalogManager< CatalogT >::CatalogList |
Definition at line 122 of file catalog_mgr.h.
|
explicit |
|
virtual |
Definition at line 48 of file catalog_mgr_impl.h.
|
private |
Assigns the next free numbers in the 64 bit space
Definition at line 731 of file catalog_mgr_impl.h.
|
inlineprotectedvirtual |
Reimplemented in catalog::WritableCatalogManager, and catalog::ClientCatalogManager.
Definition at line 221 of file catalog_mgr.h.
|
protected |
Attaches a newly created catalog.
db_path | the file on a local file system containing the database |
new_catalog | the catalog to attach to this CatalogManager |
Definition at line 943 of file catalog_mgr_impl.h.
LoadError catalog::AbstractCatalogManager< CatalogT >::ChangeRoot | ( | const shash::Any & | root_hash | ) |
Remounts to the given hash
Definition at line 156 of file catalog_mgr_impl.h.
Referenced by FuseRemounter::TryFinish().
|
private |
Definition at line 77 of file catalog_mgr_impl.h.
|
protectedpure virtual |
Create a new Catalog object. Every derived class has to implement this and return a newly created (derived) Catalog structure of it's desired type.
mountpoint | the future mountpoint of the catalog to create |
catalog_hash | the content hash of the catalog database |
parent_catalog | the parent of the catalog to create |
Implemented in catalog::WritableCatalogManager, catalog::ClientCatalogManager, and catalog::SimpleCatalogManager.
|
inlineprotected |
Definition at line 251 of file catalog_mgr.h.
|
protected |
Removes a catalog from this CatalogManager, the catalog pointer is freed if the call succeeds. This method can create dangling children if a catalog in the middle of a tree is removed.
catalog | the catalog to detach |
Definition at line 995 of file catalog_mgr_impl.h.
void catalog::AbstractCatalogManager< CatalogT >::DetachNested | ( | ) |
Detaches everything except the root catalog
Definition at line 195 of file catalog_mgr_impl.h.
Referenced by TalkManager::MainResponder(), and quota::MainUnpinListener().
|
protected |
Detaches all nested catalogs that are not on a prefix of the given tree. Used when the catalog_watermark_ is surpassed.
Definition at line 1044 of file catalog_mgr_impl.h.
|
protected |
Removes a catalog (and all of it's children) from this CatalogManager. The given catalog and all children are freed, if this call succeeds.
catalog | the catalog to detach |
Definition at line 1024 of file catalog_mgr_impl.h.
Referenced by catalog::AbstractCatalogManager< Catalog >::DetachAll().
|
protectedvirtual |
Reimplemented in catalog::WritableCatalogManager.
Definition at line 1125 of file catalog_mgr_impl.h.
|
protected |
Find the catalog leaf in the tree that fits the path. The path might be served by a not yet loaded nested catalog.
path | the path a catalog is searched for |
Definition at line 762 of file catalog_mgr_impl.h.
Referenced by catalog::WritableCatalogManager::FindCatalog().
|
inlineprotected |
Definition at line 222 of file catalog_mgr.h.
Referenced by catalog::CatalogBalancer< CatalogMgrT >::Balance().
shash::Any catalog::AbstractCatalogManager< CatalogT >::GetNestedCatalogHash | ( | const PathString & | mountpoint | ) |
Returns the NULL hash if the nested catalog is not found.
Definition at line 219 of file catalog_mgr_impl.h.
int catalog::AbstractCatalogManager< CatalogT >::GetNumCatalogs | ( | ) | const |
Definition at line 707 of file catalog_mgr_impl.h.
Referenced by NClgMagicXattr::PrepareValueFenced().
uint64_t catalog::AbstractCatalogManager< CatalogT >::GetRevision | ( | ) | const |
Definition at line 668 of file catalog_mgr_impl.h.
Referenced by LibContext::GetRevision(), Init(), TalkManager::MainResponder(), RevisionMagicXattr::PrepareValueFenced(), cvmfs::PrintInodeGeneration(), LibContext::Remount(), and FuseRemounter::TryFinish().
|
inline |
Definition at line 195 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< Catalog >::DetachAll(), and RepoCountersMagicXattr::PrepareValueFenced().
|
inline |
Get the inode number of the root DirectoryEntry ('root' means the root of the whole file system)
Definition at line 191 of file catalog_mgr.h.
Referenced by cvmfs::cvmfs_lookup(), cvmfs::cvmfs_opendir(), cvmfs::GetDirentForInode(), cvmfs::GetPathForInode(), LibContext::ListDirectory(), catalog::AbstractCatalogManager< Catalog >::MangleInode(), and cvmfs::MayBeInPageCacheTracker().
uint64_t catalog::AbstractCatalogManager< CatalogT >::GetTTL | ( | ) | const |
Definition at line 698 of file catalog_mgr_impl.h.
Referenced by MountPoint::GetEffectiveTtlSec().
bool catalog::AbstractCatalogManager< CatalogT >::GetVOMSAuthz | ( | std::string * | authz | ) | const |
Definition at line 678 of file catalog_mgr_impl.h.
Referenced by MountPoint::ReEvaluateAuthz().
bool catalog::AbstractCatalogManager< CatalogT >::HasExplicitTTL | ( | ) | const |
Definition at line 689 of file catalog_mgr_impl.h.
|
virtual |
Initializes the CatalogManager and loads and attaches the root entry.
Definition at line 98 of file catalog_mgr_impl.h.
Referenced by publish::ConstructSyncManagers(), MountPoint::CreateCatalogManager(), publish::GetSimpleCatalogManager(), swissknife::Ingest::Main(), swissknife::CommandApplyDirtab::Main(), and swissknife::CommandSync::Main().
|
inline |
Definition at line 174 of file catalog_mgr.h.
Referenced by SaveState().
|
protected |
Checks if a searched catalog is already mounted to this CatalogManager
root_path | the root path of the searched catalog |
attached_catalog | is set to the searched catalog, if not NULL |
Definition at line 787 of file catalog_mgr_impl.h.
bool catalog::AbstractCatalogManager< CatalogT >::ListCatalogSkein | ( | const PathString & | path, |
std::vector< PathString > * | result_list | ||
) |
Create a listing of the parents, catalog, and children of the catalog that serves the specified path. If the path specified is a catalog mountpoint the catalog at that point is mounted and returned.
path | the path to find in the catalogs |
result_list | the list where the results will be added. |
Definition at line 420 of file catalog_mgr_impl.h.
Referenced by LibContext::ListNestedCatalogs().
bool catalog::AbstractCatalogManager< CatalogT >::ListFileChunks | ( | const PathString & | path, |
const shash::Algorithms | interpret_hashes_as, | ||
FileChunkList * | chunks | ||
) |
Collect file chunks (if exist)
path | the path of the directory to list |
interpret_hashes_as | hash of the directory entry (by convention the same than the chunk hashes) |
Definition at line 595 of file catalog_mgr_impl.h.
Referenced by cvmfs::cvmfs_open(), cvmfs::Evict(), LibContext::GetExtAttr(), LibContext::Open(), cvmfs::Pin(), ChunkListMagicXattr::PrepareValueFenced(), and ChunksMagicXattr::PrepareValueFenced().
bool catalog::AbstractCatalogManager< CatalogT >::Listing | ( | const PathString & | path, |
DirectoryEntryList * | listing, | ||
const bool | expand_symlink | ||
) |
Do a listing of the specified directory.
path | the path of the directory to list |
listing | the resulting DirectoryEntryList |
Definition at line 519 of file catalog_mgr_impl.h.
Referenced by catalog::AbstractCatalogManager< Catalog >::Listing(), and catalog::VirtualCatalog::RemoveRecursively().
|
inline |
Definition at line 155 of file catalog_mgr.h.
|
inline |
Definition at line 158 of file catalog_mgr.h.
bool catalog::AbstractCatalogManager< CatalogT >::ListingStat | ( | const PathString & | path, |
StatEntryList * | listing | ||
) |
Do a listing of the specified directory, return only struct stat values.
path | the path of the directory to list |
listing | the resulting StatEntryList |
Definition at line 557 of file catalog_mgr_impl.h.
Referenced by cvmfs::cvmfs_opendir(), LibContext::ListDirectory(), and LibContext::ListDirectoryStat().
|
protectedpure virtual |
Load the catalog and return a file name and the catalog hash. Derived class can decide if it wants to use the hash or the path. Both the input as well as the output hash can be 0.
Implemented in catalog::ClientCatalogManager, and catalog::SimpleCatalogManager.
|
protected |
Load a catalog file as a freestanding Catalog object. Loading of catalogs is implemented by derived classes.
Definition at line 918 of file catalog_mgr_impl.h.
catalog::Counters catalog::AbstractCatalogManager< CatalogT >::LookupCounters | ( | const PathString & | path, |
std::string * | subcatalog_path, | ||
shash::Any * | hash | ||
) |
bool catalog::AbstractCatalogManager< CatalogT >::LookupNested | ( | const PathString & | path, |
PathString * | mountpoint, | ||
shash::Any * | hash, | ||
uint64_t * | size | ||
) |
Perform a lookup for Nested Catalog that serves this path. If the path specified is a catalog mountpoint the catalog at that point is mounted and returned.
path | the path to find in the catalogs |
mountpoint | the path to the nested catalog found |
hash | the hash of the nested catalog found |
size | the size of the nested catalog, 0 for root. Root is not a nested catalog in the database. |
Definition at line 356 of file catalog_mgr_impl.h.
Referenced by LibContext::GetNestedCatalogAttr().
bool catalog::AbstractCatalogManager< CatalogT >::LookupPath | ( | const PathString & | path, |
const LookupOptions | options, | ||
DirectoryEntry * | dirent | ||
) |
Perform a lookup for a specific DirectoryEntry in the catalogs.
path | the path to find in the catalogs |
options | whether to perform another lookup to get the parent entry, too |
dirent | the resulting DirectoryEntry, or special Negative entry Note: can be set to zero if the result is not important |
Definition at line 246 of file catalog_mgr_impl.h.
Referenced by catalog::CatalogBalancer< CatalogMgrT >::AddCatalogMarker(), cvmfs::cvmfs_getxattr(), cvmfs::cvmfs_open(), catalog::VirtualCatalog::EnsurePresence(), swissknife::CommandApplyDirtab::FilterCandidatesFromGlobResult(), cvmfs::FixupOpenInode(), cvmfs::GetDirentForInode(), LibContext::GetDirentForPath(), cvmfs::GetDirentForPath(), catalog::AbstractCatalogManager< Catalog >::LookupPath(), and catalog::VirtualCatalog::Remove().
|
inline |
Definition at line 137 of file catalog_mgr.h.
bool catalog::AbstractCatalogManager< CatalogT >::LookupXattrs | ( | const PathString & | path, |
XattrList * | xattrs | ||
) |
Definition at line 481 of file catalog_mgr_impl.h.
Referenced by cvmfs::cvmfs_getxattr(), cvmfs::cvmfs_listxattr(), and LibContext::GetExtAttr().
|
inline |
Inodes are ambiquitous under some circumstances, to prevent problems they must be passed through this method first
inode | the raw inode |
Definition at line 202 of file catalog_mgr.h.
Referenced by cvmfs::cvmfs_forget(), cvmfs::cvmfs_getattr(), cvmfs::cvmfs_getxattr(), cvmfs::cvmfs_listxattr(), cvmfs::cvmfs_lookup(), cvmfs::cvmfs_open(), cvmfs::cvmfs_opendir(), cvmfs::cvmfs_read(), cvmfs::cvmfs_readdir(), cvmfs::cvmfs_readlink(), cvmfs::cvmfs_release(), cvmfs::cvmfs_releasedir(), and cvmfs::cvmfs_statfs().
|
protected |
Load a catalog file and attach it to the tree of Catalog objects. Loading of catalogs is implemented by derived classes.
Definition at line 876 of file catalog_mgr_impl.h.
|
protected |
Recursively mounts all nested catalogs required to serve a path. If leaf_catalog is NULL, just indicate if it is necessary to load a nested catalog for the given path. The final leaf nested catalog is returned. The is_listable parameter is relevant if path is a nested catalog. Only if is_listable is true, the nested catalog will be used; otherwise the parent with the transaction point is sufficient.
Definition at line 812 of file catalog_mgr_impl.h.
std::string catalog::AbstractCatalogManager< CatalogT >::PrintAllMemStatistics | ( | ) | const |
Statistics from all catalogs
Definition at line 1115 of file catalog_mgr_impl.h.
Referenced by TalkManager::MainResponder().
string catalog::AbstractCatalogManager< CatalogT >::PrintHierarchy | ( | ) | const |
Gets a formatted tree of the currently attached catalogs
Definition at line 719 of file catalog_mgr_impl.h.
Referenced by TalkManager::MainResponder().
|
private |
Formats the catalog hierarchy
Definition at line 1070 of file catalog_mgr_impl.h.
|
private |
Definition at line 1096 of file catalog_mgr_impl.h.
|
inlineprotected |
Definition at line 257 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< Catalog >::inode_gauge().
|
private |
Called if a catalog is detached which renders the associated InodeChunk invalid.
chunk | the InodeChunk to be freed |
Definition at line 750 of file catalog_mgr_impl.h.
LoadError catalog::AbstractCatalogManager< CatalogT >::Remount | ( | const bool | dry_run | ) |
Remounts the root catalog if necessary. If a newer root catalog exists, it is mounted and replaces the currently mounted tree (all existing catalogs are detached)
Definition at line 118 of file catalog_mgr_impl.h.
Referenced by LibContext::Remount(), and FuseRemounter::TryFinish().
void catalog::AbstractCatalogManager< CatalogT >::SetCatalogWatermark | ( | unsigned | limit | ) |
Definition at line 72 of file catalog_mgr_impl.h.
Referenced by MountPoint::CreateCatalogManager().
void catalog::AbstractCatalogManager< CatalogT >::SetInodeAnnotation | ( | InodeAnnotation * | new_annotation | ) |
Definition at line 56 of file catalog_mgr_impl.h.
Referenced by MountPoint::SetupInodeAnnotation().
void catalog::AbstractCatalogManager< CatalogT >::SetOwnerMaps | ( | const OwnerMap & | uid_map, |
const OwnerMap & | gid_map | ||
) |
Definition at line 64 of file catalog_mgr_impl.h.
Referenced by MountPoint::SetupOwnerMaps().
|
inline |
Definition at line 173 of file catalog_mgr.h.
|
inlineprotectedvirtual |
Reimplemented in catalog::ClientCatalogManager.
Definition at line 220 of file catalog_mgr.h.
|
inlineprotected |
Definition at line 265 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< Catalog >::inode_gauge().
|
inline |
Definition at line 177 of file catalog_mgr.h.
Referenced by MountPoint::CreateCatalogManager(), cvmfs::cvmfs_open(), cvmfs::cvmfs_read(), and LHashMagicXattr::GetValue().
|
inlineprotected |
Definition at line 261 of file catalog_mgr.h.
|
private |
Saves the VOMS requirements when a root catalog is attached
Definition at line 299 of file catalog_mgr.h.
|
private |
Try to keep number of nested catalogs below the given limit. Zero means no limit. Surpassing the watermark on mounting a catalog triggers a DetachSiblings() call.
Definition at line 286 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager().
|
private |
The flat list of all attached catalogs.
Definition at line 277 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< Catalog >::DetachAll(), catalog::AbstractCatalogManager< Catalog >::GetCatalogs(), and catalog::AbstractCatalogManager< Catalog >::GetRootCatalog().
|
private |
Definition at line 310 of file catalog_mgr.h.
|
private |
Saves the result of GetVOMSAuthz when a root catalog is attached
Definition at line 295 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager().
|
private |
Counts how often the inodes have been invalidated.
Definition at line 303 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager().
|
private |
applied to all catalogs
Definition at line 305 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager(), and catalog::AbstractCatalogManager< Catalog >::GetRootInode().
|
private |
highest issued inode
Definition at line 279 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager(), and catalog::AbstractCatalogManager< Catalog >::inode_gauge().
|
private |
0: OK, 1: > 32bit
Definition at line 278 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager().
|
static |
Definition at line 125 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< Catalog >::GetRootInode(), and catalog::AbstractCatalogManager< Catalog >::MangleInode().
|
private |
Definition at line 308 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager().
|
private |
Definition at line 280 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager().
|
private |
Definition at line 306 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager(), catalog::AbstractCatalogManager< Catalog >::ReadLock(), catalog::AbstractCatalogManager< Catalog >::Unlock(), and catalog::AbstractCatalogManager< Catalog >::WriteLock().
|
private |
Definition at line 307 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< Catalog >::statistics().
|
private |
Definition at line 309 of file catalog_mgr.h.
|
private |
Not protected by a read lock because it can only change when the root catalog is exchanged (during big global lock of the file system).
Definition at line 291 of file catalog_mgr.h.
Referenced by catalog::AbstractCatalogManager< CatalogT >::AbstractCatalogManager(), and catalog::AbstractCatalogManager< Catalog >::volatile_flag().