Commit 765462fa authored by Hans Holmberg's avatar Hans Holmberg Committed by Jens Axboe

lightnvm: pblk: fix write amplificiation calculation

When the user data counter exceeds 32 bits, the write amplification
calculation does not provide the right value. Fix this by using
div64_u64 in stead of div64.

Fixes: 76758390 ("lightnvm: pblk: export write amplification counters to sysfs")
Signed-off-by: default avatarHans Holmberg <hans.holmberg@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <mb@lightnvm.io>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent ea1d24bc
...@@ -337,7 +337,6 @@ static ssize_t pblk_get_write_amp(u64 user, u64 gc, u64 pad, ...@@ -337,7 +337,6 @@ static ssize_t pblk_get_write_amp(u64 user, u64 gc, u64 pad,
{ {
int sz; int sz;
sz = snprintf(page, PAGE_SIZE, sz = snprintf(page, PAGE_SIZE,
"user:%lld gc:%lld pad:%lld WA:", "user:%lld gc:%lld pad:%lld WA:",
user, gc, pad); user, gc, pad);
...@@ -349,7 +348,7 @@ static ssize_t pblk_get_write_amp(u64 user, u64 gc, u64 pad, ...@@ -349,7 +348,7 @@ static ssize_t pblk_get_write_amp(u64 user, u64 gc, u64 pad,
u32 wa_frac; u32 wa_frac;
wa_int = (user + gc + pad) * 100000; wa_int = (user + gc + pad) * 100000;
wa_int = div_u64(wa_int, user); wa_int = div64_u64(wa_int, user);
wa_int = div_u64_rem(wa_int, 100000, &wa_frac); wa_int = div_u64_rem(wa_int, 100000, &wa_frac);
sz += snprintf(page + sz, PAGE_SIZE - sz, "%llu.%05u\n", sz += snprintf(page + sz, PAGE_SIZE - sz, "%llu.%05u\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment