From: Dave Chinner <david@fromorbit.com>
To: Long Li <leo.lilong@huawei.com>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
billodo@redhat.com, chandan.babu@oracle.com, dchinner@redhat.com,
guoxuenan@huawei.com, houtao1@huawei.com,
linux-xfs@vger.kernel.org, sandeen@redhat.com,
yi.zhang@huawei.com
Subject: Re: [PATCH v2] xfs: fix sb write verify for lazysbcount
Date: Mon, 31 Oct 2022 09:04:41 +1100 [thread overview]
Message-ID: <20221030220441.GH3600936@dread.disaster.area> (raw)
In-Reply-To: <20221029071601.GA1277642@ceph-admin>
On Sat, Oct 29, 2022 at 03:16:01PM +0800, Long Li wrote:
> On Thu, Oct 27, 2022 at 09:05:21AM -0700, Darrick J. Wong wrote:
> > On Thu, Oct 27, 2022 at 09:25:04PM +0800, Long Li wrote:
> > > not pass, therefore it will not write a clean umount record
> > > at umount. I also haven't found a code suitable for adding
> > > such checks.
> >
> > xfs_unmountfs just prior to unmounting the log.
>
>
> I tried to add an extra check in xfs_log_unmount_write, when m_icount <
> m_ifree, it will not write a umount log record, after which the summary
> counters will be recalculated at next mount. If m_ifree greater than
> m_icount in memory, sb_i{count,free} (the ondisk superblock inode counters)
> maybe incorrect even after unmount filesystem. After adding such checks,
> it can be corrected on the next mount, instead of going undetected in
> subsequent mounts.
>
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index f1f44c006ab3..e4903c15019e 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1038,7 +1038,9 @@ xfs_log_unmount_write(
> * more details.
> */
> if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
> - XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
> + XFS_ERRTAG_FORCE_SUMMARY_RECALC) ||
> + (percpu_counter_sum(&mp->m_icount) <
> + percpu_counter_sum(&mp->m_ifree))) {
> xfs_alert(mp, "%s: will fix summary counters at next mount",
> __func__);
> return;
The log code is not the layer at which the mount structures
should be verified. xfs_unmountfs() is where the mount is cleaned up
and all activity is flushed and waited on. THis is where the mount
counters should be checked, before we unmount the log.
Indeed, if you check the mount counters prior to calling
xfs_log_unmount_write(), you could call this:
xfs_alert(mp, "ifree/icount mismatch at unmount");
xfs_fs_mark_sick(mp, XFS_SICK_FS_COUNTERS);
i.e. check the mount state at the correct level and propagate the
sickness into the mount state and the log code will just do the
right thing....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2022-10-30 22:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-22 2:03 [PATCH v1] xfs: fix sb write verify for lazysbcount Long Li
2022-10-22 2:14 ` Darrick J. Wong
2022-10-22 12:01 ` Long Li
2022-10-22 21:16 ` Dave Chinner
2022-10-24 4:07 ` Darrick J. Wong
2022-10-24 5:43 ` Dave Chinner
2022-10-24 12:28 ` Long Li
2022-10-24 5:06 ` Long Li
2022-10-25 9:15 ` [PATCH v2] " Long Li
2022-10-25 18:16 ` Darrick J. Wong
2022-10-26 9:13 ` Long Li
2022-10-26 18:52 ` Darrick J. Wong
2022-10-27 13:25 ` Long Li
2022-10-27 16:05 ` Darrick J. Wong
2022-10-29 7:16 ` Long Li
2022-10-30 22:04 ` Dave Chinner [this message]
2022-10-31 14:17 ` Long Li
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=20221030220441.GH3600936@dread.disaster.area \
--to=david@fromorbit.com \
--cc=billodo@redhat.com \
--cc=chandan.babu@oracle.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=guoxuenan@huawei.com \
--cc=houtao1@huawei.com \
--cc=leo.lilong@huawei.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=yi.zhang@huawei.com \
/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