Commit 85ae7f92 authored by Ramon Nou's avatar Ramon Nou
Browse files

repair truncate

parent 6c60a27a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ WriteSizeCache::reset(const std::string& path, bool evict) {
std::pair<int, off64_t>
WriteSizeCache::flush(const std::string& path, bool evict) {
    // mutex is set in reset(). No need to lock here
    auto [latest_entry_cnt, latest_entry_size] = reset(path, false);
    auto [latest_entry_cnt, latest_entry_size] = reset(path, evict);
    // no new updates in cache, don't return size
    if(latest_entry_cnt == 0) {
        return {};
+8 −0
Original line number Diff line number Diff line
@@ -1011,6 +1011,14 @@ gkfs_truncate(const std::string& path, off_t length) {
        return -1;
    }

    if(CTX->use_write_size_cache()) {
        auto err = CTX->write_size_cache()->flush(path, true).first;
        if(err) {
            LOG(ERROR, "{}() write_size_cache() failed with err '{}'", __func__,
                err);
        }
    }

    auto md = gkfs::utils::get_metadata(path, true);
    if(!md) {
        return -1;
+1 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ write_random_exec(const write_random_options& opts) {
    io::buffer buf(data);

    int rv = ::write(fd, buf.data(), opts.count);
    ::close(fd);

    if(opts.verbose) {
        fmt::print("write(pathname=\"{}\", count={}) = {}, errno: {} [{}]\n",