diff --git a/fs/fs_zenfs.cc b/fs/fs_zenfs.cc index c41c2472..62846b0e 100644 --- a/fs/fs_zenfs.cc +++ b/fs/fs_zenfs.cc @@ -333,6 +333,19 @@ IOStatus ZenFS::Repair() { return IOStatus::OK(); } +void ZenFS::RebuildZoneLifeTime() { + std::map>::iterator it; + for (it = files_.begin(); it != files_.end(); it++) { + std::shared_ptr zFile = it->second; + std::vector extents = zFile->GetExtents(); + Env::WriteLifeTimeHint file_lifetime = zFile->GetWriteLifeTimeHint(); + for (const auto* ext : extents) { + Zone* zone = ext->zone_; + if (zone->lifetime_ < file_lifetime) zone->lifetime_ = file_lifetime; + } + } +} + std::string ZenFS::FormatPathLexically(fs::path filepath) { fs::path ret = fs::path("/") / filepath.lexically_normal(); return ret.string(); @@ -1471,6 +1484,8 @@ Status ZenFS::Mount(bool readonly) { } } + RebuildZoneLifeTime(); + Info(logger_, "Superblock sequence %d", (int)superblock_->GetSeq()); Info(logger_, "Finish threshold %u", superblock_->GetFinishTreshold()); Info(logger_, "Filesystem mount OK"); diff --git a/fs/fs_zenfs.h b/fs/fs_zenfs.h index 41abc9d5..bc9a54a6 100644 --- a/fs/fs_zenfs.h +++ b/fs/fs_zenfs.h @@ -252,6 +252,8 @@ class ZenFS : public FileSystemWrapper { IOStatus Repair(); + void RebuildZoneLifeTime(); + /* Must hold files_mtx_ */ IOStatus DeleteDirRecursiveNoLock(const std::string& d, const IOOptions& options,