Loading ifs/include/preload/preload.hpp +0 −2 Original line number Diff line number Diff line Loading @@ -8,8 +8,6 @@ #define CTX PreloadContext::getInstance() bool ld_is_aux_loaded(); void init_ld_env_if_needed(); void init_preload() __attribute__((constructor)); Loading ifs/src/preload/intcp_functions.cpp +35 −37 Original line number Diff line number Diff line Loading @@ -140,13 +140,11 @@ int rmdir(const char* path) __THROW { int close(int fd) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if(CTX->initialized() && CTX->file_map()->exist(fd)) { // No call to the daemon is required CTX->file_map()->remove(fd); return 0; } } return (reinterpret_cast<decltype(&close)>(libc_close))(fd); } Loading Loading @@ -201,7 +199,7 @@ int fstat(int fd, struct stat* buf) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return adafs_stat(path, buf); } Loading Loading @@ -250,7 +248,7 @@ int __fxstat(int ver, int fd, struct stat* buf) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return adafs_stat(path, buf); } Loading @@ -262,7 +260,7 @@ int __fxstat64(int ver, int fd, struct stat64* buf) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return adafs_stat64(path, buf); } Loading Loading @@ -316,7 +314,7 @@ int fstatfs(int fd, struct statfs* buf) { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { auto adafs_fd = CTX->file_map()->get(fd); // get information of the underlying fs // Note, we explicitely call the real glibc statfs function to not intercept it again on the mountdir path Loading @@ -337,8 +335,8 @@ int puts(const char* str) { ssize_t write(int fd, const void* buf, size_t count) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { auto adafs_fd = CTX->file_map()->get(fd); auto pos = adafs_fd->pos(); // retrieve the current offset if (adafs_fd->get_flag(OpenFile_flags::append)) Loading @@ -357,8 +355,8 @@ ssize_t write(int fd, const void* buf, size_t count) { ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { return adafs_pwrite_ws(fd, buf, count, offset); } } Loading @@ -368,8 +366,8 @@ ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) { ssize_t pwrite64(int fd, const void* buf, size_t count, __off64_t offset) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { return adafs_pwrite_ws(fd, buf, count, offset); } } Loading @@ -379,10 +377,10 @@ ssize_t pwrite64(int fd, const void* buf, size_t count, __off64_t offset) { ssize_t read(int fd, void* buf, size_t count) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { auto adafs_fd = CTX->file_map()->get(fd); auto pos = adafs_fd->pos(); //retrieve the current offset CTX->log()->trace("{}() called with fd {}", __func__, fd); auto ret = adafs_pread_ws(fd, buf, count, pos); // Update offset in file descriptor in the file map if (ret > 0) { Loading @@ -397,8 +395,8 @@ ssize_t read(int fd, void* buf, size_t count) { ssize_t pread(int fd, void* buf, size_t count, off_t offset) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { return adafs_pread_ws(fd, buf, count, offset); } } Loading @@ -408,8 +406,8 @@ ssize_t pread(int fd, void* buf, size_t count, off_t offset) { ssize_t pread64(int fd, void* buf, size_t count, __off64_t offset) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { return adafs_pread_ws(fd, buf, count, offset); } } Loading @@ -419,8 +417,8 @@ ssize_t pread64(int fd, void* buf, size_t count, __off64_t offset) { off_t lseek(int fd, off_t offset, int whence) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with path {} with mode {}", __func__, fd, offset, whence); if (CTX->file_map()->exist(fd)) { auto off_ret = adafs_lseek(fd, static_cast<off64_t>(offset), whence); if (off_ret > std::numeric_limits<off_t>::max()) { errno = EOVERFLOW; Loading @@ -437,8 +435,8 @@ off_t lseek(int fd, off_t offset, int whence) __THROW { off64_t lseek64(int fd, off64_t offset, int whence) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with path {} with mode {}", __func__, fd, offset, whence); if (CTX->file_map()->exist(fd)) { return adafs_lseek(fd, offset, whence); } } Loading @@ -448,8 +446,8 @@ off64_t lseek64(int fd, off64_t offset, int whence) __THROW { int fsync(int fd) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {} path {}", __func__, fd, CTX->file_map()->get(fd)->path()); if (CTX->file_map()->exist(fd)) { return 0; // This is a noop for us atm. fsync is called implicitly because each chunk is closed after access } } Loading @@ -459,8 +457,8 @@ int fsync(int fd) { int fdatasync(int fd) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {} path {}", __func__, fd, CTX->file_map()->get(fd)->path()); if (CTX->file_map()->exist(fd)) { return 0; // This is a noop for us atm. fsync is called implicitly because each chunk is closed after access } } Loading @@ -480,8 +478,8 @@ int ftruncate(int fd, off_t length) __THROW { int dup(int oldfd) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(oldfd)) { CTX->log()->trace("{}() called with oldfd {}", __func__, oldfd); if (CTX->file_map()->exist(oldfd)) { return adafs_dup(oldfd); } } Loading @@ -491,8 +489,8 @@ int dup(int oldfd) __THROW { int dup2(int oldfd, int newfd) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(oldfd)) { CTX->log()->trace("{}() called with oldfd {} newfd {}", __func__, oldfd, newfd); if (CTX->file_map()->exist(oldfd)) { return adafs_dup2(oldfd, newfd); } } Loading @@ -502,7 +500,7 @@ int dup2(int oldfd, int newfd) __THROW { int dup3(int oldfd, int newfd, int flags) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(oldfd)) { if (CTX->file_map()->exist(oldfd)) { // TODO implement O_CLOEXEC flag first which is used with fcntl(2) // It is in glibc since kernel 2.9. So maybe not that important :) CTX->log()->error("{}() Not implemented.", __func__); Loading Loading @@ -549,7 +547,7 @@ struct dirent* intcp_readdir(DIR* dirp){ return nullptr; } auto fd = dirp_to_fd(dirp); if(ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if(CTX->file_map()->exist(fd)) { return adafs_readdir(fd); } } Loading @@ -564,7 +562,7 @@ int intcp_closedir(DIR* dirp) { return -1; } auto fd = dirp_to_fd(dirp); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { // No call to the daemon is required CTX->file_map()->remove(fd); return 0; Loading ifs/src/preload/preload.cpp +0 −11 Original line number Diff line number Diff line Loading @@ -12,8 +12,6 @@ enum class Margo_mode { RPC, IPC }; // atomic bool to check if auxiliary files from daemon are loaded std::atomic<bool> is_aux_loaded_(false); // thread to initialize the whole margo shazaam only once per process static pthread_once_t init_env_thread = PTHREAD_ONCE_INIT; Loading Loading @@ -212,14 +210,6 @@ bool init_margo_client(Margo_mode mode, const string na_plugin) { return true; } /** * Returns atomic bool, if Margo is running * @return */ bool ld_is_aux_loaded() { return is_aux_loaded_; } /** * This function is only called in the preload constructor and initializes Argobots and Margo clients */ Loading Loading @@ -289,7 +279,6 @@ void init_preload() { exit(EXIT_FAILURE); } else { CTX->log()->info("{}() mountdir \"{}\" loaded", __func__, CTX->mountdir()); is_aux_loaded_ = true; } CTX->initialized(true); CTX->log()->debug("{}() exit", __func__); Loading Loading
ifs/include/preload/preload.hpp +0 −2 Original line number Diff line number Diff line Loading @@ -8,8 +8,6 @@ #define CTX PreloadContext::getInstance() bool ld_is_aux_loaded(); void init_ld_env_if_needed(); void init_preload() __attribute__((constructor)); Loading
ifs/src/preload/intcp_functions.cpp +35 −37 Original line number Diff line number Diff line Loading @@ -140,13 +140,11 @@ int rmdir(const char* path) __THROW { int close(int fd) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if(CTX->initialized() && CTX->file_map()->exist(fd)) { // No call to the daemon is required CTX->file_map()->remove(fd); return 0; } } return (reinterpret_cast<decltype(&close)>(libc_close))(fd); } Loading Loading @@ -201,7 +199,7 @@ int fstat(int fd, struct stat* buf) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return adafs_stat(path, buf); } Loading Loading @@ -250,7 +248,7 @@ int __fxstat(int ver, int fd, struct stat* buf) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return adafs_stat(path, buf); } Loading @@ -262,7 +260,7 @@ int __fxstat64(int ver, int fd, struct stat64* buf) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return adafs_stat64(path, buf); } Loading Loading @@ -316,7 +314,7 @@ int fstatfs(int fd, struct statfs* buf) { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { auto adafs_fd = CTX->file_map()->get(fd); // get information of the underlying fs // Note, we explicitely call the real glibc statfs function to not intercept it again on the mountdir path Loading @@ -337,8 +335,8 @@ int puts(const char* str) { ssize_t write(int fd, const void* buf, size_t count) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { auto adafs_fd = CTX->file_map()->get(fd); auto pos = adafs_fd->pos(); // retrieve the current offset if (adafs_fd->get_flag(OpenFile_flags::append)) Loading @@ -357,8 +355,8 @@ ssize_t write(int fd, const void* buf, size_t count) { ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { return adafs_pwrite_ws(fd, buf, count, offset); } } Loading @@ -368,8 +366,8 @@ ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) { ssize_t pwrite64(int fd, const void* buf, size_t count, __off64_t offset) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { return adafs_pwrite_ws(fd, buf, count, offset); } } Loading @@ -379,10 +377,10 @@ ssize_t pwrite64(int fd, const void* buf, size_t count, __off64_t offset) { ssize_t read(int fd, void* buf, size_t count) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { auto adafs_fd = CTX->file_map()->get(fd); auto pos = adafs_fd->pos(); //retrieve the current offset CTX->log()->trace("{}() called with fd {}", __func__, fd); auto ret = adafs_pread_ws(fd, buf, count, pos); // Update offset in file descriptor in the file map if (ret > 0) { Loading @@ -397,8 +395,8 @@ ssize_t read(int fd, void* buf, size_t count) { ssize_t pread(int fd, void* buf, size_t count, off_t offset) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { return adafs_pread_ws(fd, buf, count, offset); } } Loading @@ -408,8 +406,8 @@ ssize_t pread(int fd, void* buf, size_t count, off_t offset) { ssize_t pread64(int fd, void* buf, size_t count, __off64_t offset) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { return adafs_pread_ws(fd, buf, count, offset); } } Loading @@ -419,8 +417,8 @@ ssize_t pread64(int fd, void* buf, size_t count, __off64_t offset) { off_t lseek(int fd, off_t offset, int whence) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with path {} with mode {}", __func__, fd, offset, whence); if (CTX->file_map()->exist(fd)) { auto off_ret = adafs_lseek(fd, static_cast<off64_t>(offset), whence); if (off_ret > std::numeric_limits<off_t>::max()) { errno = EOVERFLOW; Loading @@ -437,8 +435,8 @@ off_t lseek(int fd, off_t offset, int whence) __THROW { off64_t lseek64(int fd, off64_t offset, int whence) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with path {} with mode {}", __func__, fd, offset, whence); if (CTX->file_map()->exist(fd)) { return adafs_lseek(fd, offset, whence); } } Loading @@ -448,8 +446,8 @@ off64_t lseek64(int fd, off64_t offset, int whence) __THROW { int fsync(int fd) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {} path {}", __func__, fd, CTX->file_map()->get(fd)->path()); if (CTX->file_map()->exist(fd)) { return 0; // This is a noop for us atm. fsync is called implicitly because each chunk is closed after access } } Loading @@ -459,8 +457,8 @@ int fsync(int fd) { int fdatasync(int fd) { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called with fd {} path {}", __func__, fd, CTX->file_map()->get(fd)->path()); if (CTX->file_map()->exist(fd)) { return 0; // This is a noop for us atm. fsync is called implicitly because each chunk is closed after access } } Loading @@ -480,8 +478,8 @@ int ftruncate(int fd, off_t length) __THROW { int dup(int oldfd) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(oldfd)) { CTX->log()->trace("{}() called with oldfd {}", __func__, oldfd); if (CTX->file_map()->exist(oldfd)) { return adafs_dup(oldfd); } } Loading @@ -491,8 +489,8 @@ int dup(int oldfd) __THROW { int dup2(int oldfd, int newfd) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(oldfd)) { CTX->log()->trace("{}() called with oldfd {} newfd {}", __func__, oldfd, newfd); if (CTX->file_map()->exist(oldfd)) { return adafs_dup2(oldfd, newfd); } } Loading @@ -502,7 +500,7 @@ int dup2(int oldfd, int newfd) __THROW { int dup3(int oldfd, int newfd, int flags) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { if (ld_is_aux_loaded() && CTX->file_map()->exist(oldfd)) { if (CTX->file_map()->exist(oldfd)) { // TODO implement O_CLOEXEC flag first which is used with fcntl(2) // It is in glibc since kernel 2.9. So maybe not that important :) CTX->log()->error("{}() Not implemented.", __func__); Loading Loading @@ -549,7 +547,7 @@ struct dirent* intcp_readdir(DIR* dirp){ return nullptr; } auto fd = dirp_to_fd(dirp); if(ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if(CTX->file_map()->exist(fd)) { return adafs_readdir(fd); } } Loading @@ -564,7 +562,7 @@ int intcp_closedir(DIR* dirp) { return -1; } auto fd = dirp_to_fd(dirp); if (ld_is_aux_loaded() && CTX->file_map()->exist(fd)) { if (CTX->file_map()->exist(fd)) { // No call to the daemon is required CTX->file_map()->remove(fd); return 0; Loading
ifs/src/preload/preload.cpp +0 −11 Original line number Diff line number Diff line Loading @@ -12,8 +12,6 @@ enum class Margo_mode { RPC, IPC }; // atomic bool to check if auxiliary files from daemon are loaded std::atomic<bool> is_aux_loaded_(false); // thread to initialize the whole margo shazaam only once per process static pthread_once_t init_env_thread = PTHREAD_ONCE_INIT; Loading Loading @@ -212,14 +210,6 @@ bool init_margo_client(Margo_mode mode, const string na_plugin) { return true; } /** * Returns atomic bool, if Margo is running * @return */ bool ld_is_aux_loaded() { return is_aux_loaded_; } /** * This function is only called in the preload constructor and initializes Argobots and Margo clients */ Loading Loading @@ -289,7 +279,6 @@ void init_preload() { exit(EXIT_FAILURE); } else { CTX->log()->info("{}() mountdir \"{}\" loaded", __func__, CTX->mountdir()); is_aux_loaded_ = true; } CTX->initialized(true); CTX->log()->debug("{}() exit", __func__); Loading