From: Chandan Babu R <chandanbabu@kernel.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 9/9] xfs_mdrestore: fix missed progress reporting
Date: Fri, 24 Nov 2023 14:44:31 +0530 [thread overview]
Message-ID: <874jhbwlxs.fsf@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <170069445938.1865809.2272471874760042809.stgit@frogsfrogsfrogs>
On Wed, Nov 22, 2023 at 03:07:39 PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> 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.
>
> Fix the v2 code to emit one final status message in case the last
> extent restored is more than a megabyte.
Looks good to me.
Reviewed-by: Chandan Babu R <chandanbabu@kernel.org>
Thanks especially for fixing all the bugs in metadump & mdrestore.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
> mdrestore/xfs_mdrestore.c | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
>
> diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
> index 3f761e8fe8d..ab9a44d2118 100644
> --- a/mdrestore/xfs_mdrestore.c
> +++ b/mdrestore/xfs_mdrestore.c
> @@ -7,6 +7,7 @@
> #include "libxfs.h"
> #include "xfs_metadump.h"
> #include <libfrog/platform.h>
> +#include "libfrog/div64.h"
>
> union mdrestore_headers {
> __be32 magic;
> @@ -160,6 +161,7 @@ restore_v1(
> int mb_count;
> xfs_sb_t sb;
> int64_t bytes_read;
> + int64_t mb_read = 0;
>
> block_size = 1 << h->v1.mb_blocklog;
> max_indices = (block_size - sizeof(xfs_metablock_t)) / sizeof(__be64);
> @@ -208,9 +210,14 @@ restore_v1(
> bytes_read = 0;
>
> for (;;) {
> - if (mdrestore.show_progress &&
> - (bytes_read & ((1 << 20) - 1)) == 0)
> - print_progress("%lld MB read", bytes_read >> 20);
> + if (mdrestore.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(ddev_fd, &block_buffer[cur_index <<
> @@ -240,6 +247,9 @@ restore_v1(
> bytes_read += block_size + (mb_count << h->v1.mb_blocklog);
> }
>
> + if (mdrestore.show_progress && bytes_read > (mb_read << 20))
> + print_progress("%lld MB read", howmany_64(bytes_read, 1U << 20));
> +
> if (mdrestore.progress_since_warning)
> putchar('\n');
>
> @@ -340,6 +350,7 @@ restore_v2(
> struct xfs_sb sb;
> struct xfs_meta_extent xme;
> char *block_buffer;
> + int64_t mb_read = 0;
> int64_t bytes_read;
> uint64_t offset;
> int len;
> @@ -416,16 +427,18 @@ restore_v2(
> bytes_read += len;
>
> if (mdrestore.show_progress) {
> - static int64_t mb_read;
> - int64_t mb_now = bytes_read >> 20;
> + int64_t mb_now = bytes_read >> 20;
>
> if (mb_now != mb_read) {
> - print_progress("%lld MB read", mb_now);
> + print_progress("%lld mb read", mb_now);
> mb_read = mb_now;
> }
> }
> } while (1);
>
> + if (mdrestore.show_progress && bytes_read > (mb_read << 20))
> + print_progress("%lld mb read", howmany_64(bytes_read, 1U << 20));
> +
> if (mdrestore.progress_since_warning)
> putchar('\n');
>
--
Chandan
prev parent reply other threads:[~2023-11-24 9:16 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 23:06 [PATCHSET 0/9] xfsprogs: minor fixes for 6.6 Darrick J. Wong
2023-11-22 23:06 ` [PATCH 1/9] libfrog: move 64-bit division wrappers to libfrog Darrick J. Wong
2023-11-23 6:34 ` Christoph Hellwig
2023-11-24 9:09 ` Chandan Babu R
2023-11-22 23:06 ` [PATCH 2/9] libxfs: don't UAF a requeued EFI Darrick J. Wong
2023-11-23 6:36 ` Christoph Hellwig
2023-11-27 18:10 ` Darrick J. Wong
2023-11-28 5:37 ` Christoph Hellwig
2023-11-28 17:01 ` Darrick J. Wong
2023-11-28 17:09 ` Christoph Hellwig
2023-11-24 9:10 ` Chandan Babu R
2023-11-22 23:07 ` [PATCH 3/9] xfs_copy: actually do directio writes to block devices Darrick J. Wong
2023-11-23 6:40 ` Christoph Hellwig
2023-11-27 18:14 ` Darrick J. Wong
2023-11-22 23:07 ` [PATCH 4/9] xfs_db: report the device associated with each io cursor Darrick J. Wong
2023-11-23 6:41 ` Christoph Hellwig
2023-11-27 18:24 ` Darrick J. Wong
2023-11-28 5:37 ` Christoph Hellwig
2023-11-22 23:07 ` [PATCH 5/9] xfs_metadump.8: update for external log device options Darrick J. Wong
2023-11-23 6:41 ` Christoph Hellwig
2023-11-24 9:11 ` Chandan Babu R
2023-11-22 23:07 ` [PATCH 6/9] xfs_mdrestore: fix uninitialized variables in mdrestore main Darrick J. Wong
2023-11-23 6:41 ` Christoph Hellwig
2023-11-24 9:11 ` Chandan Babu R
2023-11-22 23:07 ` [PATCH 7/9] xfs_mdrestore: emit newlines for fatal errors Darrick J. Wong
2023-11-23 6:41 ` Christoph Hellwig
2023-11-24 9:12 ` Chandan Babu R
2023-11-22 23:07 ` [PATCH 8/9] xfs_mdrestore: EXTERNALLOG is a compat value, not incompat Darrick J. Wong
2023-11-23 6:42 ` Christoph Hellwig
2023-11-23 6:42 ` Christoph Hellwig
2023-11-27 18:27 ` Darrick J. Wong
2023-11-28 5:38 ` Christoph Hellwig
2023-11-24 9:14 ` Chandan Babu R
2023-11-22 23:07 ` [PATCH 9/9] xfs_mdrestore: fix missed progress reporting Darrick J. Wong
2023-11-23 6:44 ` Christoph Hellwig
2023-11-24 9:14 ` Chandan Babu R [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874jhbwlxs.fsf@debian-BULLSEYE-live-builder-AMD64 \
--to=chandanbabu@kernel.org \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.