5 #define __STDC_FORMAT_MACROS
41 PathStore::PathStore(
const PathStore &other) { CopyFrom(other); }
49 for (
unsigned i = 0; i < map_.capacity(); ++i) {
50 if (map_.keys()[i] != empty_path) {
51 (map_.values() + i)->name = string_heap_->AddString(
52 map_.values()[i].name.length(), map_.values()[i].name.data());
61 void InodeTracker::InitLock() {
62 lock_ =
reinterpret_cast<pthread_mutex_t *
>(smalloc(
sizeof(pthread_mutex_t)));
63 int retval = pthread_mutex_init(lock_, NULL);
78 InodeTracker::InodeTracker() {
99 InodeTracker::~InodeTracker() {
100 pthread_mutex_destroy(lock_);
107 DentryTracker::DentryTracker() : version_(
kVersion), is_active_(true) {
121 pthread_mutex_destroy(
lock_);
180 struct pollfd watch_term;
182 watch_term.events = POLLIN | POLLPRI;
187 watch_term.revents = 0;
188 int retval = poll(&watch_term, 1, timeout_ms);
190 if (errno == EINTR) {
191 if (timeout_ms >= 0) {
193 timeout_ms = (now > deadline) ? 0 : (deadline - now) * 1000;
208 assert(watch_term.revents != 0);
221 lock_ =
reinterpret_cast<pthread_mutex_t *
>(smalloc(
sizeof(pthread_mutex_t)));
222 int retval = pthread_mutex_init(
lock_, NULL);
244 if (cursor->
head == NULL)
269 pthread_mutex_destroy(
lock_);
304 lock_ =
reinterpret_cast<pthread_mutex_t *
>(smalloc(
sizeof(pthread_mutex_t)));
305 int retval = pthread_mutex_init(
lock_, NULL);
310 uint64_t inode,
const shash::Any &hash,
const struct stat &info) {
311 assert(inode == info.st_ino);
316 return open_directives;
318 if (inode != info.st_ino) {
320 "invalid entry on open: %" PRIu64
" with st_ino=%" PRIu64,
321 " hash=%s size=%" PRIu64, inode, info.st_ino, hash.
ToString().c_str(),
328 bool retval =
map_.Lookup(inode, &entry);
338 map_.Insert(inode, entry);
339 return open_directives;
342 if (entry.
hash == hash) {
344 if (entry.
nopen < 0) {
350 map_.Insert(inode, entry);
351 return open_directives;
355 if (entry.
nopen++ == 0)
357 map_.Insert(inode, entry);
358 return open_directives;
365 if (entry.
nopen != 0) {
369 return open_directives;
382 map_.Insert(inode, entry);
383 return open_directives;
390 return open_directives;
394 return open_directives;
403 bool retval =
map_.Lookup(inode, &entry);
406 "PageCacheTracker::Close Race condition? "
407 "Did not find inode %lu",
410 "PageCacheTracker::Close Race condition? "
411 "Inode %lu has no open entries",
416 const int32_t old_open = entry.
nopen;
417 if (entry.
nopen < 0) {
424 if (entry.
nopen == 0) {
428 "page cache tracker: missing stat entry! Entry info: inode %" PRIu64
429 " - open counter %d - hash %s",
434 retval =
map_.Lookup(inode_update, &entry_update);
437 "invalid inode in page cache tracker: inode %" PRIu64
438 ", replacing %" PRIu64,
439 inode_update, inode);
443 map_.Insert(inode_update, entry_update);
446 map_.Insert(inode, entry);
455 int retval = pthread_mutex_unlock(tracker_->lock_);
460 if (!tracker_->is_active_)
463 bool contained_inode = tracker_->map_.Erase(inode);
465 tracker_->statistics_.n_remove++;
InodeReferences inode_references_
void DoPrune(uint64_t now)
PageCacheTracker & operator=(const PageCacheTracker &other)
std::string ToString(const bool with_suffix=false) const
void CopyFrom(const DentryTracker &other)
perf::Statistics * statistics_
pthread_t thread_cleaner_
assert((mem||(size==0))&&"Out Of Memory")
bool NextEntry(Cursor *cursor, uint64_t *inode_parent, NameString *name)
StringHeap * string_heap_
void MakePipe(int pipe_fd[2])
static uint32_t hasher_inode(const uint64_t &inode)
void EndEnumerate(Cursor *cursor)
void SpawnCleaner(unsigned interval_s)
static bool AssertOrLog(int t, const LogSource, const int, const char *,...)
int32_t Add(const struct stat &info)
static const unsigned kVersion
SmallHashDynamic< shash::Md5, PathInfo > map_
OpenDirectives Open(uint64_t inode, const shash::Any &hash, const struct stat &info)
void Evict(uint64_t inode)
void Close(uint64_t inode)
OpenDirectives OpenDirect()
EvictRaii(PageCacheTracker *t)
PageCacheTracker * tracker_
uint64_t Erase(int32_t index)
DentryTracker & operator=(const DentryTracker &other)
void CopyFrom(const PageCacheTracker &other)
BigQueue< Entry > entries_
static void * MainCleaner(void *data)
static const unsigned kVersion
int cleaning_interval_ms_
void WritePipe(int fd, const void *buf, size_t nbyte)
void ReadPipe(int fd, void *buf, size_t nbyte)
void ClosePipe(int pipe_fd[2])
SmallHashDynamic< uint64_t, Entry > map_
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)