5 #define __STDC_FORMAT_MACROS
7 #include "cvmfs_config.h"
52 for (
unsigned i = 0; i < map_.capacity(); ++i) {
53 if (map_.keys()[i] != empty_path) {
54 (map_.values() + i)->name =
55 string_heap_->AddString(map_.values()[i].name.length(),
56 map_.values()[i].name.data());
65 void InodeTracker::InitLock() {
67 reinterpret_cast<pthread_mutex_t *
>(smalloc(
sizeof(pthread_mutex_t)));
68 int retval = pthread_mutex_init(lock_, NULL);
83 InodeTracker::InodeTracker() {
104 InodeTracker::~InodeTracker() {
105 pthread_mutex_destroy(lock_);
112 DentryTracker::DentryTracker() : version_(
kVersion), is_active_(true) {
126 pthread_mutex_destroy(
lock_);
184 struct pollfd watch_term;
186 watch_term.events = POLLIN | POLLPRI;
190 watch_term.revents = 0;
191 int retval = poll(&watch_term, 1, timeout_ms);
193 if (errno == EINTR) {
194 if (timeout_ms >= 0) {
196 timeout_ms = (now > deadline) ? 0 : (deadline - now) * 1000;
211 assert(watch_term.revents != 0);
225 reinterpret_cast<pthread_mutex_t *
>(smalloc(
sizeof(pthread_mutex_t)));
226 int retval = pthread_mutex_init(
lock_, NULL);
249 if (cursor->
head == NULL)
276 pthread_mutex_destroy(
lock_);
312 reinterpret_cast<pthread_mutex_t *
>(smalloc(
sizeof(pthread_mutex_t)));
313 int retval = pthread_mutex_init(
lock_, NULL);
318 uint64_t inode,
const shash::Any &hash,
const struct stat &info)
320 assert(inode == info.st_ino);
325 return open_directives;
330 bool retval =
map_.Lookup(inode, &entry);
340 map_.Insert(inode, entry);
341 return open_directives;
344 if (entry.
hash == hash) {
346 if (entry.
nopen < 0) {
352 map_.Insert(inode, entry);
353 return open_directives;
357 if (entry.
nopen++ == 0)
359 map_.Insert(inode, entry);
360 return open_directives;
367 if (entry.
nopen != 0) {
371 return open_directives;
384 map_.Insert(inode, entry);
385 return open_directives;
392 return open_directives;
396 return open_directives;
405 bool retval =
map_.Lookup(inode, &entry);
408 "PageCacheTracker::Close Race condition? "
409 "Did not find inode %lu",
412 "PageCacheTracker::Close Race condition? "
413 "Inode %lu has no open entries",
418 if (entry.
nopen < 0) {
425 if (entry.
nopen == 0) {
430 retval =
map_.Lookup(inode_update, &entry_update);
433 map_.Insert(inode_update, entry_update);
436 map_.Insert(inode, entry);
447 int retval = pthread_mutex_unlock(tracker_->lock_);
452 if (!tracker_->is_active_)
455 bool contained_inode = tracker_->map_.Erase(inode);
457 tracker_->statistics_.n_remove++;
#define LogCvmfs(source, mask,...)
InodeReferences inode_references_
void DoPrune(uint64_t now)
PageCacheTracker & operator=(const PageCacheTracker &other)
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_