btrfs-progs: scrub: improve Rate reporting for sub-second durations
PATCH 1/1 btrfs-progs: scrub: improve Rate reporting for sub-second durations
Scrubs which complete in under one second may carry a duration rounded down to zero. This subsequently results in a bytes_per_sec value of zero, which corresponds to the Rate metric output, causing intermittent tests/btrfs/282 failures.
This change ensures that Rate reflects any sub-second bytes processed. Time left and ETA metrics are also affected by this change, in that they increase to account for (sub-second) bytes_per_sec.
--- cmds/scrub.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
cmds/scrub.c +8 -1
@@ -152,7 +152,14 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p, struct scrub_statime_t sec_eta; bytes_scrubbed = p->data_bytes_scrubbed + p->tree_bytes_scrubbed; -if (s->duration >0 ) +/* +* If duration is zero seconds (rounded down), then the Rate metric +* should still reflect the amount of bytes that have been processed +* in under a second. +*/ +if (s->duration ==0 ) + bytes_per_sec = bytes_scrubbed; +else bytes_per_sec = bytes_scrubbed / s->duration;if (bytes_per_sec >0 ) sec_left = (bytes_total - bytes_scrubbed) / bytes_per_sec;
Signature · 1 line
2.35.3
Quoted 10 lines · David Disseldorp
Scrubs which complete in under one second may carry a duration rounded down to zero. This subsequently results in a
bytes_per_secvalue of zero, which corresponds to the Rate metric output, causing intermittent tests/btrfs/282 failures.This change ensures that Rate reflects any sub-second bytes processed. Time left and ETA metrics are also affected by this change, in that they increase to account for (sub-second)
bytes_per_sec.Signed-off-by David Disseldorp <[email protected]>
Looks good to me.
In the future we should also increase the resolution to proper time stamp level.
Thanks,
Qu
Quoted 24 lines
--- cmds/scrub.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)cmds/scrub.c +8
-1@@ -152,7 +152,14 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p, struct scrub_statime_t sec_eta; bytes_scrubbed = p->data_bytes_scrubbed + p->tree_bytes_scrubbed; -if (s->duration >0 ) +/* +* If duration is zero seconds (rounded down), then the Rate metric +* should still reflect the amount of bytes that have been processed +* in under a second. +*/ +if (s->duration ==0 ) + bytes_per_sec = bytes_scrubbed; +else bytes_per_sec = bytes_scrubbed / s->duration;if (bytes_per_sec >0 ) sec_left = (bytes_total - bytes_scrubbed) / bytes_per_sec;
Quoted 12 lines · Qu Wenruo
Quoted 9 lines · David Disseldorp
Scrubs which complete in under one second may carry a duration rounded down to zero. This subsequently results in a
bytes_per_secvalue of zero, which corresponds to the Rate metric output, causing intermittent tests/btrfs/282 failures.This change ensures that Rate reflects any sub-second bytes processed. Time left and ETA metrics are also affected by this change, in that they increase to account for (sub-second)
bytes_per_sec.
Quoted 6 lines
Quoted 1 line
Signed-off-by David Disseldorp <[email protected]>Looks good to me.
In the future we should also increase the resolution to proper time stamp level.
It seems possible, we have some of the timestamps as time_te which is in seconds but the end time measured in scrub_one_dev() uses gettimeofday() so we would have the sub-second precision. However I'm not sure we need this, most scrubs run for a long time, I'd be fine with the simple fix like in this patch.
Quoted 10 lines · David Disseldorp
Scrubs which complete in under one second may carry a duration rounded down to zero. This subsequently results in a
bytes_per_secvalue of zero, which corresponds to the Rate metric output, causing intermittent tests/btrfs/282 failures.This change ensures that Rate reflects any sub-second bytes processed. Time left and ETA metrics are also affected by this change, in that they increase to account for (sub-second)
bytes_per_sec.Signed-off-by David Disseldorp <[email protected]>
Added to devel, thanks.