Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The lifetime_ of the zone will be lost after remount zenfs #266

Open
ywang-wnlo opened this issue Apr 4, 2023 · 2 comments
Open

The lifetime_ of the zone will be lost after remount zenfs #266

ywang-wnlo opened this issue Apr 4, 2023 · 2 comments

Comments

@ywang-wnlo
Copy link
Contributor

zenfs/fs/zbd_zenfs.cc

Lines 51 to 64 in b04ca0c

Zone::Zone(ZonedBlockDevice *zbd, ZonedBlockDeviceBackend *zbd_be,
std::unique_ptr<ZoneList> &zones, unsigned int idx)
: zbd_(zbd),
zbd_be_(zbd_be),
busy_(false),
start_(zbd_be->ZoneStart(zones, idx)),
max_capacity_(zbd_be->ZoneMaxCapacity(zones, idx)),
wp_(zbd_be->ZoneWp(zones, idx)) {
lifetime_ = Env::WLTH_NOT_SET;
used_capacity_ = 0;
capacity_ = 0;
if (zbd_be->ZoneIsWritable(zones, idx))
capacity_ = max_capacity_ - (wp_ - start_);
}

The zone is configured with a lifetime_ of Env::WLTH_NOT_SET during initialization, but if the zone already has data(such as remount), it should be configured as the maximum value of the lifetime_ of the files in it.

zenfs/fs/zbd_zenfs.cc

Lines 393 to 413 in b04ca0c

#define LIFETIME_DIFF_NOT_GOOD (100)
#define LIFETIME_DIFF_COULD_BE_WORSE (50)
unsigned int GetLifeTimeDiff(Env::WriteLifeTimeHint zone_lifetime,
Env::WriteLifeTimeHint file_lifetime) {
assert(file_lifetime <= Env::WLTH_EXTREME);
if ((file_lifetime == Env::WLTH_NOT_SET) ||
(file_lifetime == Env::WLTH_NONE)) {
if (file_lifetime == zone_lifetime) {
return 0;
} else {
return LIFETIME_DIFF_NOT_GOOD;
}
}
if (zone_lifetime > file_lifetime) return zone_lifetime - file_lifetime;
if (zone_lifetime == file_lifetime) return LIFETIME_DIFF_COULD_BE_WORSE;
return LIFETIME_DIFF_NOT_GOOD;
}

Due to the fact that the lifetime_ of zones is related to the zone allocation algorithm, which will always return LIFETIME_DIFF_NOT_GOOD as the zone_lifetime is Env::WLTH_NOT_SET

@ywang-wnlo
Copy link
Contributor Author

I tried to fix the problem in this commit

I will submit a pull request if needed

@yhr
Copy link
Collaborator

yhr commented Oct 27, 2023

@ywang-wnlo , this looks like a good fix, please submit a PR. Pardon the delay in my response :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants