diff --git a/CMake/FindLZ4.cmake b/CMake/FindLZ4.cmake index f4b9df3386639952a4fdd6d32c34c4cce66a6660..1775e6db18b66c5d6072c9a36a73239e51f1c324 100644 --- a/CMake/FindLZ4.cmake +++ b/CMake/FindLZ4.cmake @@ -18,7 +18,7 @@ set(LZ4_LIBRARIES ${LZ4_LIBRARY} ) set(LZ4_INCLUDE_DIRS ${LZ4_INCLUDE_DIR} ) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(lz4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) +find_package_handle_standard_args(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) mark_as_advanced( LZ4_LIBRARY diff --git a/CMake/FindSnappy.cmake b/CMake/FindSnappy.cmake index 6ff0ecd434f972b2e3bdce9afd19a91c3c000810..f48b29291119ce34399e2791caec4821f10861bd 100644 --- a/CMake/FindSnappy.cmake +++ b/CMake/FindSnappy.cmake @@ -11,7 +11,7 @@ set(Snappy_INCLUDE_DIRS ${Snappy_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(snappy DEFAULT_MSG Snappy_LIBRARY Snappy_INCLUDE_DIR) +find_package_handle_standard_args(Snappy DEFAULT_MSG Snappy_LIBRARY Snappy_INCLUDE_DIR) mark_as_advanced( Snappy_LIBRARY diff --git a/CMake/FindZStd.cmake b/CMake/FindZStd.cmake index dc6612b69e61b7bb4120d1f484dc793ff5aaec45..cc76a3bd58fec372e149f812453eb5293fe6ad06 100644 --- a/CMake/FindZStd.cmake +++ b/CMake/FindZStd.cmake @@ -1,29 +1,29 @@ # # - Try to find Facebook zstd library # This will define -# ZSTD_FOUND -# ZSTD_INCLUDE_DIR -# ZSTD_LIBRARIES +# ZStd_FOUND +# ZStd_INCLUDE_DIR +# ZStd_LIBRARIES # -find_path(ZSTD_INCLUDE_DIR - NAMES zstd.h -) +find_path(ZStd_INCLUDE_DIR + NAMES zstd.h + ) -find_library(ZSTD_LIBRARY - NAMES zstd -) +find_library(ZStd_LIBRARY + NAMES zstd + ) -set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) -set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR}) +set(ZStd_LIBRARIES ${ZStd_LIBRARY}) +set(ZStd_INCLUDE_DIRS ${ZStd_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ZSTD - DEFAULT_MSG ZSTD_LIBRARY ZSTD_INCLUDE_DIR -) +find_package_handle_standard_args(ZStd + DEFAULT_MSG ZStd_LIBRARY ZStd_INCLUDE_DIR + ) mark_as_advanced( - ZSTD_LIBRARY - ZSTD_INCLUDE_DIR + ZStd_LIBRARY + ZStd_INCLUDE_DIR ) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f3a2a1904891c7b0db0b2cf55fb67151822efa9..398a9b7b4df47fa4c33611d5ac5c784a9a8a5123 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,21 +7,21 @@ project( enable_testing() -if(NOT CMAKE_COMPILER_IS_GNUCC) +if (NOT CMAKE_COMPILER_IS_GNUCC) message(FATAL_ERROR "The choosen C compiler is not gcc and is not supported") -endif() -if(NOT CMAKE_COMPILER_IS_GNUCXX) +endif () +if (NOT CMAKE_COMPILER_IS_GNUCXX) message(FATAL_ERROR "The choosen C++ compiler is not g++ and is not supported") -endif() +endif () -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release - CACHE STRING "Choose the type of build: Debug Release Memcheck" FORCE) + CACHE STRING "Choose the type of build: Debug Release Memcheck" FORCE) ENDIF (NOT CMAKE_BUILD_TYPE) message(STATUS "[gekkofs] Build type: ${CMAKE_BUILD_TYPE}") @@ -39,20 +39,20 @@ mark_as_advanced(CMAKE_CXX_FLAGS_MAINTAINER) # Project version set(GIT_VERSION_FOUND FALSE) -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) +if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) find_package(Git) - if(Git_FOUND) + if (Git_FOUND) execute_process(COMMAND /bin/bash -c "${GIT_EXECUTABLE} describe --tags --match='v*.*.*' --long --dirty" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_RET - OUTPUT_VARIABLE GIT_VERSION - ERROR_VARIABLE GIT_ERR - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if("${GIT_RET}" STREQUAL "0") + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_RET + OUTPUT_VARIABLE GIT_VERSION + ERROR_VARIABLE GIT_ERR + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if ("${GIT_RET}" STREQUAL "0") string(REGEX MATCH - "^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-(.*)$" - DROP ${GIT_VERSION}) + "^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-(.*)$" + DROP ${GIT_VERSION}) set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1}) set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2}) set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3}) @@ -60,11 +60,11 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) set(GKFS_COMMIT_HASH ${CMAKE_MATCH_5}) set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-snapshot+${GKFS_COMMIT_GAP}-${GKFS_COMMIT_HASH}") set(GIT_VERSION_FOUND TRUE) - else() + else () message(WARNING "Failed to run `git describe`: [${GIT_RET}] '${GIT_ERR}'") - endif() - endif() -endif() + endif () + endif () +endif () message(STATUS "[gekkofs] Project version: ${PROJECT_VERSION}") set(GKFS_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(GKFS_VERSION_MINOR ${PROJECT_VERSION_MINOR}) @@ -90,10 +90,9 @@ find_package(Abt REQUIRED) find_package(Margo REQUIRED) find_package(Syscall_intercept REQUIRED) -# boost dependencies, system is required for filesystem +# boost dependencies find_package(Boost 1.53 REQUIRED COMPONENTS - filesystem program_options ) @@ -105,9 +104,9 @@ option(CREATE_CHECK_PARENTS "Check parent directory existance before creating ch message(STATUS "[gekkofs] Create checks parents: ${CREATE_CHECK_PARENTS}") option(SYMLINK_SUPPORT "Compile with support for symlinks" ON) -if(SYMLINK_SUPPORT) +if (SYMLINK_SUPPORT) add_definitions(-DHAS_SYMLINKS) -endif() +endif () message(STATUS "[gekkofs] Symlink support: ${SYMLINK_SUPPORT}") set(MAX_INTERNAL_FDS 256 CACHE STRING "Number of file descriptors reserved for internal use") @@ -115,18 +114,18 @@ add_definitions(-DMAX_INTERNAL_FDS=${MAX_INTERNAL_FDS}) message(STATUS "[gekkofs] File descriptors reserved for internal use: ${MAX_INTERNAL_FDS}") execute_process(COMMAND getconf OPEN_MAX - OUTPUT_VARIABLE GETCONF_MAX_FDS - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET) -if(NOT GETCONF_MAX_FDS) + OUTPUT_VARIABLE GETCONF_MAX_FDS + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) +if (NOT GETCONF_MAX_FDS) set(GETCONF_MAX_FDS=512) -endif() +endif () add_definitions(-DMAX_OPEN_FDS=${GETCONF_MAX_FDS}) option(ENABLE_CLIENT_LOG "Enable logging messages" ON) -if(ENABLE_CLIENT_LOG) +if (ENABLE_CLIENT_LOG) add_definitions(-DGKFS_ENABLE_LOGGING) -endif() +endif () message(STATUS "[gekkofs] Client logging output: ${ENABLE_CLIENT_LOG}") option(GKFS_ENABLE_FORWARDING "Enable forwarding mode" OFF) @@ -152,37 +151,37 @@ target_link_libraries(RocksDB ${Snappy_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} - ${ZSTD_LIBRARIES} + ${ZStd_LIBRARIES} ${LZ4_LIBRARIES} -) + ) -if(${JeMalloc_FOUND}) +if (${JeMalloc_FOUND}) target_link_libraries(RocksDB INTERFACE ${JEMALLOC_LIBRARIES} - ) -endif() + ) +endif () # we cannot use target_include_directories with CMake < 3.11 set_target_properties(RocksDB PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${ROCKSDB_INCLUDE_DIRS} -) + ) add_library(spdlog INTERFACE) # we cannot use target_include_directories with CMake < 3.11 set_target_properties(spdlog PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/external" -) + ) add_subdirectory(external/fmt) set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON) -if(ENABLE_CLIENT_LOG) +if (ENABLE_CLIENT_LOG) option(HERMES_LOGGING "" ON) option(HERMES_LOGGING_FMT_USE_BUNDLED "" OFF) option(HERMES_LOGGING_FMT_HEADER_ONLY "" OFF) -endif() +endif () option(HERMES_MARGO_COMPATIBLE_RPCS "" ON) add_subdirectory(external/hermes) @@ -197,18 +196,6 @@ include_directories( ) include(GNUInstallDirs) -include(CheckSymbolExists) - -check_cxx_source_compiles(" - #include - #include - - int main() { - struct statx buf; - statx(AT_FDCWD, \"/foo\", AT_EMPTY_PATH, STATX_BASIC_STATS, &buf); - return 0; - } -" GLIBC_HAS_STATX) # Global components add_subdirectory(src/global) @@ -222,20 +209,35 @@ option(GKFS_BUILD_TESTS "Build GekkoFS self tests" OFF) include(CMakeDependentOption) cmake_dependent_option(GKFS_INSTALL_TESTS "Install GekkoFS self tests" OFF "GKFS_BUILD_TESTS" OFF) -if(GKFS_BUILD_TESTS) +if (GKFS_BUILD_TESTS) + # check symbols exists doesn't work for statx. This is a workaround + check_cxx_source_compiles(" + #include + #include + + int main() { + struct statx buf; + statx(AT_FDCWD, \"/foo\", AT_EMPTY_PATH, STATX_BASIC_STATS, &buf); + return 0; + } + " GLIBC_HAS_STATX) + # STATX_TYPE must be set for c++17 for statx() to be found for tests + if (GLIBC_HAS_STATX) + add_definitions(-DSTATX_TYPE=1) + endif () message(STATUS "[gekkofs] Preparing tests...") set(GKFS_TESTS_INTERFACE "lo" CACHE STRING "Network interface to use when running tests (default: lo)") message(STATUS "[gekkofs] Network interface for tests: ${GKFS_TESTS_INTERFACE}") message(STATUS "[gekkofs] Check for forwarding tests...") - if(ENABLE_FORWARDING) + if (ENABLE_FORWARDING) set(GKFS_TESTS_FORWARDING "ON" CACHE STRING "Enable I/O forwarding tests (default: OFF)") - else() + else () set(GKFS_TESTS_FORWARDING "OFF" CACHE STRING "Enable I/O forwarding tests (default: OFF)") - endif() + endif () message(STATUS "[gekkofs] Forwarding tests: ${GKFS_TESTS_FORWARDING}") add_subdirectory(tests) -else() +else () unset(GKFS_TESTS_INTERFACE CACHE) -endif() +endif () diff --git a/include/client/env.hpp b/include/client/env.hpp index 4034dff51187efeac0a0bda68803f3d4c6f4a9cf..5252a93f58450e2d448a7e3b37b6c0a590301464 100644 --- a/include/client/env.hpp +++ b/include/client/env.hpp @@ -19,8 +19,7 @@ #define ADD_PREFIX(str) CLIENT_ENV_PREFIX str /* Environment variables for the GekkoFS client */ -namespace gkfs { -namespace env { +namespace gkfs::env { static constexpr auto LOG = ADD_PREFIX("LOG"); @@ -37,8 +36,7 @@ static constexpr auto HOSTS_FILE = ADD_PREFIX("HOSTS_FILE"); static constexpr auto FORWARDING_MAP_FILE = ADD_PREFIX("FORWARDING_MAP_FILE"); #endif -} // namespace env -} // namespace gkfs +} // namespace gkfs::env #undef ADD_PREFIX diff --git a/include/client/gkfs_functions.hpp b/include/client/gkfs_functions.hpp index f7ffa87d7ee767be6234f6be9bc8257dc93b5b3e..e88cfd627b8dd3e98e29cdcdb4aff7236d84dc56 100644 --- a/include/client/gkfs_functions.hpp +++ b/include/client/gkfs_functions.hpp @@ -22,8 +22,7 @@ struct statvfs; struct linux_dirent; struct linux_dirent64; -namespace gkfs { -namespace syscall { +namespace gkfs::syscall { int gkfs_open(const std::string& path, mode_t mode, int flags); @@ -134,7 +133,6 @@ gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp, int gkfs_rmdir(const std::string& path); -} // namespace syscall -} // namespace gkfs +} // namespace gkfs::syscall #endif // GEKKOFS_GKFS_FUNCTIONS_HPP diff --git a/include/client/intercept.hpp b/include/client/intercept.hpp index 4565a8ccf4851a8f2154dc3230d827502d343aef..e3fe1d94d00a1f520a70d86b998832a958495d53 100644 --- a/include/client/intercept.hpp +++ b/include/client/intercept.hpp @@ -14,8 +14,7 @@ #ifndef GEKKOFS_INTERCEPT_HPP #define GEKKOFS_INTERCEPT_HPP -namespace gkfs { -namespace preload { +namespace gkfs::preload { int internal_hook_guard_wrapper(long syscall_number, long arg0, long arg1, @@ -35,7 +34,6 @@ start_interception(); void stop_interception(); -} // namespace preload -} // namespace gkfs +} // namespace gkfs::preload #endif diff --git a/include/client/logging.hpp b/include/client/logging.hpp index 174d9db84d5c34092358a7ec7a854fabbbc948d8..2225f08d1e0a30e2f562b22e06c46449914f56fa 100644 --- a/include/client/logging.hpp +++ b/include/client/logging.hpp @@ -17,9 +17,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -29,8 +29,7 @@ #include #endif -namespace gkfs { -namespace log { +namespace gkfs::log { enum class log_level : short { print_syscalls = 1 << 0, @@ -375,7 +374,7 @@ struct logger { void log_syscall(syscall::info info, const long syscall_number, - const long args[6], boost::optional result = boost::none); + const long args[6], std::optional result = {}); static std::shared_ptr& global_logger() { @@ -437,8 +436,7 @@ static_buffer::grow(std::size_t size) { abort(); } -} // namespace log -} // namespace gkfs +} // namespace gkfs::log #define LOG(XXX, ...) LOG_##XXX(__VA_ARGS__) diff --git a/include/client/make_array.hpp b/include/client/make_array.hpp index 5a596b69ecfca35e1e6d0e39736b908ea3e489dd..2d1618c6009519475fe7824dcf6b39ca729db874 100644 --- a/include/client/make_array.hpp +++ b/include/client/make_array.hpp @@ -14,8 +14,9 @@ #ifndef LIBGKFS_UTILS_MAKE_ARRAY_HPP #define LIBGKFS_UTILS_MAKE_ARRAY_HPP -namespace gkfs { -namespace util { +#include + +namespace gkfs::util { template constexpr auto @@ -27,7 +28,6 @@ make_array(T&&... values) -> std::array< sizeof...(T)>{std::forward(values)...}; } -} // namespace util -} // namespace gkfs +} // namespace gkfs::util #endif // LIBGKFS_UTILS_MAKE_ARRAY_HPP diff --git a/include/client/open_dir.hpp b/include/client/open_dir.hpp index c782cb72f5f179e5d3d8744cd704a68e5bac5144..1988f13541a7f9c15a7187ee97d85c68d13f649e 100644 --- a/include/client/open_dir.hpp +++ b/include/client/open_dir.hpp @@ -20,8 +20,7 @@ #include -namespace gkfs { -namespace filemap { +namespace gkfs::filemap { class DirEntry { private: @@ -56,7 +55,6 @@ public: size(); }; -} // namespace filemap -} // namespace gkfs +} // namespace gkfs::filemap #endif // GEKKOFS_OPEN_DIR_HPP diff --git a/include/client/open_file_map.hpp b/include/client/open_file_map.hpp index b9623c414f79c261d170f9e118c7541d2efe5190..a35a05ff8a0536c707cf1d76ec2ce66b6a45c0a8 100644 --- a/include/client/open_file_map.hpp +++ b/include/client/open_file_map.hpp @@ -20,8 +20,7 @@ #include #include -namespace gkfs { -namespace filemap { +namespace gkfs::filemap { /* Forward declaration */ class OpenDir; @@ -139,7 +138,6 @@ public: get_fd_idx(); }; -} // namespace filemap -} // namespace gkfs +} // namespace gkfs::filemap #endif // GEKKOFS_OPEN_FILE_MAP_HPP diff --git a/include/client/path.hpp b/include/client/path.hpp index 47e161e650a840f30b29302bb3f5747802d6527a..6b6cf851c7e271d7cbde823d7b3f752de26490a1 100644 --- a/include/client/path.hpp +++ b/include/client/path.hpp @@ -14,8 +14,7 @@ #include #include -namespace gkfs { -namespace path { +namespace gkfs::path { unsigned int match_components(const std::string& path, unsigned int& path_components, @@ -43,5 +42,4 @@ init_cwd(); void set_cwd(const std::string& path, bool internal); -} // namespace path -} // namespace gkfs +} // namespace gkfs::path diff --git a/include/client/preload.hpp b/include/client/preload.hpp index 5d1a89892ad53e0e65d5e445f43a420427b65d97..2c6f01caa8b98a50e97527428846d896ab135c51 100644 --- a/include/client/preload.hpp +++ b/include/client/preload.hpp @@ -19,12 +19,10 @@ #define EUNKNOWN (-1) #define CTX gkfs::preload::PreloadContext::getInstance() -namespace gkfs { -namespace preload { +namespace gkfs::preload { void init_ld_env_if_needed(); -} // namespace preload -} // namespace gkfs +} // namespace gkfs::preload void init_preload() __attribute__((constructor)); diff --git a/include/client/preload_util.hpp b/include/client/preload_util.hpp index 0636878d4315671998b1eb23f27f875f87e24454..f42fcd979c2301cea3eed9beb890c8e41413b6c3 100644 --- a/include/client/preload_util.hpp +++ b/include/client/preload_util.hpp @@ -23,8 +23,7 @@ #include #include -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { struct MetadentryUpdateFlags { bool atime = false; @@ -39,8 +38,7 @@ struct MetadentryUpdateFlags { bool path = false; }; -} // namespace metadata -} // namespace gkfs +} // namespace gkfs::metadata // Hermes instance namespace hermes { @@ -50,8 +48,7 @@ class async_engine; extern std::unique_ptr ld_network_service; // function definitions -namespace gkfs { -namespace util { +namespace gkfs::util { template constexpr typename std::underlying_type::type to_underlying(E e) { @@ -77,7 +74,6 @@ read_hosts_file(); void connect_to_hosts(const std::vector>& hosts); -} // namespace util -} // namespace gkfs +} // namespace gkfs::util #endif // GEKKOFS_PRELOAD_UTIL_HPP diff --git a/include/client/rpc/forward_data.hpp b/include/client/rpc/forward_data.hpp index 005ea00d4b31dfde4d08f4219f6f97f01fade847..a150044f40b0532526735dd47d421abc752dd8d3 100644 --- a/include/client/rpc/forward_data.hpp +++ b/include/client/rpc/forward_data.hpp @@ -15,8 +15,7 @@ #ifndef GEKKOFS_CLIENT_FORWARD_DATA_HPP #define GEKKOFS_CLIENT_FORWARD_DATA_HPP -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { struct ChunkStat { unsigned long chunk_size; @@ -42,7 +41,6 @@ forward_truncate(const std::string& path, size_t current_size, size_t new_size); std::pair forward_get_chunk_stat(); -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc #endif // GEKKOFS_CLIENT_FORWARD_DATA_HPP diff --git a/include/client/rpc/forward_management.hpp b/include/client/rpc/forward_management.hpp index 539f55cb8041131778b48785426fb8c4f8591fc2..48956f518375b5e558a28b65f4bd3dc45ef2fdfc 100644 --- a/include/client/rpc/forward_management.hpp +++ b/include/client/rpc/forward_management.hpp @@ -15,13 +15,11 @@ #ifndef GEKKOFS_CLIENT_FORWARD_MNGMNT_HPP #define GEKKOFS_CLIENT_FORWARD_MNGMNT_HPP -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { bool forward_get_fs_config(); -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc #endif // GEKKOFS_CLIENT_FORWARD_MNGMNT_HPP diff --git a/include/client/syscalls/args.hpp b/include/client/syscalls/args.hpp index c706addd4d33b4b3942ac65240803f0f4153fe93..e2829626ca2ffefd4aa49dea68c1c40acefd4905 100644 --- a/include/client/syscalls/args.hpp +++ b/include/client/syscalls/args.hpp @@ -18,12 +18,14 @@ #define GKFS_SYSCALLS_ARGS_HPP #include -#include +#include +#include #include #include #include #include #include +#include #include #include @@ -78,7 +80,7 @@ static constexpr auto generic = type::generic; struct printable_arg { const char* const name; const long value; - boost::optional size; + std::optional size; }; diff --git a/include/config.hpp b/include/config.hpp index 98928b75dd9c1b91b40d0512f09acb74f680891a..33fbe3f8cfa47e6930d7ad09f009a4597ba03927 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -20,8 +20,7 @@ #define CLIENT_ENV_PREFIX "LIBGKFS_" #define DAEMON_ENV_PREFIX "GKFS_" -namespace gkfs { -namespace config { +namespace gkfs::config { constexpr auto hostfile_path = "./gkfs_hosts.txt"; constexpr auto forwarding_file_path = "./gkfs_forwarding.map"; @@ -70,7 +69,6 @@ namespace rocksdb { constexpr auto use_write_ahead_log = false; } // namespace rocksdb -} // namespace config -} // namespace gkfs +} // namespace gkfs::config #endif // GEKKOFS_CONFIG_HPP diff --git a/include/daemon/backend/metadata/db.hpp b/include/daemon/backend/metadata/db.hpp index e899068d9cf1203959d3f42161fc1fd9dacba10c..c234f87a468935363097c225f7fe39ff98653d14 100644 --- a/include/daemon/backend/metadata/db.hpp +++ b/include/daemon/backend/metadata/db.hpp @@ -20,8 +20,7 @@ namespace rdb = rocksdb; -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { class MetadataDB { private: @@ -68,7 +67,6 @@ public: iterate_all(); }; -} // namespace metadata -} // namespace gkfs +} // namespace gkfs::metadata #endif // GEKKOFS_METADATA_DB_HPP diff --git a/include/daemon/handler/rpc_util.hpp b/include/daemon/handler/rpc_util.hpp index 52fb1b60cb5d5ff8c0b7af836912523caad712de..ebfbbb92dfe4096b3a167a4accae6084dcc18d0e 100644 --- a/include/daemon/handler/rpc_util.hpp +++ b/include/daemon/handler/rpc_util.hpp @@ -22,8 +22,7 @@ extern "C" { #include -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { template inline hg_return_t @@ -96,8 +95,7 @@ cleanup_respond(hg_handle_t* handle, OutputType* output) { return ret; } -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc #endif // GEKKOFS_DAEMON_RPC_UTIL_HPP diff --git a/include/daemon/ops/data.hpp b/include/daemon/ops/data.hpp index 86831ea1689b00b6c21edde203fa2fd85adc3a83..808b807e4920b8c50fe786101a487f34fe72da10 100644 --- a/include/daemon/ops/data.hpp +++ b/include/daemon/ops/data.hpp @@ -25,8 +25,7 @@ extern "C" { #include } -namespace gkfs { -namespace data { +namespace gkfs::data { class ChunkOpException : public std::runtime_error { public: @@ -221,7 +220,6 @@ public: wait_for_tasks_and_push_back(const bulk_args& args); }; -} // namespace data -} // namespace gkfs +} // namespace gkfs::data #endif // GEKKOFS_DAEMON_DATA_HPP diff --git a/include/global/chunk_calc_util.hpp b/include/global/chunk_calc_util.hpp index 4e0ccb8db7dc09f7372b0e6ba59434b82f843f2a..bbe14622e3a6893d56b7dbd567018208fa92f3c9 100644 --- a/include/global/chunk_calc_util.hpp +++ b/include/global/chunk_calc_util.hpp @@ -16,8 +16,7 @@ #include -namespace gkfs { -namespace util { +namespace gkfs::util { /** * Compute the base2 logarithm for 64 bit integers @@ -123,7 +122,6 @@ chnk_count_for_offset(const off64_t offset, const size_t count, (chnk_start >> log2(chnk_size)) + 1); } -} // namespace util -} // namespace gkfs +} // namespace gkfs::util #endif diff --git a/include/global/global_defs.hpp b/include/global/global_defs.hpp index 9635120c1a6f0df4b2ee45a9d3dd26b5eb28de35..d759af877d312b2bc2c889519c240b54f8fd532d 100644 --- a/include/global/global_defs.hpp +++ b/include/global/global_defs.hpp @@ -14,11 +14,9 @@ #ifndef GEKKOFS_GLOBAL_DEFS_HPP #define GEKKOFS_GLOBAL_DEFS_HPP -namespace gkfs { - // These constexpr set the RPC's identity and which handler the receiver end // should use -namespace rpc { +namespace gkfs::rpc { using chnk_id_t = unsigned long; @@ -49,8 +47,6 @@ constexpr auto ofi_tcp = "ofi+tcp"; constexpr auto ofi_verbs = "ofi+verbs"; constexpr auto na_sm = "na+sm"; } // namespace protocol -} // namespace rpc - -} // namespace gkfs +} // namespace gkfs::rpc #endif // GEKKOFS_GLOBAL_DEFS_HPP diff --git a/include/global/log_util.hpp b/include/global/log_util.hpp index bf6bd727d51642ac5433c191e9115bbc9e826fb3..fe2cd89bb37b655bd7ea8ee4f87603b8fffd0f3e 100644 --- a/include/global/log_util.hpp +++ b/include/global/log_util.hpp @@ -16,8 +16,7 @@ #include -namespace gkfs { -namespace log { +namespace gkfs::log { spdlog::level::level_enum get_level(std::string level_str); @@ -28,7 +27,6 @@ get_level(unsigned long level); void setup(const std::vector& loggers, spdlog::level::level_enum level, const std::string& path); -} // namespace log -} // namespace gkfs +} // namespace gkfs::log #endif diff --git a/include/global/metadata.hpp b/include/global/metadata.hpp index 5a6b3d328d0fc8d567ff6c14615de1b078845ac4..5a141088329b30d42a3b87f226ea59fe6cde5c68 100644 --- a/include/global/metadata.hpp +++ b/include/global/metadata.hpp @@ -21,22 +21,21 @@ #include #include -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { constexpr mode_t LINK_MODE = ((S_IRWXU | S_IRWXG | S_IRWXO) | S_IFLNK); class Metadata { private: - time_t atime_; // access time. gets updated on file access unless mounted - // with noatime - time_t mtime_; // modify time. gets updated when file content is modified. - time_t ctime_; // change time. gets updated when the file attributes are - // changed AND when file content is modified. - mode_t mode_; - nlink_t link_count_; // number of names for this inode (hardlinks) - size_t size_; // size_ in bytes, might be computed instead of stored - blkcnt_t blocks_; // allocated file system blocks_ + time_t atime_{}; // access time. gets updated on file access unless mounted + // with noatime + time_t mtime_{}; // modify time. gets updated when file content is modified. + time_t ctime_{}; // change time. gets updated when the file attributes are + // changed AND when file content is modified. + mode_t mode_{}; + nlink_t link_count_{}; // number of names for this inode (hardlinks) + size_t size_{}; // size_ in bytes, might be computed instead of stored + blkcnt_t blocks_{}; // allocated file system blocks_ #ifdef HAS_SYMLINKS std::string target_path_; // For links this is the path of the target file #endif @@ -122,8 +121,7 @@ public: #endif }; -} // namespace metadata -} // namespace gkfs +} // namespace gkfs::metadata #endif // FS_METADATA_H diff --git a/include/global/path_util.hpp b/include/global/path_util.hpp index 02e9fe29c91865223a2b309fcc14278b69a85643..d88e06e6bdb8c525a0ed4b3a68aea333ad21f17f 100644 --- a/include/global/path_util.hpp +++ b/include/global/path_util.hpp @@ -17,8 +17,7 @@ #include #include -namespace gkfs { -namespace path { +namespace gkfs::path { constexpr unsigned int max_length = 4096; // 4k chars @@ -46,7 +45,6 @@ dirname(const std::string& path); std::vector split_path(const std::string& path); -} // namespace path -} // namespace gkfs +} // namespace gkfs::path #endif // GEKKOFS_PATH_UTIL_HPP diff --git a/include/global/rpc/distributor.hpp b/include/global/rpc/distributor.hpp index 8f8d915937be1038488e692f68bc4150ed731786..b3f9a926d48d414fb90750011c77b83b8f38f521 100644 --- a/include/global/rpc/distributor.hpp +++ b/include/global/rpc/distributor.hpp @@ -18,8 +18,7 @@ #include #include -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { using chunkid_t = unsigned int; using host_t = unsigned int; @@ -109,7 +108,6 @@ public: locate_directory_metadata(const std::string& path) const override; }; -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc #endif // GEKKOFS_RPC_LOCATOR_HPP diff --git a/include/global/rpc/rpc_util.hpp b/include/global/rpc/rpc_util.hpp index 139a1418f9cee1d847feaa6f3a85cdf2e47c6a9d..3699e7bc1aec4194c0c898c95bf867571a2831a4 100644 --- a/include/global/rpc/rpc_util.hpp +++ b/include/global/rpc/rpc_util.hpp @@ -22,8 +22,7 @@ extern "C" { #include -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { hg_bool_t bool_to_merc_bool(bool state); @@ -34,7 +33,6 @@ get_my_hostname(bool short_hostname = false); std::string get_host_by_name(const std::string& hostname); -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc #endif // GEKKOFS_GLOBAL_RPC_UTILS_HPP diff --git a/src/client/gkfs_functions.cpp b/src/client/gkfs_functions.cpp index 2684df4b7248ae214c3ace8a37edd894aa95285a..b8450ca969f6bce071e300e629246f961f181f4f 100644 --- a/src/client/gkfs_functions.cpp +++ b/src/client/gkfs_functions.cpp @@ -94,8 +94,7 @@ check_parent_dir(const std::string& path) { } } // namespace -namespace gkfs { -namespace syscall { +namespace gkfs::syscall { /** * gkfs wrapper for open() system calls @@ -734,7 +733,7 @@ gkfs_pread(std::shared_ptr file, char* buf, // Zeroing buffer before read is only relevant for sparse files. Otherwise // sparse regions contain invalid data. - if(gkfs::config::io::zero_buffer_before_read) { + if constexpr(gkfs::config::io::zero_buffer_before_read) { memset(buf, 0, sizeof(char) * count); } auto ret = gkfs::rpc::forward_read(file->path(), buf, offset, count); @@ -1146,5 +1145,4 @@ gkfs_readlink(const std::string& path, char* buf, int bufsize) { #endif -} // namespace syscall -} // namespace gkfs +} // namespace gkfs::syscall diff --git a/src/client/hooks.cpp b/src/client/hooks.cpp index 1e845cd44bcddc2766c94ab78cfdca54bfa8361e..0dec98e7427a0847d7c8f1cf060ec20e6f529ed8 100644 --- a/src/client/hooks.cpp +++ b/src/client/hooks.cpp @@ -40,8 +40,7 @@ with_errno(int ret) { } // namespace -namespace gkfs { -namespace hook { +namespace gkfs::hook { int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { @@ -891,5 +890,4 @@ hook_fsync(unsigned int fd) { return syscall_no_intercept(SYS_fsync, fd); } -} // namespace hook -} // namespace gkfs +} // namespace gkfs::hook diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index 1954350c752e8b05bb3d83fa4a1d6df42653228a..c7f1934c2a1cb9866311b526aff4f2fd4e2d0ff2 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -802,8 +802,7 @@ hook_clone_at_parent(unsigned long flags, void* child_stack, int* ptid, } // namespace -namespace gkfs { -namespace preload { +namespace gkfs::preload { int internal_hook_guard_wrapper(long syscall_number, long arg0, long arg1, @@ -911,5 +910,4 @@ stop_interception() { intercept_hook_point_clone_parent = nullptr; } -} // namespace preload -} // namespace gkfs +} // namespace gkfs::preload diff --git a/src/client/logging.cpp b/src/client/logging.cpp index 9f1e099aaaed621669534ab19c937e90b2fe828c..613f4e18c8e7270f8692fb37017aaca02263cbbd 100644 --- a/src/client/logging.cpp +++ b/src/client/logging.cpp @@ -391,7 +391,7 @@ logger::~logger() { void logger::log_syscall(syscall::info info, const long syscall_number, - const long args[6], boost::optional result) { + const long args[6], std::optional result) { const bool log_syscall_entry = !!(log::syscall_at_entry & log_mask_); diff --git a/src/client/preload.cpp b/src/client/preload.cpp index b0985d9ba6587991a953c839d1982a16f2c41b39..812c54c562fe9aae52265253d0db99a5d78d8494 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -221,16 +221,14 @@ log_prog_name() { } // namespace -namespace gkfs { -namespace preload { +namespace gkfs::preload { void init_ld_env_if_needed() { pthread_once(&init_env_thread, init_ld_environment_); } -} // namespace preload -} // namespace gkfs +} // namespace gkfs::preload /** * Called initially ONCE when preload library is used with the LD_PRELOAD diff --git a/src/client/preload_context.cpp b/src/client/preload_context.cpp index 29094beaae8782b39d850ff50fb9188a9559b1af..fbba7683e2ca14e7924608487d9619e77fff55af 100644 --- a/src/client/preload_context.cpp +++ b/src/client/preload_context.cpp @@ -30,8 +30,7 @@ extern "C" { #include } -namespace gkfs { -namespace preload { +namespace gkfs::preload { decltype(PreloadContext::MIN_INTERNAL_FD) constexpr PreloadContext:: MIN_INTERNAL_FD; @@ -410,5 +409,4 @@ PreloadContext::unprotect_user_fds() { internal_fds_must_relocate_ = true; } -} // namespace preload -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::preload \ No newline at end of file diff --git a/src/client/preload_util.cpp b/src/client/preload_util.cpp index f827a7780f83b8822c4270a19b3bb40189246a20..c88a10c9575713b07cdf4b2ad1754387d18958e5 100644 --- a/src/client/preload_util.cpp +++ b/src/client/preload_util.cpp @@ -163,8 +163,7 @@ load_hostfile(const std::string& path) { } // namespace -namespace gkfs { -namespace util { +namespace gkfs::util { /** * Retrieve metadata from daemon @@ -399,5 +398,4 @@ connect_to_hosts(const vector>& hosts) { CTX->hosts(addrs); } -} // namespace util -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::util \ No newline at end of file diff --git a/src/client/rpc/forward_data.cpp b/src/client/rpc/forward_data.cpp index 6d87b31db66b49deaf912033afd90b914b94bf6a..2961673eaec1c4d21059005bc201856d781dc665 100644 --- a/src/client/rpc/forward_data.cpp +++ b/src/client/rpc/forward_data.cpp @@ -23,8 +23,7 @@ using namespace std; -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { /* * This file includes all metadata RPC calls. @@ -535,5 +534,4 @@ forward_get_chunk_stat() { return make_pair(0, ChunkStat{chunk_size, chunk_total, chunk_free}); } -} // namespace rpc -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::rpc \ No newline at end of file diff --git a/src/client/rpc/forward_management.cpp b/src/client/rpc/forward_management.cpp index 843999526f2e94efc4f5e3df352fa40d9e9c3128..d666e8795509186d040c46ac307148b07df5bd14 100644 --- a/src/client/rpc/forward_management.cpp +++ b/src/client/rpc/forward_management.cpp @@ -16,8 +16,6 @@ #include #include -#include - namespace gkfs { namespace rpc { diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 793ced82fa92f74fbe2309a809464662490d2473..35730d4d2739e25212e942563004c28492600095 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -48,7 +48,6 @@ set(DAEMON_LINK_LIBRARIES # others Boost::boost Boost::program_options - Boost::filesystem Threads::Threads ) set(DAEMON_INCLUDE_DIRS diff --git a/src/daemon/backend/data/CMakeLists.txt b/src/daemon/backend/data/CMakeLists.txt index 9535714be84359270aadad00d4b833bf89380c5d..8a9356d4081c0a87ade664015cb68cc29b173d88 100644 --- a/src/daemon/backend/data/CMakeLists.txt +++ b/src/daemon/backend/data/CMakeLists.txt @@ -15,7 +15,8 @@ target_sources(storage target_link_libraries(storage PRIVATE spdlog - Boost::filesystem + # open issue for std::filesystem https://gitlab.kitware.com/cmake/cmake/-/issues/17834 + stdc++fs -ldl ) diff --git a/src/daemon/backend/data/chunk_storage.cpp b/src/daemon/backend/data/chunk_storage.cpp index b6b6aa190d742d3624e6d23f6ba486b0820ae90a..a343a132a739f7cbbe80e824cec8a458e77312b6 100644 --- a/src/daemon/backend/data/chunk_storage.cpp +++ b/src/daemon/backend/data/chunk_storage.cpp @@ -18,18 +18,17 @@ #include -#include +#include #include extern "C" { #include } -namespace bfs = boost::filesystem; +namespace fs = std::filesystem; using namespace std; -namespace gkfs { -namespace data { +namespace gkfs::data { // private functions @@ -108,10 +107,10 @@ ChunkStorage::destroy_chunk_space(const string& file_path) const { auto chunk_dir = absolute(get_chunks_dir(file_path)); try { // Note: remove_all does not throw an error when path doesn't exist. - auto n = bfs::remove_all(chunk_dir); + auto n = fs::remove_all(chunk_dir); log_->debug("{}() Removed '{}' files from '{}'", __func__, n, chunk_dir); - } catch(const bfs::filesystem_error& e) { + } catch(const fs::filesystem_error& e) { auto err_str = fmt::format( "{}() Failed to remove chunk directory. Path: '{}', Error: '{}'", __func__, chunk_dir, e.what()); @@ -268,9 +267,9 @@ ChunkStorage::trim_chunk_space(const string& file_path, gkfs::rpc::chnk_id_t chunk_start) { auto chunk_dir = absolute(get_chunks_dir(file_path)); - const bfs::directory_iterator end; + const fs::directory_iterator end; auto err_flag = false; - for(bfs::directory_iterator chunk_file(chunk_dir); chunk_file != end; + for(fs::directory_iterator chunk_file(chunk_dir); chunk_file != end; ++chunk_file) { auto chunk_path = chunk_file->path(); auto chunk_id = std::stoul(chunk_path.filename().c_str()); @@ -340,5 +339,4 @@ ChunkStorage::chunk_stat() const { return {chunksize_, bytes_total / chunksize_, bytes_free / chunksize_}; } -} // namespace data -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::data \ No newline at end of file diff --git a/src/daemon/backend/data/data_module.cpp b/src/daemon/backend/data/data_module.cpp index 781af08f58367c2650c5f9dc491012ff865ff2ed..d19157da1585d20a2a33d3be74cea5af864ee2ae 100644 --- a/src/daemon/backend/data/data_module.cpp +++ b/src/daemon/backend/data/data_module.cpp @@ -13,8 +13,7 @@ #include -namespace gkfs { -namespace data { +namespace gkfs::data { const std::shared_ptr& DataModule::log() const { @@ -26,5 +25,4 @@ DataModule::log(const std::shared_ptr& log) { DataModule::log_ = log; } -} // namespace data -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::data \ No newline at end of file diff --git a/src/daemon/backend/metadata/db.cpp b/src/daemon/backend/metadata/db.cpp index f9f61d0d83a25883461a1b03433446aba7b87371..ba985bfcb18d0f957843abdd55523fcd1496c1f6 100644 --- a/src/daemon/backend/metadata/db.cpp +++ b/src/daemon/backend/metadata/db.cpp @@ -22,8 +22,7 @@ extern "C" { #include } -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { MetadataDB::MetadataDB(const std::string& path) : path(path) { @@ -35,7 +34,7 @@ MetadataDB::MetadataDB(const std::string& path) : path(path) { options.merge_operator.reset(new MetadataMergeOperator); MetadataDB::optimize_rocksdb_options(options); write_opts.disableWAL = !(gkfs::config::rocksdb::use_write_ahead_log); - rdb::DB* rdb_ptr; + rdb::DB* rdb_ptr = nullptr; auto s = rocksdb::DB::Open(options, path, &rdb_ptr); if(!s.ok()) { throw std::runtime_error("Failed to open RocksDB: " + s.ToString()); @@ -204,5 +203,4 @@ MetadataDB::optimize_rocksdb_options(rdb::Options& options) { options.max_successive_merges = 128; } -} // namespace metadata -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::metadata \ No newline at end of file diff --git a/src/daemon/classes/fs_data.cpp b/src/daemon/classes/fs_data.cpp index cf117f0636265fdfd968954afe7223520470346b..23bc4863abb421ba21487c9a3e8bdea7bda4de24 100644 --- a/src/daemon/classes/fs_data.cpp +++ b/src/daemon/classes/fs_data.cpp @@ -15,8 +15,7 @@ #include -namespace gkfs { -namespace daemon { +namespace gkfs::daemon { // getter/setter @@ -175,5 +174,4 @@ FsData::blocks_state(bool blocks_state) { FsData::blocks_state_ = blocks_state; } -} // namespace daemon -} // namespace gkfs +} // namespace gkfs::daemon diff --git a/src/daemon/classes/rpc_data.cpp b/src/daemon/classes/rpc_data.cpp index 0d0d494f06023e01c12c868541aa497a0903867e..71251caa4c87251b4102d3added1abb1ddabf453 100644 --- a/src/daemon/classes/rpc_data.cpp +++ b/src/daemon/classes/rpc_data.cpp @@ -16,8 +16,7 @@ using namespace std; -namespace gkfs { -namespace daemon { +namespace gkfs::daemon { // Getter/Setter @@ -61,5 +60,4 @@ RPCData::self_addr_str(const std::string& addr_str) { self_addr_str_ = addr_str; } -} // namespace daemon -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::daemon \ No newline at end of file diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 98f2faf67040ffba9effe1047426cfe09c12a285..31c065f5ec4ef24fe2ce5911ef0212656dcd0027 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -29,10 +29,9 @@ #include #endif -#include #include -#include +#include #include #include #include @@ -45,7 +44,7 @@ extern "C" { using namespace std; namespace po = boost::program_options; -namespace bfs = boost::filesystem; +namespace fs = std::filesystem; static condition_variable shutdown_please; static mutex mtx; @@ -206,7 +205,7 @@ init_environment() { std::string chunk_storage_path = GKFS_DATA->rootdir() + "/data/chunks"s; GKFS_DATA->spdlogger()->debug("{}() Initializing storage backend: '{}'", __func__, chunk_storage_path); - bfs::create_directories(chunk_storage_path); + fs::create_directories(chunk_storage_path); try { GKFS_DATA->storage(std::make_shared( chunk_storage_path, gkfs::config::rpc::chunksize)); @@ -287,8 +286,8 @@ agios_initialize() { void destroy_enviroment() { GKFS_DATA->spdlogger()->debug("{}() Removing mount directory", __func__); - boost::system::error_code ecode; - bfs::remove_all(GKFS_DATA->mountdir(), ecode); + std::error_code ecode; + fs::remove_all(GKFS_DATA->mountdir(), ecode); GKFS_DATA->spdlogger()->debug("{}() Freeing I/O executions streams", __func__); for(unsigned int i = 0; i < RPC_DATA->io_streams().size(); i++) { @@ -300,7 +299,7 @@ destroy_enviroment() { GKFS_DATA->spdlogger()->debug("{}() Removing hosts file", __func__); try { gkfs::util::destroy_hosts_file(); - } catch(const bfs::filesystem_error& e) { + } catch(const fs::filesystem_error& e) { GKFS_DATA->spdlogger()->debug("{}() hosts file not found", __func__); } @@ -413,36 +412,35 @@ parse_input(const po::variables_map& vm) { auto mountdir = vm["mountdir"].as(); // Create mountdir. We use this dir to get some information on the // underlying fs with statfs in gkfs_statfs - bfs::create_directories(mountdir); - GKFS_DATA->mountdir(bfs::canonical(mountdir).native()); + fs::create_directories(mountdir); + GKFS_DATA->mountdir(fs::canonical(mountdir).native()); assert(vm.count("rootdir")); auto rootdir = vm["rootdir"].as(); #ifdef GKFS_ENABLE_FORWARDING // In forwarding mode, the backend is shared - auto rootdir_path = bfs::path(rootdir); + auto rootdir_path = fs::path(rootdir); #else - auto rootdir_path = bfs::path(rootdir) / fmt::format_int(getpid()).str(); + auto rootdir_path = fs::path(rootdir) / fmt::format_int(getpid()).str(); #endif GKFS_DATA->spdlogger()->debug("{}() Root directory: '{}'", __func__, rootdir_path.native()); - bfs::create_directories(rootdir_path); + fs::create_directories(rootdir_path); GKFS_DATA->rootdir(rootdir_path.native()); if(vm.count("metadir")) { auto metadir = vm["metadir"].as(); #ifdef GKFS_ENABLE_FORWARDING - auto metadir_path = - bfs::path(metadir) / fmt::format_int(getpid()).str(); + auto metadir_path = fs::path(metadir) / fmt::format_int(getpid()).str(); #else - auto metadir_path = bfs::path(metadir); + auto metadir_path = fs::path(metadir); #endif - bfs::create_directories(metadir_path); - GKFS_DATA->metadir(bfs::canonical(metadir_path).native()); + fs::create_directories(metadir_path); + GKFS_DATA->metadir(fs::canonical(metadir_path).native()); GKFS_DATA->spdlogger()->debug("{}() Meta directory: '{}'", __func__, metadir_path.native()); @@ -451,10 +449,9 @@ parse_input(const po::variables_map& vm) { auto metadir = vm["rootdir"].as(); #ifdef GKFS_ENABLE_FORWARDING - auto metadir_path = - bfs::path(metadir) / fmt::format_int(getpid()).str(); - bfs::create_directories(metadir_path); - GKFS_DATA->metadir(bfs::canonical(metadir_path).native()); + auto metadir_path = fs::path(metadir) / fmt::format_int(getpid()).str(); + fs::create_directories(metadir_path); + GKFS_DATA->metadir(fs::canonical(metadir_path).native()); #else GKFS_DATA->metadir(GKFS_DATA->rootdir()); #endif diff --git a/src/daemon/util.cpp b/src/daemon/util.cpp index 2f3edd9198420c82fdba746e31fad9dab6968a9c..4e6fede35b597c5b851054b329546d521a93e5e1 100644 --- a/src/daemon/util.cpp +++ b/src/daemon/util.cpp @@ -20,8 +20,7 @@ using namespace std; -namespace gkfs { -namespace util { +namespace gkfs::util { void populate_hosts_file() { @@ -49,5 +48,4 @@ destroy_hosts_file() { std::remove(GKFS_DATA->hosts_file().c_str()); } -} // namespace util -} // namespace gkfs +} // namespace gkfs::util diff --git a/src/global/metadata.cpp b/src/global/metadata.cpp index 83808eedac47e60f9a20d0f142d5e4afa4507010..cea52ad4df5405ec5bb97e77ea70d8867771639e 100644 --- a/src/global/metadata.cpp +++ b/src/global/metadata.cpp @@ -24,8 +24,7 @@ extern "C" { #include #include -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { static const char MSP = '|'; // metadata separator @@ -67,32 +66,33 @@ Metadata::Metadata(const std::string& binary_str) { ptr += read; // The order is important. don't change. - if(gkfs::config::metadata::use_atime) { + if constexpr(gkfs::config::metadata::use_atime) { assert(*ptr == MSP); atime_ = static_cast(std::stol(++ptr, &read)); assert(read > 0); ptr += read; } - if(gkfs::config::metadata::use_mtime) { + if constexpr(gkfs::config::metadata::use_mtime) { assert(*ptr == MSP); mtime_ = static_cast(std::stol(++ptr, &read)); assert(read > 0); ptr += read; } - if(gkfs::config::metadata::use_ctime) { + if constexpr(gkfs::config::metadata::use_ctime) { assert(*ptr == MSP); ctime_ = static_cast(std::stol(++ptr, &read)); assert(read > 0); ptr += read; } - if(gkfs::config::metadata::use_link_cnt) { + if constexpr(gkfs::config::metadata::use_link_cnt) { assert(*ptr == MSP); link_count_ = static_cast(std::stoul(++ptr, &read)); assert(read > 0); ptr += read; } - if(gkfs::config::metadata::use_blocks) { // last one will not encounter a - // delimiter anymore + if constexpr(gkfs::config::metadata::use_blocks) { // last one will not + // encounter a + // delimiter anymore assert(*ptr == MSP); blocks_ = static_cast(std::stoul(++ptr, &read)); assert(read > 0); @@ -119,23 +119,23 @@ Metadata::serialize() const { s += fmt::format_int(mode_).c_str(); // add mandatory mode s += MSP; s += fmt::format_int(size_).c_str(); // add mandatory size - if(gkfs::config::metadata::use_atime) { + if constexpr(gkfs::config::metadata::use_atime) { s += MSP; s += fmt::format_int(atime_).c_str(); } - if(gkfs::config::metadata::use_mtime) { + if constexpr(gkfs::config::metadata::use_mtime) { s += MSP; s += fmt::format_int(mtime_).c_str(); } - if(gkfs::config::metadata::use_ctime) { + if constexpr(gkfs::config::metadata::use_ctime) { s += MSP; s += fmt::format_int(ctime_).c_str(); } - if(gkfs::config::metadata::use_link_cnt) { + if constexpr(gkfs::config::metadata::use_link_cnt) { s += MSP; s += fmt::format_int(link_count_).c_str(); } - if(gkfs::config::metadata::use_blocks) { + if constexpr(gkfs::config::metadata::use_blocks) { s += MSP; s += fmt::format_int(blocks_).c_str(); } @@ -265,5 +265,4 @@ Metadata::is_link() const { #endif -} // namespace metadata -} // namespace gkfs +} // namespace gkfs::metadata diff --git a/src/global/path_util.cpp b/src/global/path_util.cpp index 78529363d24eb9ac49a2646139bf5a081ee8553e..e43b023f08ac3970e504ed0c87712aa5cdcf86cc 100644 --- a/src/global/path_util.cpp +++ b/src/global/path_util.cpp @@ -19,8 +19,7 @@ using namespace std; -namespace gkfs { -namespace path { +namespace gkfs::path { bool is_relative(const string& path) { @@ -156,5 +155,4 @@ dirname(const string& path) { return path.substr(0, parent_path_size); } -} // namespace path -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::path \ No newline at end of file diff --git a/src/global/rpc/distributor.cpp b/src/global/rpc/distributor.cpp index 27772cfc0ea70da3d9628465c81e2315ced294c9..70ded66c924275fcb75be8389e11b1e2de757120 100644 --- a/src/global/rpc/distributor.cpp +++ b/src/global/rpc/distributor.cpp @@ -15,8 +15,7 @@ using namespace std; -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { SimpleHashDistributor::SimpleHashDistributor(host_t localhost, unsigned int hosts_size) @@ -95,5 +94,4 @@ std::vector ForwarderDistributor::locate_directory_metadata(const std::string& path) const { return all_hosts_; } -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc diff --git a/src/global/rpc/rpc_util.cpp b/src/global/rpc/rpc_util.cpp index 68353c47d9067cd9f7bc537f9d79109d3000386a..0591fd6acff69f078793aa8689a962fc3b85dc8f 100644 --- a/src/global/rpc/rpc_util.cpp +++ b/src/global/rpc/rpc_util.cpp @@ -24,8 +24,7 @@ extern "C" { using namespace std; -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { /** * converts std bool to mercury bool @@ -90,5 +89,4 @@ get_host_by_name(const string& hostname) { return addr_str; } -} // namespace rpc -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::rpc \ No newline at end of file diff --git a/tests/integration/harness/CMakeLists.txt b/tests/integration/harness/CMakeLists.txt index f2f55409d8e279e46f22642527e2822344607963..dd0c4201d3232cdd61d1a3dc6544953cec07073c 100644 --- a/tests/integration/harness/CMakeLists.txt +++ b/tests/integration/harness/CMakeLists.txt @@ -83,7 +83,9 @@ target_link_libraries(gkfs.io CLI11::CLI11 nlohmann_json::nlohmann_json fmt::fmt -) + # open issue for std::filesystem https://gitlab.kitware.com/cmake/cmake/-/issues/17834 + stdc++fs + ) if(GKFS_INSTALL_TESTS) install(TARGETS gkfs.io diff --git a/tests/integration/harness/gkfs.io/reflection.hpp b/tests/integration/harness/gkfs.io/reflection.hpp index 91431afc749e522afa46dbd8eb8a7eea57c0c531..1375a801054eb7e38e2843857607261a4e9d8c30 100644 --- a/tests/integration/harness/gkfs.io/reflection.hpp +++ b/tests/integration/harness/gkfs.io/reflection.hpp @@ -16,18 +16,18 @@ #include #include -#include // required by DIR* - #include +extern "C" { +#include // required by DIR* +} namespace refl { namespace detail { -template +template struct property_impl { - constexpr property_impl(T Class::*aMember, - const char* aType, + constexpr property_impl(T Class::*aMember, const char* aType, const char* aName) : member{aMember}, type{aType}, diff --git a/tests/integration/harness/gkfs.io/serialize.hpp b/tests/integration/harness/gkfs.io/serialize.hpp index df1a7b1dbad952a5a86aa3ea332fe591ebd0a507..7ee43c4b65154bcedeb86087784fc3c7f4198c10 100644 --- a/tests/integration/harness/gkfs.io/serialize.hpp +++ b/tests/integration/harness/gkfs.io/serialize.hpp @@ -15,13 +15,18 @@ #define GKFS_IO_SERIALIZE_HPP #include +#include + +extern "C" { +#include +} template -nlohmann::json +nlohmann::json serialize(const T& object) { - using json = nlohmann::json; - + using json = nlohmann::json; + json j; constexpr auto n = std::tuple_size::value;