westerndigitalcorporation / zenfs

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

Do we really need a lock inside `ZonedWritableFile::Fsync`? #45

Closed royguo closed 3 years ago

royguo commented 3 years ago
IOStatus ZonedWritableFile::Fsync(const IOOptions& /*options*/,
                                  IODebugContext* /*dbg*/) {
  IOStatus s;

  buffer_mtx_.lock();
  s = FlushBuffer();
  buffer_mtx_.unlock();
  if (!s.ok()) {
    return s;
  }
  zoneFile_->PushExtent();

  return metadata_writer_->Persist(zoneFile_);
}

We know these facts about RocksDB:

yhr commented 3 years ago

@royguo : see https://github.com/facebook/rocksdb/blob/e8a700115990ebec5dddc2ffac54d9af41e9ca69/include/rocksdb/file_system.h#L898 . To support mysql/myrocks/zenfs fsyncs must be thread safe

yhr commented 3 years ago

@royguo : I'll close this if you have no further questions? thanks!