Loading include/client/cache.hpp +8 −0 Changes for include/client/cache.hpp: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -120,6 +120,14 @@ public: std::optional<cache_entry> get(const std::string& parent_dir, const std::string& name); /** * @brief Check if directory entries are cached for a given directory * @param dir_path * @return bool */ bool has_dir(const std::string& dir_path); /** * @brief Clear the cache for a given directory. Called when a directory is * closed Loading include/client/env.hpp +2 −0 Changes for include/client/env.hpp: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -95,6 +95,8 @@ static constexpr auto REPAIR_JOURNAL_PATH = ADD_PREFIX("REPAIR_JOURNAL_PATH"); static constexpr auto PROXY_PID_FILE = ADD_PREFIX("PROXY_PID_FILE"); namespace cache { static constexpr auto DENTRY = ADD_PREFIX("DENTRY_CACHE"); static constexpr auto DENTRY_CLEAR_ON_CLOSE = ADD_PREFIX("DENTRY_CACHE_CLEAR_ON_CLOSE"); static constexpr auto WRITE_SIZE = ADD_PREFIX("WRITE_SIZE_CACHE"); static constexpr auto WRITE_SIZE_THRESHOLD = ADD_PREFIX("WRITE_SIZE_CACHE_THRESHOLD"); Loading include/client/preload_context.hpp +7 −0 Changes for include/client/preload_context.hpp: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ private: std::shared_ptr<FsConfig> fs_conf_; std::shared_ptr<gkfs::cache::dir::DentryCache> dentry_cache_; bool use_dentry_cache_{false}; bool clear_dentry_cache_on_close_{true}; std::shared_ptr<gkfs::cache::file::WriteSizeCache> write_size_cache_; bool use_write_size_cache_{false}; Loading Loading @@ -367,6 +368,12 @@ public: void use_dentry_cache(bool use_dentry_cache); bool clear_dentry_cache_on_close() const; void clear_dentry_cache_on_close(bool clear_dentry_cache_on_close); std::shared_ptr<gkfs::cache::file::WriteSizeCache> write_size_cache() const; Loading src/client/cache.cpp +10 −0 Changes for src/client/cache.cpp: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -102,6 +102,16 @@ DentryCache::get(const std::string& parent_dir, const std::string& name) { return entry_it->second; } bool DentryCache::has_dir(const std::string& dir_path) { std::lock_guard<std::mutex> const lock(mtx_); auto id_it = entry_dir_id_.find(dir_path); if(id_it == entry_dir_id_.end()) { return false; } return entries_.find(id_it->second) != entries_.end(); } void DentryCache::clear_dir(const std::string& dir_path) { std::lock_guard<std::mutex> const lock(mtx_); Loading src/client/gkfs_metadata.cpp +21 −1 Changes for src/client/gkfs_metadata.cpp: 21 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include <config.hpp> #include <algorithm> #include <numeric> #include <filesystem> #include <client/preload.hpp> #include <client/preload_util.hpp> Loading Loading @@ -507,6 +508,10 @@ gkfs_create(const std::string& path, mode_t mode) { errno = 0; } } if(CTX->use_dentry_cache() && CTX->dentry_cache()) { std::filesystem::path p(path); CTX->dentry_cache()->clear_dir(p.parent_path().string()); } return 0; } Loading Loading @@ -564,6 +569,10 @@ gkfs_remove(const std::string& path, bool is_rename_stub) { } } } if(CTX->use_dentry_cache() && CTX->dentry_cache()) { std::filesystem::path p(path); CTX->dentry_cache()->clear_dir(p.parent_path().string()); } return 0; } Loading Loading @@ -704,6 +713,12 @@ gkfs_rename(const string& old_path, const string& new_path) { errno = err; return -1; } if(CTX->use_dentry_cache() && CTX->dentry_cache()) { CTX->dentry_cache()->clear_dir( std::filesystem::path(old_path).parent_path().string()); CTX->dentry_cache()->clear_dir( std::filesystem::path(new_path).parent_path().string()); } return 0; } Loading Loading @@ -1442,6 +1457,11 @@ gkfs_rmdir(const std::string& path) { errno = err; return -1; } if(CTX->use_dentry_cache() && CTX->dentry_cache()) { std::filesystem::path p(path); CTX->dentry_cache()->clear_dir(p.parent_path().string()); CTX->dentry_cache()->clear_dir(path); } return 0; } Loading Loading @@ -1998,7 +2018,7 @@ gkfs_close(unsigned int fd) { } } if(CTX->use_dentry_cache() && gkfs::config::cache::clear_dentry_cache_on_close) { CTX->clear_dentry_cache_on_close()) { // clear cache for directory if(file->type() == gkfs::filemap::FileType::directory) { CTX->dentry_cache()->clear_dir(path); Loading Loading
include/client/cache.hpp +8 −0 Changes for include/client/cache.hpp: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -120,6 +120,14 @@ public: std::optional<cache_entry> get(const std::string& parent_dir, const std::string& name); /** * @brief Check if directory entries are cached for a given directory * @param dir_path * @return bool */ bool has_dir(const std::string& dir_path); /** * @brief Clear the cache for a given directory. Called when a directory is * closed Loading
include/client/env.hpp +2 −0 Changes for include/client/env.hpp: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -95,6 +95,8 @@ static constexpr auto REPAIR_JOURNAL_PATH = ADD_PREFIX("REPAIR_JOURNAL_PATH"); static constexpr auto PROXY_PID_FILE = ADD_PREFIX("PROXY_PID_FILE"); namespace cache { static constexpr auto DENTRY = ADD_PREFIX("DENTRY_CACHE"); static constexpr auto DENTRY_CLEAR_ON_CLOSE = ADD_PREFIX("DENTRY_CACHE_CLEAR_ON_CLOSE"); static constexpr auto WRITE_SIZE = ADD_PREFIX("WRITE_SIZE_CACHE"); static constexpr auto WRITE_SIZE_THRESHOLD = ADD_PREFIX("WRITE_SIZE_CACHE_THRESHOLD"); Loading
include/client/preload_context.hpp +7 −0 Changes for include/client/preload_context.hpp: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ private: std::shared_ptr<FsConfig> fs_conf_; std::shared_ptr<gkfs::cache::dir::DentryCache> dentry_cache_; bool use_dentry_cache_{false}; bool clear_dentry_cache_on_close_{true}; std::shared_ptr<gkfs::cache::file::WriteSizeCache> write_size_cache_; bool use_write_size_cache_{false}; Loading Loading @@ -367,6 +368,12 @@ public: void use_dentry_cache(bool use_dentry_cache); bool clear_dentry_cache_on_close() const; void clear_dentry_cache_on_close(bool clear_dentry_cache_on_close); std::shared_ptr<gkfs::cache::file::WriteSizeCache> write_size_cache() const; Loading
src/client/cache.cpp +10 −0 Changes for src/client/cache.cpp: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -102,6 +102,16 @@ DentryCache::get(const std::string& parent_dir, const std::string& name) { return entry_it->second; } bool DentryCache::has_dir(const std::string& dir_path) { std::lock_guard<std::mutex> const lock(mtx_); auto id_it = entry_dir_id_.find(dir_path); if(id_it == entry_dir_id_.end()) { return false; } return entries_.find(id_it->second) != entries_.end(); } void DentryCache::clear_dir(const std::string& dir_path) { std::lock_guard<std::mutex> const lock(mtx_); Loading
src/client/gkfs_metadata.cpp +21 −1 Changes for src/client/gkfs_metadata.cpp: 21 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include <config.hpp> #include <algorithm> #include <numeric> #include <filesystem> #include <client/preload.hpp> #include <client/preload_util.hpp> Loading Loading @@ -507,6 +508,10 @@ gkfs_create(const std::string& path, mode_t mode) { errno = 0; } } if(CTX->use_dentry_cache() && CTX->dentry_cache()) { std::filesystem::path p(path); CTX->dentry_cache()->clear_dir(p.parent_path().string()); } return 0; } Loading Loading @@ -564,6 +569,10 @@ gkfs_remove(const std::string& path, bool is_rename_stub) { } } } if(CTX->use_dentry_cache() && CTX->dentry_cache()) { std::filesystem::path p(path); CTX->dentry_cache()->clear_dir(p.parent_path().string()); } return 0; } Loading Loading @@ -704,6 +713,12 @@ gkfs_rename(const string& old_path, const string& new_path) { errno = err; return -1; } if(CTX->use_dentry_cache() && CTX->dentry_cache()) { CTX->dentry_cache()->clear_dir( std::filesystem::path(old_path).parent_path().string()); CTX->dentry_cache()->clear_dir( std::filesystem::path(new_path).parent_path().string()); } return 0; } Loading Loading @@ -1442,6 +1457,11 @@ gkfs_rmdir(const std::string& path) { errno = err; return -1; } if(CTX->use_dentry_cache() && CTX->dentry_cache()) { std::filesystem::path p(path); CTX->dentry_cache()->clear_dir(p.parent_path().string()); CTX->dentry_cache()->clear_dir(path); } return 0; } Loading Loading @@ -1998,7 +2018,7 @@ gkfs_close(unsigned int fd) { } } if(CTX->use_dentry_cache() && gkfs::config::cache::clear_dentry_cache_on_close) { CTX->clear_dentry_cache_on_close()) { // clear cache for directory if(file->type() == gkfs::filemap::FileType::directory) { CTX->dentry_cache()->clear_dir(path); Loading