Loading include/client/open_file_map.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -185,6 +185,8 @@ public: int add(std::shared_ptr<OpenFile>); int add(int fd, std::shared_ptr<OpenFile>); bool remove(int fd); Loading src/client/hooks.cpp +15 −5 Original line number Diff line number Diff line Loading @@ -209,8 +209,16 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { case gkfs::preload::RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: return with_errno(gkfs::syscall::gkfs_open(resolved, mode, flags)); case gkfs::preload::RelativizeStatus::internal: { // pass open to fuse to sync fd in file_map int fd = gsl::narrow_cast<int>(syscall_no_intercept_wrapper( SYS_openat, dirfd, cpath, flags, mode)); LOG(DEBUG, "{}() open passed to fuse fd: {}", __func__, fd); // should be the same fd CTX->file_map()->add(fd, std::make_shared<gkfs::filemap::OpenFile>( resolved, flags)); return with_errno(fd); } default: LOG(ERROR, "{}() rel_fd_path status unknown.", __func__); Loading @@ -235,10 +243,12 @@ hook_close(int fd) { LOG(DEBUG, "{}() called with fd: {}", __func__, fd); auto ret = gkfs::syscall::gkfs_close(fd); //auto ret = gkfs::syscall::gkfs_close(fd); CTX->file_map()->remove(fd); if(ret == 0) return 0; //if(ret < 0) //LOG(DEBUG, "{}() close failed with fd: {}, errno {}", __func__, fd, //errno); return gsl::narrow_cast<int>(syscall_no_intercept_wrapper(SYS_close, fd)); } Loading src/client/open_file_map.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -247,6 +247,15 @@ OpenFileMap::add(std::shared_ptr<OpenFile> open_file) { return fd; } int OpenFileMap::add(int fd, std::shared_ptr<OpenFile> open_file) { auto& shard = get_shard(fd); lock_guard<recursive_mutex> lock(shard.mutex); shard.files[fd] = open_file; total_files_++; return fd; } bool OpenFileMap::remove(const int fd) { if(fd < 0) Loading Loading
include/client/open_file_map.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -185,6 +185,8 @@ public: int add(std::shared_ptr<OpenFile>); int add(int fd, std::shared_ptr<OpenFile>); bool remove(int fd); Loading
src/client/hooks.cpp +15 −5 Original line number Diff line number Diff line Loading @@ -209,8 +209,16 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { case gkfs::preload::RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: return with_errno(gkfs::syscall::gkfs_open(resolved, mode, flags)); case gkfs::preload::RelativizeStatus::internal: { // pass open to fuse to sync fd in file_map int fd = gsl::narrow_cast<int>(syscall_no_intercept_wrapper( SYS_openat, dirfd, cpath, flags, mode)); LOG(DEBUG, "{}() open passed to fuse fd: {}", __func__, fd); // should be the same fd CTX->file_map()->add(fd, std::make_shared<gkfs::filemap::OpenFile>( resolved, flags)); return with_errno(fd); } default: LOG(ERROR, "{}() rel_fd_path status unknown.", __func__); Loading @@ -235,10 +243,12 @@ hook_close(int fd) { LOG(DEBUG, "{}() called with fd: {}", __func__, fd); auto ret = gkfs::syscall::gkfs_close(fd); //auto ret = gkfs::syscall::gkfs_close(fd); CTX->file_map()->remove(fd); if(ret == 0) return 0; //if(ret < 0) //LOG(DEBUG, "{}() close failed with fd: {}, errno {}", __func__, fd, //errno); return gsl::narrow_cast<int>(syscall_no_intercept_wrapper(SYS_close, fd)); } Loading
src/client/open_file_map.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -247,6 +247,15 @@ OpenFileMap::add(std::shared_ptr<OpenFile> open_file) { return fd; } int OpenFileMap::add(int fd, std::shared_ptr<OpenFile> open_file) { auto& shard = get_shard(fd); lock_guard<recursive_mutex> lock(shard.mutex); shard.files[fd] = open_file; total_files_++; return fd; } bool OpenFileMap::remove(const int fd) { if(fd < 0) Loading