Commit 8b523c1e authored by Marc Vef's avatar Marc Vef
Browse files

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

parent 241e0af1
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@
namespace gkfs {
namespace config {

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

constexpr auto hostfile_path = "./gkfs_hosts.txt";

namespace io {
@@ -51,7 +54,7 @@ constexpr auto use_blocks = false;
} // namespace metadata

namespace rpc {
constexpr auto chunksize = 524288; // in bytes (e.g., 524288 == 512KB)
constexpr auto chunksize = 16 * 1024 * 1024; // in MiB (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
/*
+18 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

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

extern "C" {
#include <sys/statfs.h>
@@ -124,10 +125,16 @@ ChunkStorage::write_chunk(const string& file_path, gkfs::rpc::chnk_id_t chunk_id
                          off64_t offset) const {

    assert((offset + size) <= chunksize_);
    string chunk_path = ""s;
    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));
    }
    log_->trace("{}() Before open with chunk path '{}'", __func__, chunk_path);
    int fd = open(chunk_path.c_str(), O_WRONLY | O_CREAT, 0640);
    if (fd < 0) {
        auto err_str = fmt::format("Failed to open chunk file for write. File: '{}', Error: '{}'", chunk_path,
@@ -167,7 +174,13 @@ 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 = ""s;
    if (gkfs::config::limbo_mode) {
        chunk_path = "/dev/zero"s;
    } else {
        chunk_path = absolute(get_chunk_path(file_path, chunk_id));
    }
    log_->trace("{}() Before open with chunk path '{}'", __func__, chunk_path);
    int fd = open(chunk_path.c_str(), O_RDONLY);
    if (fd < 0) {
        auto err_str = fmt::format("Failed to open chunk file for read. File: '{}', Error: '{}'", chunk_path,
+2 −1
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ void remove(const string& path) {
    try {
        GKFS_DATA->mdb()->remove(path); // remove metadata from KV store
    } catch (const NotFoundException& e) {}
    if (!gkfs::config::limbo_mode)
        GKFS_DATA->storage()->destroy_chunk_space(path); // destroys all chunks for the path on this node
}