47 std::vector<std::string>
list;
48 std::vector<std::string>::iterator
it;
54 , cache_base_defined(false)
55 , cache_dir_defined(false)
59 if (is_alien && quota_limit > 0) {
60 error_reason =
"Alien cache cannot be managed (no quota manager allowed)";
63 if (is_alien && workspace ==
"") {
64 error_reason =
"Workspace option needs to be set for alien cache";
67 if ((is_alien ? 1 : 0) + (cache_base_defined ? 1 : 0)
68 + (cache_dir_defined ? 1 : 0)
70 error_reason =
"CVMFS_CACHE_DIR, CVMFS_CACHE_BASE and CVMFS_CACHE_ALIEN "
71 "are mutually exclusive. Exactly one needs to be defined.";
134 return (uint32_t) * (
reinterpret_cast<const uint32_t *
>(key.
digest) + 1);
179 }
else if (static_cast<int32_t>(
object.refcnt) + change_by < 0) {
183 object.refcnt += change_by;
184 if (
object.refcnt == 0) {
205 info->
size =
object.size;
210 unsigned char *buffer) {
215 if (offset >
object.size) {
219 if (bytes_read < 0) {
222 *size =
static_cast<uint32_t
>(bytes_read);
237 transaction.
hash = *id;
238 transaction.
txn = txn;
262 if ((bytes_written >= 0) && (static_cast<uint32_t>(bytes_written) == size)) {
348 int main(
int argc,
char **argv) {
350 fprintf(stderr,
"Missing argument: path to config file\n");
359 "cannot parse options file %s", argv[1]);
363 "CVMFS_CACHE_PLUGIN_DEBUGLOG");
364 if (debug_log != NULL) {
371 if (locator == NULL) {
373 "CVMFS_CACHE_PLUGIN_LOCATOR missing");
380 options,
"CVMFS_CACHE_PLUGIN_CRASH_DUMP");
382 if (watchdog_crash_dump_path)
387 if (!settings.IsValid()) {
389 "Invalid config in file %s: %s", argv[1],
390 settings.error_reason.c_str());
399 memset(empty_hash.
digest, 0, 20);
411 memset(&callbacks, 0,
sizeof(callbacks));
437 if ((pid = fork()) == 0) {
438 if ((pid = fork()) == 0) {
439 int null_read = open(
"/dev/null", O_RDONLY);
440 int null_write = open(
"/dev/null", O_WRONLY);
441 assert((null_read >= 0) && (null_write >= 0));
442 int retval = dup2(null_read, 0);
444 retval = dup2(null_write, 1);
446 retval = dup2(null_write, 2);
459 waitpid(pid, &statloc, 0);
470 "Running unsupervised. Quit by SIGINT (CTRL+C)");
int posix_breadcrumb_store(const char *fqrn, const cvmcache_breadcrumb *breadcrumb)
struct cvmcache_hash catalog_hash
int(* cvmcache_chrefcnt)(struct cvmcache_hash *id, int32_t change_by)
struct cvmcache_hash Cpphash2Chash(const shash::Any &hash)
virtual int64_t Write(const void *buf, uint64_t size, void *txn)
SmallHashDynamic< uint64_t, Txn > * g_transactions
virtual int Open(const LabeledObject &object)
virtual int CommitTxn(void *txn)
int(* cvmcache_info)(struct cvmcache_info *info)
std::vector< std::string > list
void cvmcache_terminate(struct cvmcache_context *ctx)
static const int kLabelCatalog
uint32_t cvmcache_hash_hasher(const struct cvmcache_hash &key)
int cvmcache_listen(struct cvmcache_context *ctx, char *locator)
Settings GetSettings(cvmcache_option_map *options)
void cvmcache_cleanup_global()
virtual int AbortTxn(void *txn)
struct cvmcache_hash hash
void cvmcache_terminate_watchdog()
int posix_pread(struct cvmcache_hash *id, uint64_t offset, uint32_t *size, unsigned char *buffer)
const SettingsPublisher & settings() const
virtual int64_t GetSize(int fd)
int posix_breadcrumb_load(const char *fqrn, cvmcache_breadcrumb *breadcrumb)
assert((mem||(size==0))&&"Out Of Memory")
virtual void CtrlTxn(const Label &label, const int flags, void *txn)
int cvmcache_is_supervised()
int(* cvmcache_pread)(struct cvmcache_hash *id, uint64_t offset, uint32_t *size, unsigned char *buffer)
int(* cvmcache_breadcrumb_load)(const char *fqrn, cvmcache_breadcrumb *breadcrumb)
int posix_info(struct cvmcache_info *info)
#define SetLogDebugFile(filename)
unsigned char digest[digest_size_]
virtual int OpenFromTxn(void *txn)
void cvmcache_wait_for(struct cvmcache_context *ctx)
int64_t String2Int64(const string &value)
int posix_abort_txn(uint64_t txn_id)
static PosixCacheManager * Create(const std::string &cache_path, const bool alien_cache, const RenameWorkarounds rename_workaround=kRenameNormal, const bool do_refcount=true)
int(* cvmcache_write_txn)(uint64_t txn_id, unsigned char *buffer, uint32_t size)
virtual int StartTxn(const shash::Any &id, uint64_t size, void *txn)
virtual manifest::Breadcrumb LoadBreadcrumb(const std::string &fqrn)
SmallHashDynamic< struct cvmcache_hash, CacheObject > * g_opened_objects
cvmcache_object_type type
PosixCacheManager * g_cache_mgr
SmallHashDynamic< uint64_t, Listing > * g_listings
bool operator!=(const cvmcache_hash &a, const cvmcache_hash &b)
int posix_commit_txn(uint64_t txn_id)
uint32_t uint64_hasher(const uint64_t &key)
void cvmcache_options_free(char *value)
atomic_int32 g_terminated
void cvmcache_spawn_watchdog(const char *crash_dump_file)
void cvmcache_options_fini(cvmcache_option_map *opts)
void handle_sigint(int sig)
int posix_start_txn(struct cvmcache_hash *id, uint64_t txn_id, struct cvmcache_object_info *info)
enum cvmcache_object_type type
struct cvmcache_context * cvmcache_init(struct cvmcache_callbacks *callbacks)
void cvmcache_init_global()
static const int kLabelVolatile
int cvmcache_options_parse(cvmcache_option_map *opts, const char *path)
#define CVMCACHE_SIZE_UNKNOWN
bool operator==(const cvmcache_hash &a, const cvmcache_hash &b)
void cvmcache_process_requests(struct cvmcache_context *ctx, unsigned nworkers)
int(* cvmcache_breadcrumb_store)(const char *fqrn, const cvmcache_breadcrumb *breadcrumb)
int posix_write_txn(uint64_t txn_id, unsigned char *buffer, uint32_t size)
char * cvmcache_options_get(cvmcache_option_map *opts, const char *key)
int(* cvmcache_commit_txn)(uint64_t txn_id)
int(* cvmcache_start_txn)(struct cvmcache_hash *id, uint64_t txn_id, struct cvmcache_object_info *info)
int(* cvmcache_abort_txn)(uint64_t txn_id)
int posix_chrefcnt(struct cvmcache_hash *id, int32_t change_by)
std::string MakeCanonicalPath(const std::string &path)
int posix_obj_info(struct cvmcache_hash *id, struct cvmcache_object_info *info)
virtual bool StoreBreadcrumb(const manifest::Manifest &manifest)
int(* cvmcache_obj_info)(struct cvmcache_hash *id, struct cvmcache_object_info *info)
shash::Any Chash2Cpphash(const struct cvmcache_hash *h)
std::vector< std::string >::iterator it
virtual int Close(int fd)
virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)
cvmcache_object_type type
virtual uint32_t SizeOfTxn()
cvmcache_option_map * cvmcache_options_init()
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)