Loading include/client/open_file_map.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,9 @@ public: bool empty() const; std::vector<int> get_range(unsigned int first, unsigned int last); }; } // namespace gkfs::filemap Loading include/client/preload_context.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ #include <vector> #include <string> #include <mutex> #include <unordered_set> #include <config.hpp> #include <bitset> Loading Loading @@ -134,6 +135,7 @@ private: std::bitset<GKFS_MAX_INTERNAL_FDS> internal_fds_; mutable std::mutex internal_fds_mutex_; std::unordered_set<int> internal_fd_table_; bool internal_fds_must_relocate_; std::bitset<MAX_USER_FDS> protected_fds_; std::string hostname; Loading src/client/hooks.cpp +0 −9 Original line number Diff line number Diff line Loading @@ -1540,15 +1540,6 @@ hook_mmap(void* addr, size_t length, int prot, int flags, int fd, } if(auto file = CTX->file_map()->get(fd)) { // In non-range-fd mode, GekkoFS keeps a /dev/null kernel fd per tracked // file. If that no longer holds, this entry is stale (likely fd reuse), // so forward to the kernel. if(!CTX->range_fd() && !CTX->protect_fds() && !kernel_fd_targets_dev_null(fd)) { return reinterpret_cast<void*>(syscall_no_intercept_wrapper( SYS_mmap, addr, length, prot, flags, fd, offset)); } return gkfs::syscall::gkfs_mmap(addr, length, prot, flags, fd, offset); } return reinterpret_cast<void*>(syscall_no_intercept_wrapper( Loading src/client/intercept.cpp +17 −8 Original line number Diff line number Diff line Loading @@ -589,19 +589,25 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, break; #ifdef SYS_close_range case SYS_close_range: { auto first = static_cast<unsigned int>(arg0); auto last = static_cast<unsigned int>(arg1); auto flags = static_cast<unsigned int>(arg2); // Do not forward close_range() directly to the kernel here. // Launcher processes such as ssh/Hydra may call it while the // preloaded client runtime is still active. Forwarding the range // closes native runtime descriptors (Mercury/Margo sockets, event // fds, etc.) and breaks the client before exec or shutdown. auto fds = get_open_fds(); for(auto fd : fds) { if(fd < first || fd > last) if(fd < static_cast<int>(arg0) || fd > static_cast<int>(arg1)) { continue; } if(CTX->is_internal_fd(fd)) { continue; } if(CTX->file_map()->exist(fd)) { gkfs::syscall::gkfs_close(fd); } else } else { close(fd); } } *result = 0; break; } Loading Loading @@ -1242,8 +1248,11 @@ hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, pthread_once(&key_once_control, make_key); // Ensure the key is created if(pthread_getspecific(reentrance_guard_key) != NULL) { // If the guard is set, forward the syscall to the kernel and return. return gkfs::syscall::forward_to_kernel; // While handling an application syscall, nested syscalls originate // from the GekkoFS runtime itself. Route them through hook_internal() // so native runtime descriptors remain tracked and protected. return hook_internal(syscall_number, arg0, arg1, arg2, arg3, arg4, arg5, syscall_return_value); } // Set the guard to a non-NULL value. pthread_setspecific( Loading src/client/open_file_map.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -347,4 +347,20 @@ OpenFileMap::empty() const { return total_files_ == 0; } std::vector<int> OpenFileMap::get_range(unsigned int first, unsigned int last) { std::vector<int> result; for(auto& shard : shards_) { lock_guard<recursive_mutex> lock(shard.mutex); auto it = shard.files.lower_bound(static_cast<int>(first)); while(it != shard.files.end() && static_cast<unsigned int>(it->first) <= last) { result.push_back(it->first); ++it; } } std::sort(result.begin(), result.end()); return result; } } // namespace gkfs::filemap No newline at end of file Loading
include/client/open_file_map.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,9 @@ public: bool empty() const; std::vector<int> get_range(unsigned int first, unsigned int last); }; } // namespace gkfs::filemap Loading
include/client/preload_context.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ #include <vector> #include <string> #include <mutex> #include <unordered_set> #include <config.hpp> #include <bitset> Loading Loading @@ -134,6 +135,7 @@ private: std::bitset<GKFS_MAX_INTERNAL_FDS> internal_fds_; mutable std::mutex internal_fds_mutex_; std::unordered_set<int> internal_fd_table_; bool internal_fds_must_relocate_; std::bitset<MAX_USER_FDS> protected_fds_; std::string hostname; Loading
src/client/hooks.cpp +0 −9 Original line number Diff line number Diff line Loading @@ -1540,15 +1540,6 @@ hook_mmap(void* addr, size_t length, int prot, int flags, int fd, } if(auto file = CTX->file_map()->get(fd)) { // In non-range-fd mode, GekkoFS keeps a /dev/null kernel fd per tracked // file. If that no longer holds, this entry is stale (likely fd reuse), // so forward to the kernel. if(!CTX->range_fd() && !CTX->protect_fds() && !kernel_fd_targets_dev_null(fd)) { return reinterpret_cast<void*>(syscall_no_intercept_wrapper( SYS_mmap, addr, length, prot, flags, fd, offset)); } return gkfs::syscall::gkfs_mmap(addr, length, prot, flags, fd, offset); } return reinterpret_cast<void*>(syscall_no_intercept_wrapper( Loading
src/client/intercept.cpp +17 −8 Original line number Diff line number Diff line Loading @@ -589,19 +589,25 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, break; #ifdef SYS_close_range case SYS_close_range: { auto first = static_cast<unsigned int>(arg0); auto last = static_cast<unsigned int>(arg1); auto flags = static_cast<unsigned int>(arg2); // Do not forward close_range() directly to the kernel here. // Launcher processes such as ssh/Hydra may call it while the // preloaded client runtime is still active. Forwarding the range // closes native runtime descriptors (Mercury/Margo sockets, event // fds, etc.) and breaks the client before exec or shutdown. auto fds = get_open_fds(); for(auto fd : fds) { if(fd < first || fd > last) if(fd < static_cast<int>(arg0) || fd > static_cast<int>(arg1)) { continue; } if(CTX->is_internal_fd(fd)) { continue; } if(CTX->file_map()->exist(fd)) { gkfs::syscall::gkfs_close(fd); } else } else { close(fd); } } *result = 0; break; } Loading Loading @@ -1242,8 +1248,11 @@ hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, pthread_once(&key_once_control, make_key); // Ensure the key is created if(pthread_getspecific(reentrance_guard_key) != NULL) { // If the guard is set, forward the syscall to the kernel and return. return gkfs::syscall::forward_to_kernel; // While handling an application syscall, nested syscalls originate // from the GekkoFS runtime itself. Route them through hook_internal() // so native runtime descriptors remain tracked and protected. return hook_internal(syscall_number, arg0, arg1, arg2, arg3, arg4, arg5, syscall_return_value); } // Set the guard to a non-NULL value. pthread_setspecific( Loading
src/client/open_file_map.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -347,4 +347,20 @@ OpenFileMap::empty() const { return total_files_ == 0; } std::vector<int> OpenFileMap::get_range(unsigned int first, unsigned int last) { std::vector<int> result; for(auto& shard : shards_) { lock_guard<recursive_mutex> lock(shard.mutex); auto it = shard.files.lower_bound(static_cast<int>(first)); while(it != shard.files.end() && static_cast<unsigned int>(it->first) <= last) { result.push_back(it->first); ++it; } } std::sort(result.begin(), result.end()); return result; } } // namespace gkfs::filemap No newline at end of file