Verified Commit 6539c2cc authored by Marc Vef's avatar Marc Vef
Browse files

Remove: Separating metadata and data removal logic

Removes 1 stat RPC per remove operation
parent 25a5ed7a
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -41,8 +41,7 @@ int
forward_stat(const std::string& path, std::string& attr);

int
forward_remove(const std::string& path, bool remove_metadentry_only,
               ssize_t size);
forward_remove(const std::string& path);

int
forward_decr_size(const std::string& path, size_t length);
+134 −10
Original line number Diff line number Diff line
@@ -462,8 +462,8 @@ struct stat {
};

//==============================================================================
// definitions for remove
struct remove {
// definitions for remove metadata
struct remove_metadata {

    // forward declarations of public input/output types for this RPC
    class input;
@@ -471,23 +471,23 @@ struct remove {
    class output;

    // traits used so that the engine knows what to do with the RPC
    using self_type = remove;
    using self_type = remove_metadata;
    using handle_type = hermes::rpc_handle<self_type>;
    using input_type = input;
    using output_type = output;
    using mercury_input_type = rpc_rm_node_in_t;
    using mercury_output_type = rpc_err_out_t;
    using mercury_output_type = rpc_rm_metadata_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 = 2549415936;
    constexpr static const uint64_t public_id = 2087845888;

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

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

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

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

    class input {

@@ -541,9 +541,10 @@ struct remove {
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        output() : m_err() {}
        output() : m_err(), m_size(), m_mode() {}

        output(int32_t err) : m_err(err) {}
        output(int32_t err, int64_t size, uint32_t mode)
            : m_err(err), m_size(size), m_mode(mode) {}

        output(output&& rhs) = default;

@@ -555,8 +556,10 @@ struct remove {
        output&
        operator=(const output& other) = default;

        explicit output(const rpc_err_out_t& out) {
        explicit output(const rpc_rm_metadata_out_t& out) {
            m_err = out.err;
            m_size = out.size;
            m_mode = out.mode;
        }

        int32_t
@@ -564,8 +567,21 @@ struct remove {
            return m_err;
        }

        int64_t
        size() const {
            return m_size;
        }

        uint32_t
        mode() const {
            return m_mode;
        };


    private:
        int32_t m_err;
        int64_t m_size;
        uint32_t m_mode;
    };
};

@@ -1285,6 +1301,114 @@ struct mk_symlink {

#endif // HAS_SYMLINKS

//==============================================================================
// definitions for remove data
struct remove_data {

    // 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 = remove_data;
    using handle_type = hermes::rpc_handle<self_type>;
    using input_type = input;
    using output_type = output;
    using mercury_input_type = rpc_rm_node_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 = 2649292800;

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

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

    // 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_rm_node_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) : m_path(path) {}

        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;
        }

        explicit input(const rpc_rm_node_in_t& other) : m_path(other.path) {}

        explicit operator rpc_rm_node_in_t() {
            return {m_path.c_str()};
        }

    private:
        std::string m_path;
    };

    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 write_data
struct write_data {
+3 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ DECLARE_MARGO_RPC_HANDLER(rpc_srv_stat)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_decr_size)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_remove)
DECLARE_MARGO_RPC_HANDLER(rpc_srv_remove_metadata)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_update_metadentry)

@@ -47,6 +47,8 @@ DECLARE_MARGO_RPC_HANDLER(rpc_srv_mk_symlink)


// data
DECLARE_MARGO_RPC_HANDLER(rpc_srv_remove_data)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_read)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_write)
+2 −1
Original line number Diff line number Diff line
@@ -25,7 +25,8 @@ namespace tag {
constexpr auto fs_config = "rpc_srv_fs_config";
constexpr auto create = "rpc_srv_mk_node";
constexpr auto stat = "rpc_srv_stat";
constexpr auto remove = "rpc_srv_rm_node";
constexpr auto remove_metadata = "rpc_srv_rm_metadata";
constexpr auto remove_data = "rpc_srv_rm_data";
constexpr auto decr_size = "rpc_srv_decr_size";
constexpr auto update_metadentry = "rpc_srv_update_metadentry";
constexpr auto get_metadentry_size = "rpc_srv_get_metadentry_size";
+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ MERCURY_GEN_PROC(rpc_stat_out_t,

MERCURY_GEN_PROC(rpc_rm_node_in_t, ((hg_const_string_t)(path)))

MERCURY_GEN_PROC(rpc_rm_metadata_out_t,
                 ((hg_int32_t)(err))((hg_int64_t)(size))((hg_uint32_t)(mode)))

MERCURY_GEN_PROC(rpc_trunc_in_t,
                 ((hg_const_string_t)(path))((hg_uint64_t)(length)))

Loading