From d441ffa26603bb56c3a1bc095c2aca7aef913226 Mon Sep 17 00:00:00 2001 From: Julius Athenstaedt Date: Mon, 16 Oct 2023 14:03:27 +0200 Subject: [PATCH 1/5] GKFS_ Prefix for MAX_INTERNAL_FDS --- .gitignore | 3 +++ CMake/gkfs-options.cmake | 2 +- CMakeLists.txt | 4 ++-- CMakePresets.json | 2 +- include/client/preload_context.hpp | 4 ++-- src/client/preload_context.cpp | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6fb38b1ce..569490bc8 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,9 @@ *.idea/ .run/ +# clangd +.clangd + # OS generated files .DS_Store .DS_Store? diff --git a/CMake/gkfs-options.cmake b/CMake/gkfs-options.cmake index 598de903c..2339377ac 100644 --- a/CMake/gkfs-options.cmake +++ b/CMake/gkfs-options.cmake @@ -267,7 +267,7 @@ gkfs_define_option( ## Maximum number of internal file descriptors reserved for GekkoFS # FIXME: should be prefixed with GKFS_ -gkfs_define_variable(MAX_INTERNAL_FDS 256 +gkfs_define_variable(GKFS_MAX_INTERNAL_FDS 256 STRING "Number of file descriptors reserved for internal use" ADVANCED ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71e7c842f..6c47cecd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,8 +266,8 @@ if (GKFS_RENAME_SUPPORT) add_definitions(-DHAS_RENAME) endif () -if(MAX_INTERNAL_FDS) - add_definitions(-DMAX_INTERNAL_FDS=${MAX_INTERNAL_FDS}) +if(GKFS_MAX_INTERNAL_FDS) + add_definitions(-DGKFS_MAX_INTERNAL_FDS=${GKFS_MAX_INTERNAL_FDS}) endif() if(MAX_OPEN_FDS) diff --git a/CMakePresets.json b/CMakePresets.json index 88fc9ce80..fd1a314c1 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -86,7 +86,7 @@ "GKFS_ENABLE_PROMETHEUS": true, "GKFS_RENAME_SUPPORT": true, "MAX_OPEN_FDS": "10000", - "MAX_INTERNAL_FDS": "1024" + "GKFS_MAX_INTERNAL_FDS": "1024" } }, { diff --git a/include/client/preload_context.hpp b/include/client/preload_context.hpp index 26875435b..35dccd915 100644 --- a/include/client/preload_context.hpp +++ b/include/client/preload_context.hpp @@ -77,7 +77,7 @@ enum class RelativizeStatus { internal, external, fd_unknown, fd_not_a_dir }; */ class PreloadContext { - static auto constexpr MIN_INTERNAL_FD = MAX_OPEN_FDS - MAX_INTERNAL_FDS; + static auto constexpr MIN_INTERNAL_FD = MAX_OPEN_FDS - GKFS_MAX_INTERNAL_FDS; static auto constexpr MAX_USER_FDS = MIN_INTERNAL_FD; private: @@ -99,7 +99,7 @@ private: bool interception_enabled_; - std::bitset internal_fds_; + std::bitset internal_fds_; mutable std::mutex internal_fds_mutex_; bool internal_fds_must_relocate_; std::bitset protected_fds_; diff --git a/src/client/preload_context.cpp b/src/client/preload_context.cpp index 236d2583f..f8ac782fe 100644 --- a/src/client/preload_context.cpp +++ b/src/client/preload_context.cpp @@ -316,7 +316,7 @@ PreloadContext::register_internal_fd(int fd) { if(static_cast(pos) == internal_fds_.size()) { throw std::runtime_error( - "Internal GekkoFS file descriptors exhausted, increase MAX_INTERNAL_FDS in " + "Internal GekkoFS file descriptors exhausted, increase GKFS_MAX_INTERNAL_FDS in " "CMake, rebuild GekkoFS and try again."); } internal_fds_.reset(pos); -- GitLab From a4b09aba05b8f3404744a711eadf6fad29781fdb Mon Sep 17 00:00:00 2001 From: Julius Athenstaedt Date: Mon, 16 Oct 2023 14:44:02 +0200 Subject: [PATCH 2/5] GKFS_ Prefix for MAX_OPEN_FDS --- CMake/gkfs-options.cmake | 2 +- CMakeLists.txt | 6 +++--- CMakePresets.json | 2 +- include/client/preload_context.hpp | 2 +- src/client/preload.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMake/gkfs-options.cmake b/CMake/gkfs-options.cmake index 2339377ac..b7b5cd85b 100644 --- a/CMake/gkfs-options.cmake +++ b/CMake/gkfs-options.cmake @@ -282,7 +282,7 @@ if (NOT _GETCONF_MAX_FDS) endif () gkfs_define_variable( - MAX_OPEN_FDS + GKFS_MAX_OPEN_FDS ${_GETCONF_MAX_FDS} STRING "Maximum number of open file descriptors supported" diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c47cecd6..646279f2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,7 @@ include(gkfs-utils) ################################################################################ include(gkfs-options) -set(CMAKE_EXPORT_COMPILE_COMMANDS 0) +set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # ############################################################################## @@ -270,8 +270,8 @@ if(GKFS_MAX_INTERNAL_FDS) add_definitions(-DGKFS_MAX_INTERNAL_FDS=${GKFS_MAX_INTERNAL_FDS}) endif() -if(MAX_OPEN_FDS) - add_definitions(-DMAX_OPEN_FDS=${MAX_OPEN_FDS}) +if(GKFS_MAX_OPEN_FDS) + add_definitions(-DGKFS_MAX_OPEN_FDS=${GKFS_MAX_OPEN_FDS}) endif() if(ENABLE_CLIENT_LOG) diff --git a/CMakePresets.json b/CMakePresets.json index fd1a314c1..6564634c8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -85,7 +85,7 @@ "GKFS_CHUNK_STATS": true, "GKFS_ENABLE_PROMETHEUS": true, "GKFS_RENAME_SUPPORT": true, - "MAX_OPEN_FDS": "10000", + "GKFS_MAX_OPEN_FDS": "10000", "GKFS_MAX_INTERNAL_FDS": "1024" } }, diff --git a/include/client/preload_context.hpp b/include/client/preload_context.hpp index 35dccd915..ed6bde47d 100644 --- a/include/client/preload_context.hpp +++ b/include/client/preload_context.hpp @@ -77,7 +77,7 @@ enum class RelativizeStatus { internal, external, fd_unknown, fd_not_a_dir }; */ class PreloadContext { - static auto constexpr MIN_INTERNAL_FD = MAX_OPEN_FDS - GKFS_MAX_INTERNAL_FDS; + static auto constexpr MIN_INTERNAL_FD = GKFS_MAX_OPEN_FDS - GKFS_MAX_INTERNAL_FDS; static auto constexpr MAX_USER_FDS = MIN_INTERNAL_FD; private: diff --git a/src/client/preload.cpp b/src/client/preload.cpp index 7b05ca9a3..1d082907a 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -266,7 +266,7 @@ init_preload() { // happens during our internal initialization, there's no way for us to // control this creation and the fd will be created in the // [0, MAX_USER_FDS) range rather than in our private - // [MAX_USER_FDS, MAX_OPEN_FDS) range. To prevent this for our internal + // [MAX_USER_FDS, GKFS_MAX_OPEN_FDS) range. To prevent this for our internal // initialization code, we forcefully occupy the user fd range to force // such modules to create fds in our private range. CTX->protect_user_fds(); -- GitLab From 9efd7f449a06e2a1d5a7acd6fe648ad43ebca8ae Mon Sep 17 00:00:00 2001 From: Julius Athenstaedt Date: Mon, 16 Oct 2023 15:14:32 +0200 Subject: [PATCH 3/5] GKFS_ prefix for ENABLE_CLIENT_LOG --- CMake/gkfs-options.cmake | 2 +- CMakeLists.txt | 4 ++-- CMakePresets.json | 2 +- docs/sphinx/devs/coverage.md | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMake/gkfs-options.cmake b/CMake/gkfs-options.cmake index b7b5cd85b..7d675315a 100644 --- a/CMake/gkfs-options.cmake +++ b/CMake/gkfs-options.cmake @@ -328,7 +328,7 @@ gkfs_define_option( ## Client logging support # FIXME: should be prefixed with GKFS_ gkfs_define_option( - ENABLE_CLIENT_LOG HELP_TEXT "Enable logging messages in clients" + GKFS_ENABLE_CLIENT_LOG HELP_TEXT "Enable logging messages in clients" DEFAULT_VALUE ON ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 646279f2c..5ddf2b64f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,7 +274,7 @@ if(GKFS_MAX_OPEN_FDS) add_definitions(-DGKFS_MAX_OPEN_FDS=${GKFS_MAX_OPEN_FDS}) endif() -if(ENABLE_CLIENT_LOG) +if(GKFS_ENABLE_CLIENT_LOG) add_definitions(-DGKFS_ENABLE_LOGGING) add_definitions(-DLIBGKFS_LOG_MESSAGE_SIZE=${CLIENT_LOG_MESSAGE_SIZE}) endif () @@ -289,7 +289,7 @@ endif () configure_file(include/common/cmake_configure.hpp.in include/common/cmake_configure.hpp) -if(ENABLE_CLIENT_LOG) +if(GKFS_ENABLE_CLIENT_LOG) option(HERMES_LOGGING "" ON) option(HERMES_LOGGING_FMT_USE_BUNDLED "" OFF) option(HERMES_LOGGING_FMT_HEADER_ONLY "" OFF) diff --git a/CMakePresets.json b/CMakePresets.json index 6564634c8..a2eb90a75 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -18,7 +18,7 @@ "GKFS_ENABLE_PARALLAX": false, "GKFS_BUILD_TESTS": false, "GKFS_INSTALL_TESTS": false, - "ENABLE_CLIENT_LOG": true, + "GKFS_ENABLE_CLIENT_LOG": true, "CLIENT_LOG_MESSAGE_SIZE": "1024", "GKFS_SYMLINK_SUPPORT": false }, diff --git a/docs/sphinx/devs/coverage.md b/docs/sphinx/devs/coverage.md index 7bd9932a7..6499b81e0 100644 --- a/docs/sphinx/devs/coverage.md +++ b/docs/sphinx/devs/coverage.md @@ -59,7 +59,7 @@ Preset CMake variables: CMAKE_EXE_LINKER_FLAGS_COVERAGE="--coverage" CMAKE_MAP_IMPORTED_CONFIG_COVERAGE="Coverage;RelWithDebInfo;Release;Debug;" CMAKE_SHARED_LINKER_FLAGS_COVERAGE="--coverage" - ENABLE_CLIENT_LOG:BOOL="TRUE" + GKFS_ENABLE_CLIENT_LOG:BOOL="TRUE" GKFS_BUILD_DOCUMENTATION:BOOL="TRUE" GKFS_BUILD_TESTS:BOOL="TRUE" GKFS_CHUNK_STATS:BOOL="TRUE" -- GitLab From 39840ca1af5f9bcb2ece5638e2a066e6a62d365b Mon Sep 17 00:00:00 2001 From: Julius Athenstaedt Date: Mon, 16 Oct 2023 15:38:55 +0200 Subject: [PATCH 4/5] GKFS_ prefix for CREATE_CHECK_PARENTS --- CHANGELOG.md | 2 +- CMake/gkfs-options.cmake | 4 +--- include/common/cmake_configure.hpp.in | 2 +- src/client/gkfs_functions.cpp | 6 +++--- src/daemon/daemon.cpp | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f360b69b9..2e945f6bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -302,7 +302,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Paths inside kernel pseudo filesystems (`/sys`, `/proc`) are forwarded directly to the kernel and internal path resolution will be skipped. Be aware that also paths like `/sys/../tmp/gkfs_mountpoint/asd` will be forwarded to the kernel -- Added new Cmake flag `CREATE_CHECK_PARENTS` to controls if the existance of the parent node needs to be checked during +- Added new Cmake flag `GKFS_CREATE_CHECK_PARENTS` to controls if the existance of the parent node needs to be checked during the creation of a child node. ### Changed diff --git a/CMake/gkfs-options.cmake b/CMake/gkfs-options.cmake index 7d675315a..533e7f077 100644 --- a/CMake/gkfs-options.cmake +++ b/CMake/gkfs-options.cmake @@ -235,16 +235,14 @@ cmake_dependent_option(GKFS_INSTALL_TESTS "Install GekkoFS self tests" OFF "GKFS ################################################################################ ## check before create -# FIXME: should be prefixed with GKFS_ gkfs_define_option( - CREATE_CHECK_PARENTS + GKFS_CREATE_CHECK_PARENTS HELP_TEXT "Enable checking parent directory for existence before creating children" DEFAULT_VALUE ON DESCRIPTION "Verify that a parent directory exists before creating new files or directories" ) ## symbolic link support -# FIXME: should be prefixed with GKFS_ gkfs_define_option( GKFS_SYMLINK_SUPPORT HELP_TEXT "Enable support for symlinks" diff --git a/include/common/cmake_configure.hpp.in b/include/common/cmake_configure.hpp.in index 8b3ee852b..8d2405805 100644 --- a/include/common/cmake_configure.hpp.in +++ b/include/common/cmake_configure.hpp.in @@ -14,7 +14,7 @@ #ifndef GKFS_CMAKE_CONFIGURE_HPP #define GKFS_CMAKE_CONFIGURE_HPP -#cmakedefine01 CREATE_CHECK_PARENTS +#cmakedefine01 GKFS_CREATE_CHECK_PARENTS #cmakedefine01 LOG_SYSCALLS #cmakedefine GKFS_USE_GUIDED_DISTRIBUTION #define GKFS_USE_GUIDED_DISTRIBUTION_PATH "@GKFS_USE_GUIDED_DISTRIBUTION_PATH@" diff --git a/src/client/gkfs_functions.cpp b/src/client/gkfs_functions.cpp index 282a3eae9..a19373d88 100644 --- a/src/client/gkfs_functions.cpp +++ b/src/client/gkfs_functions.cpp @@ -91,13 +91,13 @@ namespace { /** * Checks if metadata for parent directory exists (can be disabled with - * CREATE_CHECK_PARENTS). errno may be set + * GKFS_CREATE_CHECK_PARENTS). errno may be set * @param path * @return 0 on success, -1 on failure */ int check_parent_dir(const std::string& path) { -#if CREATE_CHECK_PARENTS +#if GKFS_CREATE_CHECK_PARENTS auto p_comp = gkfs::path::dirname(path); auto md = gkfs::utils::get_metadata(p_comp); if(!md) { @@ -114,7 +114,7 @@ check_parent_dir(const std::string& path) { errno = ENOTDIR; return -1; } -#endif // CREATE_CHECK_PARENTS +#endif // GKFS_CREATE_CHECK_PARENTS return 0; } } // namespace diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 0cff0fc6e..cae92f201 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -813,7 +813,7 @@ main(int argc, const char* argv[]) { #else cout << "Debug: OFF" << endl; #endif -#if CREATE_CHECK_PARENTS +#if GKFS_CREATE_CHECK_PARENTS cout << "Create check parents: ON" << endl; #else cout << "Create check parents: OFF" << endl; -- GitLab From e9a691e3e61dfcac9efe58c2f144b26398c6947a Mon Sep 17 00:00:00 2001 From: Julius Athenstaedt Date: Mon, 16 Oct 2023 16:07:31 +0200 Subject: [PATCH 5/5] GKFS_ prefix for CLIENT_LOG_MESSAGE_SIZE --- .gitignore | 1 + CMake/gkfs-options.cmake | 6 +----- CMakeLists.txt | 4 ++-- CMakePresets.json | 2 +- docs/sphinx/devs/coverage.md | 2 +- include/client/preload_context.hpp | 3 ++- src/client/preload.cpp | 4 +++- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 569490bc8..a846ad148 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,7 @@ # clangd .clangd +.cache # OS generated files .DS_Store diff --git a/CMake/gkfs-options.cmake b/CMake/gkfs-options.cmake index 533e7f077..335537519 100644 --- a/CMake/gkfs-options.cmake +++ b/CMake/gkfs-options.cmake @@ -264,13 +264,11 @@ gkfs_define_option( ################################################################################ ## Maximum number of internal file descriptors reserved for GekkoFS -# FIXME: should be prefixed with GKFS_ gkfs_define_variable(GKFS_MAX_INTERNAL_FDS 256 STRING "Number of file descriptors reserved for internal use" ADVANCED ) ## Maximum number of open file descriptors for GekkoFS -# FIXME: should be prefixed with GKFS_ execute_process(COMMAND getconf OPEN_MAX OUTPUT_VARIABLE _GETCONF_MAX_FDS OUTPUT_STRIP_TRAILING_WHITESPACE @@ -324,15 +322,13 @@ gkfs_define_option( ################################################################################ ## Client logging support -# FIXME: should be prefixed with GKFS_ gkfs_define_option( GKFS_ENABLE_CLIENT_LOG HELP_TEXT "Enable logging messages in clients" DEFAULT_VALUE ON ) -# FIXME: should be prefixed with GKFS_ gkfs_define_variable( - CLIENT_LOG_MESSAGE_SIZE + GKFS_CLIENT_LOG_MESSAGE_SIZE 1024 STRING "Maximum size of a log message in the client library" diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ddf2b64f..38d7f6992 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -267,7 +267,7 @@ if (GKFS_RENAME_SUPPORT) endif () if(GKFS_MAX_INTERNAL_FDS) - add_definitions(-DGKFS_MAX_INTERNAL_FDS=${GKFS_MAX_INTERNAL_FDS}) + add_definitions(-DGKFS_MAX_INTERNAL_FDS=${GKFS_MAX_INTERNAL_FDS}) endif() if(GKFS_MAX_OPEN_FDS) @@ -276,7 +276,7 @@ endif() if(GKFS_ENABLE_CLIENT_LOG) add_definitions(-DGKFS_ENABLE_LOGGING) - add_definitions(-DLIBGKFS_LOG_MESSAGE_SIZE=${CLIENT_LOG_MESSAGE_SIZE}) + add_definitions(-DLIBGKFS_LOG_MESSAGE_SIZE=${GKFS_CLIENT_LOG_MESSAGE_SIZE}) endif () if(GKFS_ENABLE_UNUSED_FUNCTIONS) diff --git a/CMakePresets.json b/CMakePresets.json index a2eb90a75..9f12e9c73 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -19,7 +19,7 @@ "GKFS_BUILD_TESTS": false, "GKFS_INSTALL_TESTS": false, "GKFS_ENABLE_CLIENT_LOG": true, - "CLIENT_LOG_MESSAGE_SIZE": "1024", + "GKFS_CLIENT_LOG_MESSAGE_SIZE": "1024", "GKFS_SYMLINK_SUPPORT": false }, "warnings": { diff --git a/docs/sphinx/devs/coverage.md b/docs/sphinx/devs/coverage.md index 6499b81e0..29070570d 100644 --- a/docs/sphinx/devs/coverage.md +++ b/docs/sphinx/devs/coverage.md @@ -49,7 +49,6 @@ that greatly simplify this process. Thus, GekkoFS provides a CMake $ cmake --preset=default-coverage Preset CMake variables: - CLIENT_LOG_MESSAGE_SIZE="512" CMAKE_BUILD_TYPE="Coverage" CMAKE_CXX_COMPILER="/usr/bin/g++" CMAKE_CXX_FLAGS="-Wall -Wextra -fdiagnostics-color=always --pedantic -Wno-unused-parameter -Wno-missing-field-initializers -DGKFS_DEBUG_BUILD -DHERMES_DEBUG_BUILD" @@ -59,6 +58,7 @@ Preset CMake variables: CMAKE_EXE_LINKER_FLAGS_COVERAGE="--coverage" CMAKE_MAP_IMPORTED_CONFIG_COVERAGE="Coverage;RelWithDebInfo;Release;Debug;" CMAKE_SHARED_LINKER_FLAGS_COVERAGE="--coverage" + GKFS_CLIENT_LOG_MESSAGE_SIZE="512" GKFS_ENABLE_CLIENT_LOG:BOOL="TRUE" GKFS_BUILD_DOCUMENTATION:BOOL="TRUE" GKFS_BUILD_TESTS:BOOL="TRUE" diff --git a/include/client/preload_context.hpp b/include/client/preload_context.hpp index ed6bde47d..4be2eeeb0 100644 --- a/include/client/preload_context.hpp +++ b/include/client/preload_context.hpp @@ -77,7 +77,8 @@ enum class RelativizeStatus { internal, external, fd_unknown, fd_not_a_dir }; */ class PreloadContext { - static auto constexpr MIN_INTERNAL_FD = GKFS_MAX_OPEN_FDS - GKFS_MAX_INTERNAL_FDS; + static auto constexpr MIN_INTERNAL_FD = + GKFS_MAX_OPEN_FDS - GKFS_MAX_INTERNAL_FDS; static auto constexpr MAX_USER_FDS = MIN_INTERNAL_FD; private: diff --git a/src/client/preload.cpp b/src/client/preload.cpp index 1d082907a..339734194 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -266,7 +266,9 @@ init_preload() { // happens during our internal initialization, there's no way for us to // control this creation and the fd will be created in the // [0, MAX_USER_FDS) range rather than in our private - // [MAX_USER_FDS, GKFS_MAX_OPEN_FDS) range. To prevent this for our internal + // [MAX_USER_FDS, GKFS_MAX_OPEN_FDS) range. + // with MAX_USER_FDS = GKFS_MAX_OPEN_FDS - GKFS_MAX_INTERNAL_FDS + // To prevent this for our internal // initialization code, we forcefully occupy the user fd range to force // such modules to create fds in our private range. CTX->protect_user_fds(); -- GitLab