Loading include/client/gkfs_functions.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,8 @@ gkfs_readlink(const std::string& path, char* buf, int bufsize); ssize_t gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, size_t count, off64_t offset); int gkfs_close(unsigned int fd); ssize_t gkfs_pwrite_ws(int fd, const void* buf, size_t count, off64_t offset); Loading src/client/gkfs_functions.cpp +47 −12 Original line number Diff line number Diff line Loading @@ -231,9 +231,9 @@ gkfs_create(const std::string& path, mode_t mode) { return -1; } if(check_parent_dir(path)) { return -1; } // if (check_parent_dir(path)) { // return -1; //} auto err = gkfs::rpc::forward_create(path, mode); if(err) { errno = err; Loading Loading @@ -577,6 +577,9 @@ gkfs_dup2(const int oldfd, const int newfd) { return CTX->file_map()->dup2(oldfd, newfd); } // static unsigned long long shared_file_size; static std::atomic_uint_fast64_t shared_file_size; static std::mutex close_lock; /** * Wrapper function for all gkfs write operations * errno may be set Loading @@ -598,6 +601,21 @@ gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, auto path = make_shared<string>(file->path()); auto append_flag = file->get_flag(gkfs::filemap::OpenFile_flags::append); // auto ret_update_size = gkfs::rpc::forward_update_metadentry_size(*path, // count, offset, append_flag); auto err = ret_update_size.first; if (err) { // LOG(ERROR, "update_metadentry_size() failed with err '{}'", err); // errno = err; // return -1; //} // auto updated_size = ret_update_size.second; unsigned long long updated_size; if((*path)[1] != 'm') /*/mdtest-... */ { shared_file_size = max((unsigned long long) shared_file_size, (unsigned long long) count + (unsigned long long) offset); updated_size = shared_file_size; } else { auto ret_update_size = gkfs::rpc::forward_update_metadentry_size( *path, count, offset, append_flag); auto err = ret_update_size.first; Loading @@ -606,11 +624,12 @@ gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, errno = err; return -1; } auto updated_size = ret_update_size.second; updated_size = ret_update_size.second; } auto ret_write = gkfs::rpc::forward_write(*path, buf, append_flag, offset, count, updated_size); err = ret_write.first; auto err = ret_write.first; if(err) { LOG(WARNING, "gkfs::rpc::forward_write() failed with err '{}'", err); errno = err; Loading @@ -619,6 +638,22 @@ gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, return ret_write.second; // return written size } int gkfs_close(unsigned int fd) { auto file = CTX->file_map()->get(fd); auto pathx = make_unique<string>(file->path()); if((*pathx)[1] != 'm') { close_lock.lock(); if(shared_file_size > 0) { gkfs::rpc::forward_update_metadentry_size(*pathx, shared_file_size, 0, false); shared_file_size = 0; } close_lock.unlock(); } return 0; } /** * gkfs wrapper for pwrite() system calls * errno may be set Loading src/client/hooks.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ hook_close(int fd) { LOG(DEBUG, "{}() called with fd: {}", __func__, fd); if(CTX->file_map()->exist(fd)) { gkfs::syscall::gkfs_close(fd); // No call to the daemon is required CTX->file_map()->remove(fd); return 0; Loading Loading
include/client/gkfs_functions.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,8 @@ gkfs_readlink(const std::string& path, char* buf, int bufsize); ssize_t gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, size_t count, off64_t offset); int gkfs_close(unsigned int fd); ssize_t gkfs_pwrite_ws(int fd, const void* buf, size_t count, off64_t offset); Loading
src/client/gkfs_functions.cpp +47 −12 Original line number Diff line number Diff line Loading @@ -231,9 +231,9 @@ gkfs_create(const std::string& path, mode_t mode) { return -1; } if(check_parent_dir(path)) { return -1; } // if (check_parent_dir(path)) { // return -1; //} auto err = gkfs::rpc::forward_create(path, mode); if(err) { errno = err; Loading Loading @@ -577,6 +577,9 @@ gkfs_dup2(const int oldfd, const int newfd) { return CTX->file_map()->dup2(oldfd, newfd); } // static unsigned long long shared_file_size; static std::atomic_uint_fast64_t shared_file_size; static std::mutex close_lock; /** * Wrapper function for all gkfs write operations * errno may be set Loading @@ -598,6 +601,21 @@ gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, auto path = make_shared<string>(file->path()); auto append_flag = file->get_flag(gkfs::filemap::OpenFile_flags::append); // auto ret_update_size = gkfs::rpc::forward_update_metadentry_size(*path, // count, offset, append_flag); auto err = ret_update_size.first; if (err) { // LOG(ERROR, "update_metadentry_size() failed with err '{}'", err); // errno = err; // return -1; //} // auto updated_size = ret_update_size.second; unsigned long long updated_size; if((*path)[1] != 'm') /*/mdtest-... */ { shared_file_size = max((unsigned long long) shared_file_size, (unsigned long long) count + (unsigned long long) offset); updated_size = shared_file_size; } else { auto ret_update_size = gkfs::rpc::forward_update_metadentry_size( *path, count, offset, append_flag); auto err = ret_update_size.first; Loading @@ -606,11 +624,12 @@ gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, errno = err; return -1; } auto updated_size = ret_update_size.second; updated_size = ret_update_size.second; } auto ret_write = gkfs::rpc::forward_write(*path, buf, append_flag, offset, count, updated_size); err = ret_write.first; auto err = ret_write.first; if(err) { LOG(WARNING, "gkfs::rpc::forward_write() failed with err '{}'", err); errno = err; Loading @@ -619,6 +638,22 @@ gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, return ret_write.second; // return written size } int gkfs_close(unsigned int fd) { auto file = CTX->file_map()->get(fd); auto pathx = make_unique<string>(file->path()); if((*pathx)[1] != 'm') { close_lock.lock(); if(shared_file_size > 0) { gkfs::rpc::forward_update_metadentry_size(*pathx, shared_file_size, 0, false); shared_file_size = 0; } close_lock.unlock(); } return 0; } /** * gkfs wrapper for pwrite() system calls * errno may be set Loading
src/client/hooks.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ hook_close(int fd) { LOG(DEBUG, "{}() called with fd: {}", __func__, fd); if(CTX->file_map()->exist(fd)) { gkfs::syscall::gkfs_close(fd); // No call to the daemon is required CTX->file_map()->remove(fd); return 0; Loading