From b1974beee075f14c48fb11e40effce4ddea2b78a Mon Sep 17 00:00:00 2001 From: rnou Date: Thu, 3 Apr 2025 08:27:29 +0200 Subject: [PATCH 1/3] Fast startup --- src/client/preload.cpp | 12 ++++++------ src/client/preload_util.cpp | 31 ++++++++++++++++++++++++++----- src/daemon/util.cpp | 11 +++++++++++ src/proxy/util.cpp | 8 +++++--- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/client/preload.cpp b/src/client/preload.cpp index 7f22669e1..a32e22d52 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -329,13 +329,13 @@ init_environment() { } } - LOG(INFO, "Retrieving file system configuration..."); +// LOG(INFO, "Retrieving file system configuration..."); - if(!gkfs::rpc::forward_get_fs_config()) { - exit_error_msg( - EXIT_FAILURE, - "Unable to fetch file system configurations from daemon process through RPC."); - } + // if(!gkfs::rpc::forward_get_fs_config()) { + // exit_error_msg( + // EXIT_FAILURE, + // "Unable to fetch file system configurations from daemon process through RPC."); + // } // Initialize random number generator and seed for replica selection // in case of failure, a new replica will be selected if(CTX->get_replicas() > 0) { diff --git a/src/client/preload_util.cpp b/src/client/preload_util.cpp index 74c319bf5..78718b17d 100644 --- a/src/client/preload_util.cpp +++ b/src/client/preload_util.cpp @@ -166,8 +166,10 @@ load_hostfile(const std::string& path) { path, strerror(errno))); } vector> hosts; - const regex line_re("^(\\S+)\\s+(\\S+)\\s*(\\S*)$", - regex::ECMAScript | regex::optimize); + const regex line_re( + "^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)$", + regex::ECMAScript | regex::optimize); + string line; string host; string uri; @@ -185,9 +187,28 @@ load_hostfile(const std::string& path) { throw runtime_error( fmt::format("unrecognized line format: '{}'", line)); } - host = match[1]; + + host = match[1]; uri = match[2]; - hosts.emplace_back(host, uri); + // match[3] that is the proxy (not used here) + hosts.emplace_back(host, uri); + + // info will be repeated line per line: + CTX->mountdir(match[4]); + LOG(INFO, "Mountdir: '{}'", CTX->mountdir()); + + CTX->fs_conf()->rootdir = match[5]; + CTX->fs_conf()->atime_state = match[6] == '1'; + CTX->fs_conf()->mtime_state = match[7] == '1'; + CTX->fs_conf()->ctime_state = match[8] == '1'; + CTX->fs_conf()->link_cnt_state = match[9] == '1'; + CTX->fs_conf()->blocks_state = match[10] == '1'; + // convert match[11] and match[12] to unsigned integers. + CTX->fs_conf()->uid = std::stoi(match[11]); + CTX->fs_conf()->gid = std::stoi(match[12]); + + + } if(hosts.empty()) { throw runtime_error( @@ -564,4 +585,4 @@ lookup_proxy_addr() { CTX->proxy_host(addr); } -} // namespace gkfs::utils \ No newline at end of file +} // namespace gkfs::utils diff --git a/src/daemon/util.cpp b/src/daemon/util.cpp index 7b7165628..c2e53781d 100644 --- a/src/daemon/util.cpp +++ b/src/daemon/util.cpp @@ -47,6 +47,7 @@ #include #include #include +#include using namespace std; @@ -114,6 +115,16 @@ populate_hosts_file() { auto line_out = fmt::format("{} {}", hostname, daemon_addr); if(!proxy_addr.empty()) line_out = fmt::format("{} {}", line_out, proxy_addr); + if(proxy_addr.empty()) + line_out = fmt::format("{} {}", line_out, "NOPROXY"); + + line_out = fmt::format( + "{} {} {} {} {} {} {} {} {} {}", line_out, GKFS_DATA->mountdir(), + GKFS_DATA->rootdir(), (int) GKFS_DATA->atime_state(), + (int) GKFS_DATA->mtime_state(), (int) GKFS_DATA->ctime_state(), + (int) GKFS_DATA->link_cnt_state(), (int) GKFS_DATA->blocks_state(), + getuid(), getgid()); + // Constants for retry mechanism const int MAX_RETRIES = 5; // Maximum number of retry attempts const std::chrono::milliseconds RETRY_DELAY( diff --git a/src/proxy/util.cpp b/src/proxy/util.cpp index ac963ba8c..f1542949a 100644 --- a/src/proxy/util.cpp +++ b/src/proxy/util.cpp @@ -56,8 +56,10 @@ load_hostfile(const std::string& lfpath) { lfpath, strerror(errno))); } vector> hosts; - const regex line_re("^(\\S+)\\s+(\\S+)\\s*(\\S*)$", - regex::ECMAScript | regex::optimize); + const regex line_re( + "^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)$", + regex::ECMAScript | regex::optimize); + string line; string host; string uri; @@ -255,4 +257,4 @@ connect_to_hosts(const vector>& hosts) { } } -} // namespace gkfs::util \ No newline at end of file +} // namespace gkfs::util -- GitLab From f8d9ac6bafe90fa055080c215053ea26670ca65d Mon Sep 17 00:00:00 2001 From: Ramon Nou Date: Tue, 8 Apr 2025 18:15:43 +0200 Subject: [PATCH 2/3] updated malleable --- src/daemon/malleability/malleable_manager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/daemon/malleability/malleable_manager.cpp b/src/daemon/malleability/malleable_manager.cpp index 6af7ba34b..184ee44d7 100644 --- a/src/daemon/malleability/malleable_manager.cpp +++ b/src/daemon/malleability/malleable_manager.cpp @@ -75,8 +75,10 @@ MalleableManager::load_hostfile(const std::string& path) { path, strerror(errno))); } vector> hosts; - const regex line_re("^(\\S+)\\s+(\\S+)\\s*(\\S*)$", - regex::ECMAScript | regex::optimize); + const regex line_re( + "^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)$", + regex::ECMAScript | regex::optimize); + string line; string host; string uri; -- GitLab From 0d61015d2fd2a66e83282dab8c4b9faebbdf6db7 Mon Sep 17 00:00:00 2001 From: Ramon Nou Date: Fri, 9 May 2025 20:45:21 +0200 Subject: [PATCH 3/3] CHANGELOG --- .gitignore | 1 + CHANGELOG.md | 1 + src/client/preload.cpp | 15 ++++++++------- src/client/preload_util.cpp | 9 +++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index a846ad148..8f57cf301 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,4 @@ builds/ # Allow users to provide their own CMake presets CMakeUserPresets.json +gkfs/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 37fe10b50..900ab19aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Export extra user library functions ([!227](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/227)) - Update CLI11 and fmt to avoid cmake errors ([!231])(https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/231)) - Update CLI11 in modules ([!232](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/232)). + - Faster initialization relaying on host_files information instead of server RPC ([!242](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/242)) ### Fixed - Dup3 is supported if O_CLOEXEC is not used (i.e. hexdump) ([!228](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/228)) diff --git a/src/client/preload.cpp b/src/client/preload.cpp index a32e22d52..2950de7a8 100644 --- a/src/client/preload.cpp +++ b/src/client/preload.cpp @@ -329,13 +329,14 @@ init_environment() { } } -// LOG(INFO, "Retrieving file system configuration..."); - - // if(!gkfs::rpc::forward_get_fs_config()) { - // exit_error_msg( - // EXIT_FAILURE, - // "Unable to fetch file system configurations from daemon process through RPC."); - // } + // LOG(INFO, "Retrieving file system configuration..."); + + // if(!gkfs::rpc::forward_get_fs_config()) { + // exit_error_msg( + // EXIT_FAILURE, + // "Unable to fetch file system configurations from daemon + // process through RPC."); + // } // Initialize random number generator and seed for replica selection // in case of failure, a new replica will be selected if(CTX->get_replicas() > 0) { diff --git a/src/client/preload_util.cpp b/src/client/preload_util.cpp index 78718b17d..c518caa1b 100644 --- a/src/client/preload_util.cpp +++ b/src/client/preload_util.cpp @@ -188,11 +188,11 @@ load_hostfile(const std::string& path) { fmt::format("unrecognized line format: '{}'", line)); } - host = match[1]; + host = match[1]; uri = match[2]; // match[3] that is the proxy (not used here) - hosts.emplace_back(host, uri); - + hosts.emplace_back(host, uri); + // info will be repeated line per line: CTX->mountdir(match[4]); LOG(INFO, "Mountdir: '{}'", CTX->mountdir()); @@ -206,9 +206,6 @@ load_hostfile(const std::string& path) { // convert match[11] and match[12] to unsigned integers. CTX->fs_conf()->uid = std::stoi(match[11]); CTX->fs_conf()->gid = std::stoi(match[12]); - - - } if(hosts.empty()) { throw runtime_error( -- GitLab