Loading CMakeLists.txt +6 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,12 @@ if (SYMLINK_SUPPORT) endif () message(STATUS "[gekkofs] Symlink support: ${SYMLINK_SUPPORT}") option(RENAME_SUPPORT "Compile with support for rename ops" ON) if (RENAME_SUPPORT) add_definitions(-DHAS_RENAME) endif () message(STATUS "[gekkofs] Rename support: ${RENAME_SUPPORT}") set(MAX_INTERNAL_FDS 256 CACHE STRING "Number of file descriptors reserved for internal use") add_definitions(-DMAX_INTERNAL_FDS=${MAX_INTERNAL_FDS}) message(STATUS "[gekkofs] File descriptors reserved for internal use: ${MAX_INTERNAL_FDS}") Loading include/client/gkfs_functions.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -149,11 +149,11 @@ gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp, int gkfs_rmdir(const std::string& path); #ifdef HAS_RENAME int gkfs_rename(const std::string& old_path_resolved, const std::string& new_path_resolved); #endif } // namespace gkfs::syscall // gkfs_getsingleserverdir is using extern "C" to demangle it for C usage Loading include/client/rpc/forward_metadata.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -55,9 +55,11 @@ forward_create(const std::string& path, mode_t mode); int forward_stat(const std::string& path, std::string& attr); #ifdef HAS_RENAME int forward_rename(const std::string& path, const std::string& path2, const gkfs::metadata::Metadata& md); #endif int forward_remove(const std::string& path); Loading include/config.hpp +5 −0 Original line number Diff line number Diff line Loading @@ -62,11 +62,16 @@ namespace metadata { constexpr auto dir = "metadata"; // which metadata should be considered apart from size and mode // Blocks are used to store the rename status (-1 is a renamed file) constexpr auto use_atime = false; constexpr auto use_ctime = false; constexpr auto use_mtime = false; constexpr auto use_link_cnt = false; #ifdef HAS_RENAME constexpr auto use_blocks = true; #else constexpr auto use_blocks = false; #endif /* * If true, all chunks on the same host are removed during a metadata remove * rpc. This is a technical optimization that reduces the number of RPCs for Loading src/client/gkfs_functions.cpp +28 −16 Original line number Diff line number Diff line Loading @@ -172,12 +172,13 @@ gkfs_open(const std::string& path, mode_t mode, int flags, bool rename) { return -1; } md = *md_; #ifdef HAS_RENAME if(rename == false && md.blocks() == -1) { LOG(ERROR, "File is renamed '{}': '{}' - rename: {}", path, LOG(DEBUG, "File is renamed '{}': '{}' - rename: {}", path, rename); return -1; } #endif } else { LOG(ERROR, "Error creating file: '{}'", strerror(errno)); return -1; Loading Loading @@ -208,25 +209,23 @@ gkfs_open(const std::string& path, mode_t mode, int flags, bool rename) { } return gkfs_open(md.target_path(), mode, flags); } #endif #ifdef HAS_RENAME /// The file is a renamed file, so we need to get the metadata of the /// original file. /// This does not work as we will check that this is a -1. if(!md.target_path().empty()) { LOG(ERROR, "File '{}' is renamed, reentering with '{}'", path, LOG(DEBUG, "File '{}' is renamed, reentering with '{}'", path, md.target_path()); return gkfs_open(md.target_path(), mode, flags, true); } #endif if(rename == false && md.blocks() == -1) { LOG(ERROR, "File '{}' is renamed __", path); LOG(DEBUG, "File '{}' is renamed __", path); errno = ENOENT; return -1; } #endif if(S_ISDIR(md.mode())) { return gkfs_opendir(path); } Loading Loading @@ -332,6 +331,7 @@ gkfs_access(const std::string& path, const int mask, bool follow_links) { return 0; } #ifdef HAS_RENAME /** * gkfs wrapper for rename() system calls * errno may be set Loading @@ -358,6 +358,7 @@ gkfs_rename(const string& old_path, const string& new_path) { return 0; } #endif /** * gkfs wrapper for stat() system calls Loading @@ -370,9 +371,15 @@ gkfs_rename(const string& old_path, const string& new_path) { int gkfs_stat(const string& path, struct stat* buf, bool follow_links) { auto md = gkfs::utils::get_metadata(path, follow_links); if(!md or md.value().blocks() == -1) { if(!md) { return -1; } #ifdef HAS_RENAME if (md.value().blocks() == -1) { errno = ENOENT; return -1; } #endif gkfs::utils::metadata_to_stat(path, *md, *buf); return 0; } Loading @@ -395,10 +402,15 @@ gkfs_statx(int dirfs, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links) { auto md = gkfs::utils::get_metadata(path, follow_links); if(!md or md.value().blocks() == -1) { if(!md) { return -1; } #ifdef HAS_RENAME if (md.value().blocks() == -1) { errno = ENOENT; return -1; } #endif struct stat tmp {}; gkfs::utils::metadata_to_stat(path, *md, tmp); Loading Loading
CMakeLists.txt +6 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,12 @@ if (SYMLINK_SUPPORT) endif () message(STATUS "[gekkofs] Symlink support: ${SYMLINK_SUPPORT}") option(RENAME_SUPPORT "Compile with support for rename ops" ON) if (RENAME_SUPPORT) add_definitions(-DHAS_RENAME) endif () message(STATUS "[gekkofs] Rename support: ${RENAME_SUPPORT}") set(MAX_INTERNAL_FDS 256 CACHE STRING "Number of file descriptors reserved for internal use") add_definitions(-DMAX_INTERNAL_FDS=${MAX_INTERNAL_FDS}) message(STATUS "[gekkofs] File descriptors reserved for internal use: ${MAX_INTERNAL_FDS}") Loading
include/client/gkfs_functions.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -149,11 +149,11 @@ gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp, int gkfs_rmdir(const std::string& path); #ifdef HAS_RENAME int gkfs_rename(const std::string& old_path_resolved, const std::string& new_path_resolved); #endif } // namespace gkfs::syscall // gkfs_getsingleserverdir is using extern "C" to demangle it for C usage Loading
include/client/rpc/forward_metadata.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -55,9 +55,11 @@ forward_create(const std::string& path, mode_t mode); int forward_stat(const std::string& path, std::string& attr); #ifdef HAS_RENAME int forward_rename(const std::string& path, const std::string& path2, const gkfs::metadata::Metadata& md); #endif int forward_remove(const std::string& path); Loading
include/config.hpp +5 −0 Original line number Diff line number Diff line Loading @@ -62,11 +62,16 @@ namespace metadata { constexpr auto dir = "metadata"; // which metadata should be considered apart from size and mode // Blocks are used to store the rename status (-1 is a renamed file) constexpr auto use_atime = false; constexpr auto use_ctime = false; constexpr auto use_mtime = false; constexpr auto use_link_cnt = false; #ifdef HAS_RENAME constexpr auto use_blocks = true; #else constexpr auto use_blocks = false; #endif /* * If true, all chunks on the same host are removed during a metadata remove * rpc. This is a technical optimization that reduces the number of RPCs for Loading
src/client/gkfs_functions.cpp +28 −16 Original line number Diff line number Diff line Loading @@ -172,12 +172,13 @@ gkfs_open(const std::string& path, mode_t mode, int flags, bool rename) { return -1; } md = *md_; #ifdef HAS_RENAME if(rename == false && md.blocks() == -1) { LOG(ERROR, "File is renamed '{}': '{}' - rename: {}", path, LOG(DEBUG, "File is renamed '{}': '{}' - rename: {}", path, rename); return -1; } #endif } else { LOG(ERROR, "Error creating file: '{}'", strerror(errno)); return -1; Loading Loading @@ -208,25 +209,23 @@ gkfs_open(const std::string& path, mode_t mode, int flags, bool rename) { } return gkfs_open(md.target_path(), mode, flags); } #endif #ifdef HAS_RENAME /// The file is a renamed file, so we need to get the metadata of the /// original file. /// This does not work as we will check that this is a -1. if(!md.target_path().empty()) { LOG(ERROR, "File '{}' is renamed, reentering with '{}'", path, LOG(DEBUG, "File '{}' is renamed, reentering with '{}'", path, md.target_path()); return gkfs_open(md.target_path(), mode, flags, true); } #endif if(rename == false && md.blocks() == -1) { LOG(ERROR, "File '{}' is renamed __", path); LOG(DEBUG, "File '{}' is renamed __", path); errno = ENOENT; return -1; } #endif if(S_ISDIR(md.mode())) { return gkfs_opendir(path); } Loading Loading @@ -332,6 +331,7 @@ gkfs_access(const std::string& path, const int mask, bool follow_links) { return 0; } #ifdef HAS_RENAME /** * gkfs wrapper for rename() system calls * errno may be set Loading @@ -358,6 +358,7 @@ gkfs_rename(const string& old_path, const string& new_path) { return 0; } #endif /** * gkfs wrapper for stat() system calls Loading @@ -370,9 +371,15 @@ gkfs_rename(const string& old_path, const string& new_path) { int gkfs_stat(const string& path, struct stat* buf, bool follow_links) { auto md = gkfs::utils::get_metadata(path, follow_links); if(!md or md.value().blocks() == -1) { if(!md) { return -1; } #ifdef HAS_RENAME if (md.value().blocks() == -1) { errno = ENOENT; return -1; } #endif gkfs::utils::metadata_to_stat(path, *md, *buf); return 0; } Loading @@ -395,10 +402,15 @@ gkfs_statx(int dirfs, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links) { auto md = gkfs::utils::get_metadata(path, follow_links); if(!md or md.value().blocks() == -1) { if(!md) { return -1; } #ifdef HAS_RENAME if (md.value().blocks() == -1) { errno = ENOENT; return -1; } #endif struct stat tmp {}; gkfs::utils::metadata_to_stat(path, *md, tmp); Loading