Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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