Verified Commit f04501aa authored by Marc Vef's avatar Marc Vef
Browse files

Restructuring code w.r.t. configurations and definitions

- #defines have been mostly removed from configurations
- a dedicated config file has been added for configurations with constexpr
- past configure file is now only a cmake wrapper
- wrapping global functions into namespaces
parent 6eef8fc1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ add_definitions(-DLIBGKFS_LOG_MESSAGE_SIZE=${CLIENT_LOG_MESSAGE_SIZE})
message(STATUS "[gekkofs] Maximum log message size in the client library: ${CLIENT_LOG_MESSAGE_SIZE}")
mark_as_advanced(CLIENT_LOG_MESSAGE_SIZE)

configure_file(include/global/configure.hpp.in include/global/configure.hpp)
configure_file(include/global/cmake_configure.hpp.in include/global/cmake_configure.hpp)

# Imported target
add_library(RocksDB INTERFACE IMPORTED GLOBAL)
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
#ifndef GKFS_CLIENT_ENV
#define GKFS_CLIENT_ENV

#include <global/configure.hpp>
#include <config.hpp>

#define ADD_PREFIX(str) CLIENT_ENV_PREFIX str

+13 −7
Original line number Diff line number Diff line
@@ -17,10 +17,11 @@

#include <client/preload.hpp>
#include <global/metadata.hpp>
// third party libs

#include <string>
#include <iostream>
#include <map>
#include <type_traits>

struct MetadentryUpdateFlags {
    bool atime = false;
@@ -60,14 +61,19 @@ extern hg_id_t rpc_mk_symlink_id;
#endif

// function definitions
namespace gkfs {
    namespace client {
        template<typename E>
        constexpr typename std::underlying_type<E>::type to_underlying(E e) {
            return static_cast<typename std::underlying_type<E>::type>(e);
        }

        int metadata_to_stat(const std::string& path, const Metadata& md, struct stat& attr);

std::vector<std::pair<std::string, std::string>> load_hosts_file(const std::string& lfpath);

hg_addr_t get_local_addr();
        std::vector<std::pair<std::string, std::string>> load_hostfile(const std::string& lfpath);

        void load_hosts();
bool lookup_all_hosts();
    }
}

#endif //IFS_PRELOAD_UTIL_HPP
+14 −14
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ struct fs_config {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::fs_config;
    constexpr static const auto name = gkfs::hg_tag::fs_config;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -256,7 +256,7 @@ struct create {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::create;
    constexpr static const auto name = gkfs::hg_tag::create;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -367,7 +367,7 @@ struct stat {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::stat;
    constexpr static const auto name = gkfs::hg_tag::stat;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -481,7 +481,7 @@ struct remove {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::remove;
    constexpr static const auto name = gkfs::hg_tag::remove;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -583,7 +583,7 @@ struct decr_size {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::decr_size;
    constexpr static const auto name = gkfs::hg_tag::decr_size;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -693,7 +693,7 @@ struct update_metadentry {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::update_metadentry;
    constexpr static const auto name = gkfs::hg_tag::update_metadentry;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -955,7 +955,7 @@ struct get_metadentry_size {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::get_metadentry_size;
    constexpr static const auto name = gkfs::hg_tag::get_metadentry_size;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -1066,7 +1066,7 @@ struct update_metadentry_size {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::update_metadentry_size;
    constexpr static const auto name = gkfs::hg_tag::update_metadentry_size;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -1206,7 +1206,7 @@ struct mk_symlink {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::mk_symlink;
    constexpr static const auto name = gkfs::hg_tag::mk_symlink;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -1319,7 +1319,7 @@ struct write_data {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::write_data;
    constexpr static const auto name = gkfs::hg_tag::write_data;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -1512,7 +1512,7 @@ struct read_data {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::read_data;
    constexpr static const auto name = gkfs::hg_tag::read_data;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -1705,7 +1705,7 @@ struct trunc_data {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::trunc_data;
    constexpr static const auto name = gkfs::hg_tag::trunc_data;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -1819,7 +1819,7 @@ struct get_dirents {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::get_dirents;
    constexpr static const auto name = gkfs::hg_tag::get_dirents;

    // requires response?
    constexpr static const auto requires_response = true;
@@ -1942,7 +1942,7 @@ struct chunk_stat {
    constexpr static const hg_id_t mercury_id = public_id;

    // RPC name
    constexpr static const auto name = hg_tag::chunk_stat;
    constexpr static const auto name = gkfs::hg_tag::chunk_stat;

    // requires response?
    constexpr static const auto requires_response = true;

include/config.hpp

0 → 100644
+73 −0
Original line number Diff line number Diff line
/*
  Copyright 2018-2019, Barcelona Supercomputing Center (BSC), Spain
  Copyright 2015-2019, Johannes Gutenberg Universitaet Mainz, Germany

  This software was partially supported by the
  EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).

  This software was partially supported by the
  ADA-FS project under the SPPEXA project funded by the DFG.

  SPDX-License-Identifier: MIT
*/

#ifndef GEKKOFS_CONFIG_HPP
#define GEKKOFS_CONFIG_HPP

#include <global/cmake_configure.hpp>

// environment prefixes (are concatenated in env module at compile time)
#define CLIENT_ENV_PREFIX "LIBGKFS_"
#define DAEMON_ENV_PREFIX "GKFS_"

namespace gkfs_config {

    constexpr auto daemon_pid_path = "/tmp/gkfs_daemon"; // XXX TMP
    constexpr auto hostfile_path = "./gkfs_hosts.txt";

    namespace io {
        /*
         * Zero buffer before read. This is relevant if sparse files are used.
         * If buffer is not zeroed, sparse regions contain invalid data.
         */
        constexpr auto zero_buffer_before_read = false;
    }

    namespace logging {
        constexpr auto client_log_path = "/tmp/gkfs_client.log";
        constexpr auto daemon_log_path = "/tmp/gkfs_daemon.log";

        constexpr auto client_log_level = "info,errors,critical,mercury";
        constexpr auto daemon_log_level = 4; //info
    }

    namespace metadata {

        // which metadata should be considered apart from size and mode
        constexpr auto use_atime = false;
        constexpr auto use_ctime = false;
        constexpr auto use_mtime = false;
        constexpr auto use_link_cnt = false;
        constexpr auto use_blocks = false;
    }

    namespace rpc {
        constexpr auto chunksize = 524288; // in bytes (e.g., 524288 == 512KB)
        //size of preallocated buffer to hold directory entries in rpc call
        constexpr auto dirents_buff_size = (8 * 1024 * 1024); // 8 mega
        /*
         * Indicates the number of concurrent progress to drive I/O operations of chunk files to and from local file systems
         * The value is directly mapped to created Argobots xstreams, controlled in a single pool with ABT_snoozer scheduler
         */
        constexpr auto daemon_io_xstreams = 8;
        // Number of threads used for RPC handlers at the daemon
        constexpr auto daemon_handler_xstreams = 8;
    }

    namespace rocksdb {
        // Write-ahead logging of rocksdb
        constexpr auto use_write_ahead_log = false;
    }
}

#endif //GEKKOFS_CONFIG_HPP
Loading