From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Dave Chinner <david@fromorbit.com>, xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs: don't write a corrupt unmount record to force summary counter recalc
Date: Fri, 27 Mar 2020 08:31:48 -0400 [thread overview]
Message-ID: <20200327123148.GA27785@bfoster> (raw)
In-Reply-To: <20200327011417.GF29339@magnolia>
On Thu, Mar 26, 2020 at 06:14:17PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> In commit f467cad95f5e3, I added the ability to force a recalculation of
> the filesystem summary counters if they seemed incorrect. This was done
> (not entirely correctly) by tweaking the log code to write an unmount
> record without the UMOUNT_TRANS flag set. At next mount, the log
> recovery code will fail to find the unmount record and go into recovery,
> which triggers the recalculation.
>
> What actually gets written to the log is what ought to be an unmount
> record, but without any flags set to indicate what kind of record it
> actually is. This worked to trigger the recalculation, but we shouldn't
> write bogus log records when we could simply write nothing.
>
> Fixes: f467cad95f5e3 ("xfs: force summary counter recalc at next mount")
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/xfs_log.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 46108ca20d85..00fda2e8e738 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -835,19 +835,6 @@ xlog_unmount_write(
> if (error)
> goto out_err;
>
> - /*
> - * If we think the summary counters are bad, clear the unmount header
> - * flag in the unmount record so that the summary counters will be
> - * recalculated during log recovery at next mount. Refer to
> - * xlog_check_unmount_rec for more details.
> - */
> - if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
> - XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
> - xfs_alert(mp, "%s: will fix summary counters at next mount",
> - __func__);
> - flags &= ~XLOG_UNMOUNT_TRANS;
> - }
> -
> error = xlog_write_unmount_record(log, tic, &lsn, flags);
> /*
> * At this point, we're umounting anyway, so there's no point in
> @@ -913,6 +900,20 @@ xfs_log_unmount_write(
>
> if (XLOG_FORCED_SHUTDOWN(log))
> return;
> +
> + /*
> + * If we think the summary counters are bad, avoid writing the unmount
> + * record to force log recovery at next mount, after which the summary
> + * counters will be recalculated. Refer to xlog_check_unmount_rec for
> + * more details.
> + */
> + if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
> + XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
> + xfs_alert(mp, "%s: will fix summary counters at next mount",
> + __func__);
> + return;
> + }
> +
> xfs_log_unmount_verify_iclog(log);
> xlog_unmount_write(log);
> }
>
next prev parent reply other threads:[~2020-03-27 12:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 1:14 [PATCH] xfs: don't write a corrupt unmount record to force summary counter recalc Darrick J. Wong
2020-03-27 9:06 ` Christoph Hellwig
2020-03-27 12:31 ` Brian Foster [this message]
2020-03-29 23:04 ` Dave Chinner
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=20200327123148.GA27785@bfoster \
--to=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).