From: Darrick J. Wong <djwong@xxxxxxxxxx> Currently, the progress reporting only triggers when the number of bytes read is exactly a multiple of a megabyte. This isn't always guaranteed, since AG headers can be 512 bytes in size. Fix the algorithm by recording the number of megabytes we've reported as being read, and emit a new report any time the bytes_read count, once converted to megabytes, doesn't match. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- mdrestore/xfs_mdrestore.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 4318fac9008..672010bcc6e 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -126,6 +126,7 @@ perform_restore( int mb_count; xfs_sb_t sb; int64_t bytes_read; + int64_t mb_read = 0; int log_fd = -1; bool is_mdx; @@ -205,8 +206,14 @@ perform_restore( fatal("rtdev not supported\n"); } - if (show_progress && (bytes_read & ((1 << 20) - 1)) == 0) - print_progress("%lld MB read", bytes_read >> 20); + if (show_progress) { + int64_t mb_now = bytes_read >> 20; + + if (mb_now != mb_read) { + print_progress("%lld MB read", mb_now); + mb_read = mb_now; + } + } for (cur_index = 0; cur_index < mb_count; cur_index++) { if (pwrite(write_fd, &block_buffer[cur_index << @@ -245,6 +252,9 @@ perform_restore( bytes_read += block_size + (mb_count << mbp->mb_blocklog); } + if (show_progress && bytes_read > (mb_read << 20)) + print_progress("%lld MB read", mb_read + 1); + if (progress_since_warning) putchar('\n');