Verified Commit 2657e84d authored by Marc Vef's avatar Marc Vef
Browse files

Added limbo mode for IO, writing to /dev/null, reading from /dev/zero

parent 28893870
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@

namespace gkfs::config {

// writes to dev null instead of chunk space, read is reading /dev/zero
constexpr bool limbo_mode = false;

constexpr auto hostfile_path = "./gkfs_hosts.txt";
constexpr auto forwarding_file_path = "./gkfs_forwarding.map";

+15 −5
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@

#include <filesystem>
#include <spdlog/spdlog.h>
#include <config.hpp>

extern "C" {
#include <sys/statfs.h>
@@ -155,10 +156,14 @@ ChunkStorage::write_chunk(const string& file_path,
                          size_t size, off64_t offset) const {

    assert((offset + size) <= chunksize_);
    string chunk_path{};
    if(gkfs::config::limbo_mode) {
        chunk_path = "/dev/null"s;
    } else {
        // may throw ChunkStorageException on failure
        init_chunk_space(file_path);

    auto chunk_path = absolute(get_chunk_path(file_path, chunk_id));
        chunk_path = absolute(get_chunk_path(file_path, chunk_id));
    }

    FileHandle fh(open(chunk_path.c_str(), O_WRONLY | O_CREAT, 0640),
                  chunk_path);
@@ -212,7 +217,12 @@ ssize_t
ChunkStorage::read_chunk(const string& file_path, gkfs::rpc::chnk_id_t chunk_id,
                         char* buf, size_t size, off64_t offset) const {
    assert((offset + size) <= chunksize_);
    auto chunk_path = absolute(get_chunk_path(file_path, chunk_id));
    string chunk_path{};
    if(gkfs::config::limbo_mode) {
        chunk_path = "/dev/zero"s;
    } else {
        chunk_path = absolute(get_chunk_path(file_path, chunk_id));
    }

    FileHandle fh(open(chunk_path.c_str(), O_RDONLY), chunk_path);
    if(!fh.valid()) {
+2 −1
Original line number Diff line number Diff line
@@ -227,6 +227,7 @@ rpc_srv_remove_data(hg_handle_t handle) {

    // Remove all chunks for that file
    try {
        if(!gkfs::config::limbo_mode)
            GKFS_DATA->storage()->destroy_chunk_space(in.path);
        out.err = 0;
    } catch(const gkfs::data::ChunkStorageException& e) {