Commit 7271647e authored by Ramon Nou's avatar Ramon Nou
Browse files

optimizied, binary inline data

parent eacc3c3a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -82,7 +82,8 @@ to_underlying(E e) {
}

std::optional<gkfs::metadata::Metadata>
get_metadata(const std::string& path, bool follow_links = false);
get_metadata(const std::string& path, bool follow_links = false,
             bool include_inline = false);

int
metadata_to_stat(const std::string& path, const gkfs::metadata::Metadata& md,
+2 −1
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@ forward_create_write_inline(const std::string& path, mode_t mode,
                            const int copy);

int
forward_stat(const std::string& path, std::string& attr, const int copy);
forward_stat(const std::string& path, std::string& attr,
             std::string& inline_data, int copy, bool include_inline = false);

#ifdef HAS_RENAME
int
+41 −10
Original line number Diff line number Diff line
@@ -448,12 +448,16 @@ struct create_write_inline {
        }

        explicit input(const rpc_create_write_inline_in_t& other)
            : m_path(other.path), m_mode(other.mode), m_data(other.data),
            : m_path(other.path), m_mode(other.mode),
              m_data(static_cast<char*>(other.data.data), other.data.size),
              m_count(other.count) {}

        explicit
        operator rpc_create_write_inline_in_t() {
            return {m_path.c_str(), m_mode, m_data.c_str(), m_count};
            return {m_path.c_str(),
                    m_mode,
                    {(void*) m_data.c_str(), m_data.size()},
                    m_count};
        }

    private:
@@ -552,7 +556,8 @@ struct stat {
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        input(const std::string& path) : m_path(path) {}
        input(const std::string& path, bool include_inline = false)
            : m_path(path), m_include_inline(include_inline) {}

        input(input&& rhs) = default;

@@ -569,15 +574,22 @@ struct stat {
            return m_path;
        }

        explicit input(const rpc_path_only_in_t& other) : m_path(other.path) {}
        bool
        include_inline() const {
            return m_include_inline;
        }

        explicit input(const rpc_path_only_in_t& other)
            : m_path(other.path), m_include_inline(other.include_inline) {}

        explicit
        operator rpc_path_only_in_t() {
            return {m_path.c_str()};
            return {m_path.c_str(), static_cast<hg_bool_t>(m_include_inline)};
        }

    private:
        std::string m_path;
        bool m_include_inline;
    };

    class output {
@@ -589,8 +601,9 @@ struct stat {
    public:
        output() : m_err(), m_db_val() {}

        output(int32_t err, const std::string& db_val)
            : m_err(err), m_db_val(db_val) {}
        output(int32_t err, const std::string& db_val,
               const std::string& inline_data)
            : m_err(err), m_db_val(db_val), m_inline_data(inline_data) {}

        output(output&& rhs) = default;

@@ -608,6 +621,11 @@ struct stat {
            if(out.db_val != nullptr) {
                m_db_val = out.db_val;
            }

            if(out.inline_data.data != nullptr && out.inline_data.size > 0) {
                m_inline_data.assign((char*) out.inline_data.data,
                                     out.inline_data.size);
            }
        }

        int32_t
@@ -620,9 +638,15 @@ struct stat {
            return m_db_val;
        }

        std::string
        inline_data() const {
            return m_inline_data;
        }

    private:
        int32_t m_err;
        std::string m_db_val;
        std::string m_inline_data;
    };
};

@@ -2628,12 +2652,16 @@ struct write_data_inline {
              m_append(append) {}

        explicit input(const rpc_write_inline_in_t& other)
            : m_path(other.path), m_offset(other.offset), m_data(other.data),
            : m_path(other.path), m_offset(other.offset),
              m_data(static_cast<char*>(other.data.data), other.data.size),
              m_count(other.count), m_append(other.append) {}

        explicit
        operator rpc_write_inline_in_t() {
            return {m_path.c_str(), m_offset, m_data.c_str(), m_count,
            return {m_path.c_str(),
                    m_offset,
                    {(void*) m_data.c_str(), m_data.size()},
                    m_count,
                    static_cast<hg_bool_t>(m_append)};
        }

@@ -2729,7 +2757,10 @@ struct read_data_inline {
    public:
        output() : m_err(0), m_count(0) {}
        explicit output(const rpc_read_inline_out_t& out)
            : m_err(out.err), m_data(out.data ? out.data : ""),
            : m_err(out.err),
              m_data(out.data.data
                             ? std::string((char*) out.data.data, out.data.size)
                             : ""),
              m_count(out.count) {}

        int32_t
+2 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@

namespace gkfs::metadata {

constexpr const char MSP = '|';

constexpr mode_t LINK_MODE = ((S_IRWXU | S_IRWXG | S_IRWXO) | S_IFLNK);

uint16_t
+16 −5
Original line number Diff line number Diff line
@@ -46,6 +46,15 @@ extern "C" {

/* visible API for RPC data types used in RPCS */

typedef struct {
    void* data;
    size_t size;
} rpc_inline_data_t;

hg_return_t
hg_proc_rpc_inline_data_t(hg_proc_t proc, void* data);


// misc generic rpc types
MERCURY_GEN_PROC(rpc_err_out_t, ((hg_int32_t) (err)))

@@ -53,10 +62,12 @@ MERCURY_GEN_PROC(rpc_err_out_t, ((hg_int32_t) (err)))
MERCURY_GEN_PROC(rpc_mk_node_in_t,
                 ((hg_const_string_t) (path))((uint32_t) (mode)))

MERCURY_GEN_PROC(rpc_path_only_in_t, ((hg_const_string_t) (path)))
MERCURY_GEN_PROC(rpc_path_only_in_t,
                 ((hg_const_string_t) (path))((hg_bool_t) (include_inline)))

MERCURY_GEN_PROC(rpc_stat_out_t,
                 ((hg_int32_t) (err))((hg_const_string_t) (db_val)))
                 ((hg_int32_t) (err))((hg_const_string_t) (db_val))(
                         (rpc_inline_data_t) (inline_data)))

MERCURY_GEN_PROC(rpc_rm_node_in_t,
                 ((hg_const_string_t) (path))((hg_bool_t) (rm_dir)))
@@ -194,7 +205,7 @@ MERCURY_GEN_PROC(rpc_migrate_metadata_in_t,
// Inline write operations
MERCURY_GEN_PROC(rpc_write_inline_in_t,
                 ((hg_const_string_t) (path))((hg_uint64_t) (offset))(
                         (hg_const_string_t) (data))((hg_uint64_t) (count))(
                         (rpc_inline_data_t) (data))((hg_uint64_t) (count))(
                         (hg_bool_t) (append)))

// Output: err, offset (for append), bytes written
@@ -204,7 +215,7 @@ MERCURY_GEN_PROC(

MERCURY_GEN_PROC(rpc_create_write_inline_in_t,
                 ((hg_const_string_t) (path))((uint32_t) (mode))(
                         (hg_const_string_t) (data))((hg_uint64_t) (count)))
                         (rpc_inline_data_t) (data))((hg_uint64_t) (count)))

MERCURY_GEN_PROC(rpc_create_write_inline_out_t,
                 ((hg_int32_t) (err))((hg_uint64_t) (io_size)))
@@ -217,5 +228,5 @@ MERCURY_GEN_PROC(rpc_read_inline_in_t,
// Output: err, data buffer, bytes read
MERCURY_GEN_PROC(
        rpc_read_inline_out_t,
        ((hg_int32_t) (err))((hg_const_string_t) (data))((hg_uint64_t) (count)))
        ((hg_int32_t) (err))((rpc_inline_data_t) (data))((hg_uint64_t) (count)))
#endif // LFS_RPC_TYPES_HPP
Loading