Verified Commit 332081b6 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

Move fs_config into preload context

parent 1a7b77b6
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
#ifndef IFS_ADAFS_FUNCTIONS_HPP
#define IFS_ADAFS_FUNCTIONS_HPP

#include <preload/preload_util.hpp>
#include <preload/open_file_map.hpp>

/*
+28 −0
Original line number Diff line number Diff line
@@ -9,12 +9,39 @@
class OpenFileMap;


struct FsConfig {
    // configurable metadata
    bool atime_state;
    bool mtime_state;
    bool ctime_state;
    bool uid_state;
    bool gid_state;
    bool inode_no_state;
    bool link_cnt_state;
    bool blocks_state;

    uid_t uid;
    gid_t gid;

    std::string rootdir;

    // rpc infos
    std::map<uint64_t, std::string> hosts;
    std::map<std::string, std::string> sys_hostfile;
    uint64_t host_id; // my host number
    size_t host_size;
    std::string rpc_port;
};


class PreloadContext {
    private:
    PreloadContext();

    std::shared_ptr<spdlog::logger> log_;
    std::shared_ptr<OpenFileMap> ofm_;
    std::shared_ptr<FsConfig> fs_conf_;

    std::string mountdir_;

    public:
@@ -35,6 +62,7 @@ class PreloadContext {
    bool relativize_path(std::string& path) const;

    const std::shared_ptr<OpenFileMap>& file_map() const;
    const std::shared_ptr<FsConfig>& fs_conf() const;
};


+0 −27
Original line number Diff line number Diff line
@@ -11,31 +11,6 @@ extern "C" {
#include <margo.h>
}

// TODO singleton this stuff away
// The contents of FsConfig or only set once when set up
struct FsConfig {
    // configurable metadata
    bool atime_state;
    bool mtime_state;
    bool ctime_state;
    bool uid_state;
    bool gid_state;
    bool inode_no_state;
    bool link_cnt_state;
    bool blocks_state;

    uid_t uid;
    gid_t gid;

    std::string rootdir;

    // rpc infos
    std::map<uint64_t, std::string> hosts;
    std::map<std::string, std::string> sys_hostfile;
    uint64_t host_id; // my host number
    size_t host_size;
    std::string rpc_port;
};
// Used to bundle metadata into one place
struct Metadentry {
    time_t atime;
@@ -95,8 +70,6 @@ extern hg_id_t rpc_update_metadentry_size_id;
extern hg_id_t rpc_write_data_id;
extern hg_id_t rpc_read_data_id;
extern hg_id_t rpc_get_dirents_id;
// fs_config is set ONCE in the beginning. It shall not be modified afterwards
extern std::shared_ptr<struct FsConfig> fs_config;
// rpc addresses. Populated when environment is initialized. After that it is read-only accessed
extern std::map<uint64_t, hg_addr_t> rpc_addresses;
// file descriptor index validation flag
+6 −6
Original line number Diff line number Diff line
@@ -115,11 +115,11 @@ int adafs_statfs(const string& path, struct statfs* adafs_buf, struct statfs& re
    adafs_buf->f_type = 0; // fs is not know to VFS. Therefore, no valid specifier possible
    adafs_buf->f_bsize = static_cast<int>(CHUNKSIZE);
    // some rough estimations
    adafs_buf->f_blocks = realfs_buf.f_blocks * fs_config->host_size;
    adafs_buf->f_bfree = realfs_buf.f_bfree * fs_config->host_size;
    adafs_buf->f_bavail = realfs_buf.f_bavail * fs_config->host_size;
    adafs_buf->f_files = realfs_buf.f_files * fs_config->host_size;
    adafs_buf->f_ffree = realfs_buf.f_ffree * fs_config->host_size;
    adafs_buf->f_blocks = realfs_buf.f_blocks * CTX->fs_conf()->host_size;
    adafs_buf->f_bfree = realfs_buf.f_bfree * CTX->fs_conf()->host_size;
    adafs_buf->f_bavail = realfs_buf.f_bavail * CTX->fs_conf()->host_size;
    adafs_buf->f_files = realfs_buf.f_files * CTX->fs_conf()->host_size;
    adafs_buf->f_ffree = realfs_buf.f_ffree * CTX->fs_conf()->host_size;
    adafs_buf->f_fsid = realfs_buf.f_fsid; // "Nobody knows what f_fsid is supposed to contain"
    adafs_buf->f_namelen = realfs_buf.f_namelen;
    adafs_buf->f_frsize = realfs_buf.f_frsize;
@@ -128,7 +128,7 @@ int adafs_statfs(const string& path, struct statfs* adafs_buf, struct statfs& re
    adafs_buf->f_spare[2] = 0;
    adafs_buf->f_spare[3] = 0;
    adafs_buf->f_flags = ST_NOATIME | ST_NOSUID | ST_NODEV | ST_SYNCHRONOUS;
    if (!fs_config->atime_state)
    if (!CTX->fs_conf()->atime_state)
        adafs_buf->f_flags = adafs_buf->f_flags | ST_NOATIME | ST_NODIRATIME;
    return 0;
}
+16 −16
Original line number Diff line number Diff line
@@ -69,24 +69,24 @@ bool ipc_send_get_fs_config() {
        if (ret == HG_SUCCESS) {
            if (!CTX->mountdir().empty() && CTX->mountdir() != out.mountdir) {
                CTX->log()->warn(
                        "{}() fs_config mountdir {} and received out.mountdir {} mismatch detected! Using received mountdir",
                        "{}() fs_conf mountdir {} and received out.mountdir {} mismatch detected! Using received mountdir",
                        __func__, CTX->mountdir(), out.mountdir);
                CTX->mountdir(out.mountdir);
            }
            fs_config->rootdir = out.rootdir;
            fs_config->atime_state = out.atime_state;
            fs_config->mtime_state = out.mtime_state;
            fs_config->ctime_state = out.ctime_state;
            fs_config->uid_state = out.uid_state;
            fs_config->gid_state = out.gid_state;
            fs_config->inode_no_state = out.inode_no_state;
            fs_config->link_cnt_state = out.link_cnt_state;
            fs_config->blocks_state = out.blocks_state;
            fs_config->uid = out.uid;
            fs_config->gid = out.gid;
            fs_config->host_id = out.host_id;
            fs_config->host_size = out.host_size;
            fs_config->rpc_port = to_string(RPC_PORT);
            CTX->fs_conf()->rootdir = out.rootdir;
            CTX->fs_conf()->atime_state = out.atime_state;
            CTX->fs_conf()->mtime_state = out.mtime_state;
            CTX->fs_conf()->ctime_state = out.ctime_state;
            CTX->fs_conf()->uid_state = out.uid_state;
            CTX->fs_conf()->gid_state = out.gid_state;
            CTX->fs_conf()->inode_no_state = out.inode_no_state;
            CTX->fs_conf()->link_cnt_state = out.link_cnt_state;
            CTX->fs_conf()->blocks_state = out.blocks_state;
            CTX->fs_conf()->uid = out.uid;
            CTX->fs_conf()->gid = out.gid;
            CTX->fs_conf()->host_id = out.host_id;
            CTX->fs_conf()->host_size = out.host_size;
            CTX->fs_conf()->rpc_port = to_string(RPC_PORT);

            // split comma separated host string and create a hosts map
            string hosts_raw = out.hosts_raw;
@@ -97,7 +97,7 @@ bool ipc_send_get_fs_config() {
            for (auto&& s : tok) {
                hostmap[i++] = s;
            }
            fs_config->hosts = hostmap;
            CTX->fs_conf()->hosts = hostmap;
            CTX->log()->debug("{}() Got response with mountdir {}", __func__, out.mountdir);
        } else {
            CTX->log()->error("{}() Retrieving fs configurations from daemon", __func__);
Loading