Verified Commit 853ff94f authored by Marc Vef's avatar Marc Vef
Browse files

Added Proxy truncate() support for Client <-> Proxy

parent 9c6d9a79
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@ std::pair<int, ssize_t>
forward_read_proxy(const std::string& path, void* buf, off64_t offset,
                   size_t read_size);

int
forward_truncate_proxy(const std::string& path, size_t current_size,
                       size_t new_size);

std::pair<int, ChunkStat>
forward_get_chunk_stat_proxy();

+134 −6
Original line number Diff line number Diff line
@@ -2574,6 +2574,134 @@ struct read_data_proxy {
    };
};

//==============================================================================
// definitions for chunk_stat_proxy
struct trunc_data_proxy {

    // forward declarations of public input/output types for this RPC
    class input;

    class output;

    // traits used so that the engine knows what to do with the RPC
    using self_type = trunc_data_proxy;
    using handle_type = hermes::rpc_handle<self_type>;
    using input_type = input;
    using output_type = output;
    using mercury_input_type = rpc_client_proxy_trunc_in_t;
    using mercury_output_type = rpc_err_out_t;

    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 22;

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = 0;

    // RPC name
    constexpr static const auto name = gkfs::rpc::tag::client_proxy_truncate;

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

    // Mercury callback to serialize input arguments
    constexpr static const auto mercury_in_proc_cb =
            HG_GEN_PROC_NAME(rpc_client_proxy_trunc_in_t);

    // Mercury callback to serialize output arguments
    constexpr static const auto mercury_out_proc_cb =
            HG_GEN_PROC_NAME(rpc_err_out_t);

    class input {

        template <typename ExecutionContext>
        friend hg_return_t
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        input(const std::string& path, uint64_t current_size, uint64_t length)
            : m_path(path), m_current_size(current_size), m_length(length) {}

        input(input&& rhs) = default;

        input(const input& other) = default;

        input&
        operator=(input&& rhs) = default;

        input&
        operator=(const input& other) = default;

        std::string
        path() const {
            return m_path;
        }

        uint64_t
        current_size() const {
            return m_current_size;
        }

        uint64_t
        length() const {
            return m_length;
        }

        explicit input(const rpc_client_proxy_trunc_in_t& other)
            : m_path(other.path), m_current_size(other.current_size),
              m_length(other.length) {}

        explicit
        operator rpc_client_proxy_trunc_in_t() {
            return {
                    m_path.c_str(),
                    m_current_size,
                    m_length,
            };
        }

    private:
        std::string m_path;
        uint64_t m_current_size;
        uint64_t m_length;
    };

    class output {

        template <typename ExecutionContext>
        friend hg_return_t
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        output() : m_err() {}

        output(int32_t err) : m_err(err) {}

        output(output&& rhs) = default;

        output(const output& other) = default;

        output&
        operator=(output&& rhs) = default;

        output&
        operator=(const output& other) = default;

        explicit output(const rpc_err_out_t& out) {
            m_err = out.err;
        }

        int32_t
        err() const {
            return m_err;
        }

    private:
        int32_t m_err;
    };
};

//==============================================================================
// definitions for chunk_stat_proxy
struct chunk_stat_proxy {
@@ -2594,7 +2722,7 @@ struct chunk_stat_proxy {
    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 22;
    constexpr static const uint64_t public_id = 23;

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = 0;
@@ -2728,7 +2856,7 @@ struct create_proxy {
    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 23;
    constexpr static const uint64_t public_id = 24;

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = 0;
@@ -2845,7 +2973,7 @@ struct stat_proxy {
    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 24;
    constexpr static const uint64_t public_id = 25;

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = 0;
@@ -2965,7 +3093,7 @@ struct remove_proxy {
    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 25;
    constexpr static const uint64_t public_id = 26;

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = 0;
@@ -3074,7 +3202,7 @@ struct update_metadentry_size_proxy {
    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 26;
    constexpr static const uint64_t public_id = 27;

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = 0;
@@ -3213,7 +3341,7 @@ struct get_dirents_extended_proxy {
    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 27;
    constexpr static const uint64_t public_id = 28;

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = 0;
+1 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ constexpr auto client_proxy_update_size =
        "proxy_rpc_srv_update_metadentry_size";
constexpr auto client_proxy_write = "proxy_rpc_srv_write_data";
constexpr auto client_proxy_read = "proxy_rpc_srv_read_data";
constexpr auto client_proxy_truncate = "proxy_rpc_srv_truncate";
constexpr auto client_proxy_chunk_stat = "proxy_rpc_srv_chunk_stat";
constexpr auto client_proxy_get_dirents_extended =
        "proxy_rpc_srv_get_dirents_extended";
+3 −1
Original line number Diff line number Diff line
@@ -136,7 +136,9 @@ MERCURY_GEN_PROC(rpc_client_proxy_read_in_t,
                 ((hg_const_string_t) (path))(
                         (int64_t) (offset)) // file offset, NOT chunk offset
                 ((hg_uint64_t) (read_size))((hg_bulk_t) (bulk_handle)))

MERCURY_GEN_PROC(rpc_client_proxy_trunc_in_t,
                 ((hg_const_string_t) (path))((hg_uint64_t) (current_size))(
                         (hg_uint64_t) (length)))
// proxy <-> daemon

MERCURY_GEN_PROC(
+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ constexpr auto fwd_stat = true;
constexpr auto fwd_remove = true;
constexpr auto fwd_update_size = true;
constexpr auto fwd_io = true;
constexpr auto fwd_truncate = true;
constexpr auto fwd_chunk_stat = true;
constexpr auto fwd_get_dirents_single = true;
// Only use proxy for io if write/read size is higher than set value
Loading