Commit 3a7aca10 authored by Ramon Nou's avatar Ramon Nou
Browse files

fix(client): revert metadata stat chunk bypass to preserve posix and rename semantics

parent f57bffec
Loading
Loading
Loading
Loading
Loading
+0 −20
Changes for include/client/rpc/forward_data.hpp: 0 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -76,26 +76,6 @@ forward_truncate(const std::string& path, size_t current_size, size_t new_size,
std::pair<int, ChunkStat>
forward_get_chunk_stat();

std::string
get_local_chunk_dir(const std::string& rootdir, const std::string& file_path);

std::string
get_local_chunk_path(const std::string& rootdir, const std::string& file_path,
                     uint64_t chunk_id);

ssize_t
write_local_chunk(const std::string& rootdir, const std::string& file_path,
                  uint64_t chunk_id, const char* buf, size_t size,
                  off64_t offset);

ssize_t
read_local_chunk(const std::string& rootdir, const std::string& file_path,
                 uint64_t chunk_id, char* buf, size_t size, off64_t offset);

void
destroy_local_chunk_space(const std::string& rootdir,
                          const std::string& file_path);

} // namespace gkfs::rpc

#endif // GEKKOFS_CLIENT_FORWARD_DATA_HPP
+0 −24
Changes for src/client/gkfs_data.cpp: 0 added lines, 24 removed lines.
Original line number Diff line number Diff line
@@ -134,16 +134,6 @@ gkfs_do_write(gkfs::filemap::OpenFile& file, const char* buf, size_t count,
                            std::string(buf, count), result.failed_copies);
                }
                gkfs::rpc::record_replica_write(result);
                const bool can_bypass =
                        (num_replicas == 0) && CTX->local_bypass() &&
                        CTX->has_local_host() && CTX->fs_conf() &&
                        !CTX->fs_conf()->rootdir.empty();
                if(can_bypass && targets.size() == 1 &&
                   targets[0].host == CTX->local_host_id()) {
                    gkfs::rpc::write_local_chunk(
                            CTX->fs_conf()->rootdir, *path, 0,
                            static_cast<const char*>(buf), count, offset);
                }
                gkfs::metadata::Metadata md{
                        static_cast<mode_t>(file.mode() | S_IFREG)};
                md.size(static_cast<size_t>(offset) + count);
@@ -216,20 +206,6 @@ gkfs_do_write(gkfs::filemap::OpenFile& file, const char* buf, size_t count,
                    file.path(), buf, offset, count, is_append, num_replicas);
            err = ret_inline.first;
            if(err == 0) {
                const bool can_bypass =
                        (num_replicas == 0) && CTX->local_bypass() &&
                        CTX->has_local_host() && CTX->fs_conf() &&
                        !CTX->fs_conf()->rootdir.empty();
                if(can_bypass) {
                    const auto target = gkfs::rpc::locate_metadata_replica(
                            *CTX->distributor(), file.path(), 0);
                    if(target.host == CTX->local_host_id()) {
                        gkfs::rpc::write_local_chunk(
                                CTX->fs_conf()->rootdir, file.path(), 0,
                                static_cast<const char*>(buf), count,
                                is_append ? ret_inline.second : offset);
                    }
                }
                if(update_pos)
                    file.pos(ret_inline.second + count);
                return count;
+0 −52
Changes for src/client/rpc/forward_metadata.cpp: 0 added lines, 52 removed lines.
Original line number Diff line number Diff line
@@ -48,8 +48,6 @@
#include <client/logging.hpp>
#include <client/open_dir.hpp>
#include <client/open_file_map.hpp>
#include <client/rpc/forward_data.hpp>
#include <common/metadata.hpp>

#include <common/rpc/distributor.hpp>
#include <common/rpc/rpc_util.hpp>
@@ -244,51 +242,6 @@ forward_stat(const std::string& path, string& attr, string& inline_data,
    const auto target =
            gkfs::rpc::locate_metadata_replica(*CTX->distributor(), path, copy);

    const bool can_bypass = (copy == 0) && (CTX->get_replicas() == 0) &&
                            CTX->local_bypass() && CTX->has_local_host() &&
                            (target.host == CTX->local_host_id()) &&
                            CTX->fs_conf() && !CTX->fs_conf()->rootdir.empty();
    if(can_bypass) {
        const auto& rootdir = CTX->fs_conf()->rootdir;
        auto chunk_0_path = get_local_chunk_path(rootdir, path, 0);
        struct stat chunk_st{};
        if(::stat(chunk_0_path.c_str(), &chunk_st) == 0 &&
           S_ISREG(chunk_st.st_mode)) {
            auto chunk_1_path = get_local_chunk_path(rootdir, path, 1);
            if(::access(chunk_1_path.c_str(), F_OK) != 0) {
                gkfs::metadata::Metadata md{};
                md.mode(chunk_st.st_mode);
                md.link_count(1);
                md.size(chunk_st.st_size);
                md.atime(chunk_st.st_atime);
                md.mtime(chunk_st.st_mtime);
                md.ctime(chunk_st.st_ctime);
                md.blocks(chunk_st.st_blocks);

                if(include_inline && chunk_st.st_size >= 0 &&
                   static_cast<size_t>(chunk_st.st_size) <=
                           gkfs::config::metadata::inline_data_size) {
                    inline_data.resize(chunk_st.st_size);
                    if(chunk_st.st_size > 0) {
                        int fd = ::open(chunk_0_path.c_str(), O_RDONLY);
                        if(fd >= 0) {
                            ssize_t r = ::pread64(fd, inline_data.data(),
                                                  chunk_st.st_size, 0);
                            ::close(fd);
                            if(r == static_cast<ssize_t>(chunk_st.st_size)) {
                                md.inline_data(inline_data);
                            } else {
                                inline_data.clear();
                            }
                        }
                    }
                }
                attr = md.serialize();
                CTX->mark_host_success(target.host);
                return 0;
            }
        }
    }

    auto endp = CTX->hosts()->at(target.host);

@@ -378,11 +331,6 @@ forward_remove(const std::string& path, bool rm_dir, const int8_t num_copies,
    if(err != 0)
        return err;

    if(!rm_dir && CTX->local_bypass() && CTX->has_local_host() &&
       CTX->fs_conf() && !CTX->fs_conf()->rootdir.empty()) {
        destroy_local_chunk_space(CTX->fs_conf()->rootdir, path);
    }

    // Step 2: Broadcast remove_data to ALL daemons so that every host can
    // clean up whatever chunks it holds for this file.
    // NOTE: When using the proxy, the proxy handles this broadcast itself, so