Skip to content

Commit

Permalink
fs: rebuild zone lifetime while mount
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Wang <[email protected]>
  • Loading branch information
ywang-wnlo committed Oct 30, 2023
1 parent 8337de1 commit fce7037
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fs/fs_zenfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,19 @@ IOStatus ZenFS::Repair() {
return IOStatus::OK();
}

void ZenFS::RebuildZoneLifeTime() {
std::map<std::string, std::shared_ptr<ZoneFile>>::iterator it;
for (it = files_.begin(); it != files_.end(); it++) {
std::shared_ptr<ZoneFile> zFile = it->second;
std::vector<ZoneExtent*> 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();
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions fs/fs_zenfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fce7037

Please sign in to comment.