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

AllocateNewZone have to wait for GCWorker job done #257

Closed sg20180546 closed 1 year ago

sg20180546 commented 1 year ago

In some IO Intensive situation, ZoneFile::AllocateNewZone returns IOStatus::NoSpace. but rather than return directly Nospace error and shutdown database, maybe there should be one more chance to GCWorker collect extents and make appropriate zone to allocate data (i think) In my research environment, i change AllocateNewZone like this :+1:

IOStatus ZoneFile::AllocateNewZone() {
  Zone* zone;
  IOStatus s = zbd_->AllocateIOZone(lifetime_, io_type_, &zone);

  if (!s.ok()&&s!=IOStatus::NoSpace()){ 
    return s;
  }
  if (!zone) {
    // return IOStatus::NoSpace("Zone allocation failure\n");
    zenfs_->GCWorker(true);
    s = zbd_->AllocateIOZone(lifetime_, io_type_, &zone);
  }
  if(!s.ok()){
    return s;
  }
  if(!zone){
    return IOStatus::NoSpace("Zone allocation failure\n");
  }

Parameter for GCWorker is flag for run only once(loop). I make a member variable ZenFS* in ZoneFile and Call GCWorker, but this may be messy code. (if maintainer do not thinks like that, i could push it)

Anyway, there have to be one more chance for zone allocation.

yhr commented 1 year ago

@sg20180546 : I think we should not force gc if the user has not requested it, but rather make sure that the background gc thread frees up enough space to sustain the user writes. To do this properly we would have to rate-limit the user writes to make sure the background gc process will free up enough space (as the user writes would likely out-compete the gc thread for disk bandwidth)