Verified Commit 9de7db86 authored by Marc Vef's avatar Marc Vef
Browse files

Avoid stat RPC during remove

parent 1579454e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ cmake_dependent_option(GKFS_INSTALL_TESTS "Install GekkoFS self tests" OFF "GKFS
gkfs_define_option(
  GKFS_CREATE_CHECK_PARENTS
  HELP_TEXT "Enable checking parent directory for existence before creating children"
  DEFAULT_VALUE ON
  DEFAULT_VALUE OFF
  DESCRIPTION "Verify that a parent directory exists before creating new files or directories"
)

+5 −5
Original line number Diff line number Diff line
@@ -327,9 +327,9 @@ gkfs_create(const std::string& path, mode_t mode) {
            return -1;
    }

    // if(check_parent_dir(path)) {
    //     return -1;
    // }
     if(check_parent_dir(path)) {
         return -1;
     }
    int err = 0;
    if(gkfs::config::proxy::fwd_create && CTX->use_proxy()) {
        // no replication support for proxy
@@ -365,6 +365,8 @@ gkfs_create(const std::string& path, mode_t mode) {
 */
int
gkfs_remove(const std::string& path) {
#ifdef HAS_SYMLINKS
#ifdef HAS_RENAME
    auto md = gkfs::utils::get_metadata(path);
    if(!md) {
        return -1;
@@ -375,8 +377,6 @@ gkfs_remove(const std::string& path) {
        errno = EISDIR;
        return -1;
    }
#ifdef HAS_SYMLINKS
#ifdef HAS_RENAME
    if(md.value().blocks() == -1) {
        errno = ENOENT;
        return -1;
+12 −11
Original line number Diff line number Diff line
@@ -246,13 +246,14 @@ rpc_srv_remove_metadata(hg_handle_t handle) {
        auto md = gkfs::metadata::get(in.path);
        gkfs::metadata::remove(in.path);
        out.err = 0;
        if(!S_ISDIR(md.mode())) {
            out.mode = md.mode();
            out.size = md.size();
            if constexpr(gkfs::config::metadata::implicit_data_removal) {
                if(S_ISREG(md.mode()) && (md.size() != 0))
                    GKFS_DATA->storage()->destroy_chunk_space(in.path);
            }

        }
    } catch(const gkfs::metadata::NotFoundException& e) {
        GKFS_DATA->spdlogger()->warn(
                "{}(): path '{}' message '{}'. Continuing, setting out.err 0.",
@@ -705,7 +706,7 @@ rpc_srv_get_dirents_extended(hg_handle_t handle) {
    auto hgi = margo_get_info(handle);
    auto mid = margo_hg_handle_get_instance(handle);
    auto bulk_size = margo_bulk_get_size(in.bulk_handle);
    GKFS_DATA->spdlogger()->debug("{}() Got RPC: path '{}' bulk_size '{}' ",
    GKFS_DATA->spdlogger()->trace("{}() Got RPC: path '{}' bulk_size '{}' ",
                                  __func__, in.path, bulk_size);

    // Get directory entries from local DB
@@ -770,9 +771,9 @@ rpc_srv_get_dirents_extended(hg_handle_t handle) {
        return gkfs::rpc::cleanup_respond(&handle, &in, &out, &bulk_handle);
    }

    GKFS_DATA->spdlogger()->trace(
            "{}() path '{}' entries '{}' out_size '{}'. Set up local read only bulk handle and allocated buffer with size '{}'",
            __func__, in.path, entries.size(), out_size, out_size);
    GKFS_DATA->spdlogger()->info(
            "{}() path '{}' entries '{}' out_size '{}' bulk_size '{}' difference '{}'.",
            __func__, in.path, entries.size(), out_size, bulk_size, bulk_size - out_size);

    // Serialize output data on local buffer
    // The parenthesis are extremely important, if not the + will be size_t or
@@ -824,7 +825,7 @@ rpc_srv_get_dirents_extended(hg_handle_t handle) {

    out.dirents_size = entries.size();
    out.err = 0;
    GKFS_DATA->spdlogger()->debug(
    GKFS_DATA->spdlogger()->trace(
            "{}() Sending output response err '{}' dirents_size '{}'. DONE",
            __func__, out.err, out.dirents_size);
    return gkfs::rpc::cleanup_respond(&handle, &in, &out, &bulk_handle);