westerndigitalcorporation / zenfs

ZenFS is a storage backend for RocksDB that enables support for ZNS SSDs and SMR HDDs.
GNU General Public License v2.0
235 stars 86 forks source link

Why Deletefile() do not check open_for_wr_mtx_ lock(AcquireWRLock) ? #277

Closed sg20180546 closed 9 months ago

sg20180546 commented 1 year ago

Maybe it may incur zone capacity (remainig) leak, If the file is migrated by garbage collection.

fs/fs_zenfs.cc

    if (GetFileNoLock(fname) == nullptr) {
      Info(logger_, "Migrate file not exist anymore.");
      zbd_->ReleaseMigrateZone(target_zone);
      break;
    }

In the code, if file is deleted or removed during GC, break the loop and call SyncFileExtents. But there is no code about substracting Zone->usedcapacity of extents that is migrated but deleted .


    ext->start_ = target_start;
    ext->zone_ = target_zone;
    ext->zone_->used_capacity_ += ext->length_;

Maybe there should be corresponding operation of above operation.

yhr commented 1 year ago

If the file has been deleted, the file destructor releases all extents and subtracts the zone used capacity counts