Unverified Commit 9b82b532 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

preload: move mountdir into context sigleton

parent 52269a81
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ class PreloadContext {

    void log(std::shared_ptr<spdlog::logger> logger);
    std::shared_ptr<spdlog::logger> log() const;

    void mountdir(const std::string& path);
    std::string mountdir() const;
};


+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ struct FsConfig {
    uid_t uid;
    gid_t gid;

    std::string mountdir;
    std::string rootdir;

    // rpc infos
+2 −2
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ int statfs(const char* path, struct statfs* buf) __THROW {
        // get information of the underlying fs.
        // Note, we explicitely call the real glibc statfs function to not intercept it again on the mountdir path
        struct statfs realfs{};
        auto ret = (reinterpret_cast<decltype(&statfs)>(libc_statfs))(fs_config->mountdir.c_str(), &realfs);
        auto ret = (reinterpret_cast<decltype(&statfs)>(libc_statfs))(CTX->mountdir().c_str(), &realfs);
        if (ret != 0)
            return ret;
        return adafs_statfs(path, buf, realfs);
@@ -260,7 +260,7 @@ int fstatfs(int fd, struct statfs* buf) {
        // get information of the underlying fs
        // Note, we explicitely call the real glibc statfs function to not intercept it again on the mountdir path
        struct statfs realfs{};
        auto ret = (reinterpret_cast<decltype(&statfs)>(libc_statfs))(fs_config->mountdir.c_str(), &realfs);
        auto ret = (reinterpret_cast<decltype(&statfs)>(libc_statfs))(CTX->mountdir().c_str(), &realfs);
        if (ret != 0)
            return ret;
        return adafs_statfs(adafs_fd->path(), buf, realfs);
+3 −3
Original line number Diff line number Diff line
@@ -63,11 +63,11 @@ bool ipc_send_get_fs_config() {
        CTX->log()->debug("{}() Waiting for response", __func__);
        ret = margo_get_output(handle, &out);
        if (ret == HG_SUCCESS) {
            if (!fs_config->mountdir.empty() && fs_config->mountdir != out.mountdir) {
            if (!CTX->mountdir().empty() && CTX->mountdir() != out.mountdir) {
                CTX->log()->warn(
                        "{}() fs_config mountdir {} and received out.mountdir {} mismatch detected! Using received mountdir",
                        __func__, fs_config->mountdir, out.mountdir);
                fs_config->mountdir = out.mountdir;
                        __func__, CTX->mountdir(), out.mountdir);
                CTX->mountdir(out.mountdir);
            }
            fs_config->rootdir = out.rootdir;
            fs_config->atime_state = out.atime_state;
+2 −2
Original line number Diff line number Diff line
@@ -255,12 +255,12 @@ void init_preload() {
    init_passthrough_if_needed();
    // The logger is initialized in init_passthrough. So we cannot log before that.
    CTX->log()->info("{}() enter", __func__);
    if (get_daemon_pid() == -1 || fs_config->mountdir.empty()) {
    if (get_daemon_pid() == -1 || CTX->mountdir().empty()) {
        cerr << "ADA-FS daemon not running or mountdir could not be loaded. Check adafs_preload.log" << endl;
        CTX->log()->error("{}() Daemon not running or mountdir not set", __func__);
        exit(EXIT_FAILURE);
    } else {
        CTX->log()->info("{}() mountdir \"{}\" loaded", __func__, fs_config->mountdir);
        CTX->log()->info("{}() mountdir \"{}\" loaded", __func__, CTX->mountdir());
        is_aux_loaded_ = true;
    }
    CTX->log()->debug("{}() exit", __func__);
Loading