Commit e2a1e2e5 authored by Marc Vef's avatar Marc Vef
Browse files

Fix dangling close() when using write_cache

parent b29b8445
Loading
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -1635,6 +1635,7 @@ int
gkfs_fsync(unsigned int fd) {
    auto file = CTX->file_map()->get(fd);
    if(!file) {
        errno = 0;
        return 0;
    }
    // TODO this whole update and flush should go into the Cache class
@@ -1642,8 +1643,10 @@ gkfs_fsync(unsigned int fd) {
        auto path = file->path();
        auto write_size =
                CTX->write_size_cache()->remove_write_size(file->path());
        if(!write_size)
        if(!write_size) {
            errno = 0;
            return 0;
        }
        LOG(DEBUG, "{}() Updating size for path '{}' size '{}'", __func__,
            file->path(), write_size.value());
        auto err = update_file_size(path, write_size.value(), 0, false).first;
@@ -1674,19 +1677,20 @@ gkfs_close(unsigned int fd) {
            auto path = file->path();
            auto write_size =
                    CTX->write_size_cache()->remove_write_size(file->path());
            if(!write_size)
                return 0;
            LOG(DEBUG, "{}() Updating size for path '{}' size '{}'", __func__,
                file->path(), write_size.value());
            auto err =
                    update_file_size(path, write_size.value(), 0, false).first;
            if(write_size) {
                LOG(DEBUG, "{}() Updating size for path '{}' size '{}'",
                    __func__, file->path(), write_size.value());
                auto err = update_file_size(path, write_size.value(), 0, false)
                                   .first;
                if(err) {
                LOG(ERROR, "{}() update_metadentry_size() failed with err '{}'",
                    LOG(ERROR,
                        "{}() update_metadentry_size() failed with err '{}'",
                        __func__, err);
                    errno = err;
                    return -1;
                }
            }
        }
        if(CTX->use_dentry_cache() &&
           gkfs::config::cache::clear_dentry_cache_on_close) {
            // clear cache for directory
+4 −1
Original line number Diff line number Diff line
@@ -130,8 +130,11 @@ ChunkStorage::destroy_chunk_space(const string& file_path) const {
        auto err_str = fmt::format(
                "{}() Failed to remove chunk directory. Path: '{}', Error: '{}'",
                __func__, chunk_dir, e.what());
        if(e.code().value() != ENOENT) {
            throw ChunkStorageException(e.code().value(), err_str);
        }
        //        throw ChunkStorageException(e.code().value(), err_str);
    }
}

/**