From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org, hch@lst.de, dchinner@redhat.com,
christian.brauner@ubuntu.com
Subject: Re: [PATCH 3/4] xfs: force log and push AIL to clear pinned inodes when aborting mount
Date: Mon, 8 Mar 2021 10:01:23 +1100 [thread overview]
Message-ID: <20210307230123.GY4662@dread.disaster.area> (raw)
In-Reply-To: <161514875722.698643.971171271199400538.stgit@magnolia>
On Sun, Mar 07, 2021 at 12:25:57PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> If we allocate quota inodes in the process of mounting a filesystem but
> then decide to abort the mount, it's possible that the quota inodes are
> sitting around pinned by the log. Now that inode reclaim relies on the
> AIL to flush inodes, we have to force the log and push the AIL in
> between releasing the quota inodes and kicking off reclaim to tear down
> all the incore inodes. Do this by extracting the bits we need from the
> unmount path and reusing them.
>
> This was originally found during a fuzz test of metadata directories
> (xfs/1546), but the actual symptom was that reclaim hung up on the quota
> inodes.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
> fs/xfs/xfs_mount.c | 100 ++++++++++++++++++++++++++++------------------------
> 1 file changed, 54 insertions(+), 46 deletions(-)
Seems reasonable.
>
>
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 52370d0a3f43..556ce373145f 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -634,6 +634,57 @@ xfs_check_summary_counts(
> return xfs_initialize_perag_data(mp, mp->m_sb.sb_agcount);
> }
>
> +/*
> + * Force the log contents and checkpoint them into the filesystem, the reclaim
> + * inodes in preparation to unmount.
"then reclaim"
Ignoring the typo, the comment doesn't add anything useful - you're
saying what the function does, not why. I'd prefer you lift all the
comments in the code up into the header, explaining why each step
is needed/taken. Something like:
/*
* Flush and reclaim dirty inodes in preparation for unmount. Inodes and
* internal inode structures can be sitting in the CIL and AIL at this point, so
* we need to unpin them, write them back and/or reclaim them before unmount can
* proceed.
*
* An inode cluster that has been freed can have its buffer still pinned in
* memory because the transaction is still sitting in a iclog. The stale inodes
* on that buffer will be pinned to the buffer until the transaction hits the
* disk and the callbacks run. Pushing the AIL will skip the stale inodes and
* may never see the pinned buffer, so nothing will push out the iclog and unpin
* the buffer.
*
* Hence we need to force the log to unpin everything first. However, log forces
* don't wait for the discards they issue to complete, so we have to explicitly
* wait for them to complete here as well.
*
* Then we can tell the world we are unmounting so that error handling knows
* that the filesystem is going away and we should error out anything that we
* have been retrying in the background. This will prevent never-ending retries
* in AIL pushing from hanging the unmount.
*
* Finally, we can push the AIL to clean all the remaining dirty objects, then
* reclaim the remaining inodes that are still in memory at this point in
* time.
*/
static void
xfs_unmount_flush_inodes(
struct xfs_mount *mp)
{
xfs_log_force(mp, XFS_LOG_SYNC);
xfs_extent_busy_wait_all(mp);
flush_workqueue(xfs_discard_wq);
mp->m_flags |= XFS_MOUNT_UNMOUNTING;
xfs_ail_push_all_sync(mp->m_ail);
cancel_delayed_work_sync(&mp->m_reclaim_work);
xfs_reclaim_inodes(mp);
xfs_health_unmount(mp);
}
Everything else looks fine.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2021-03-07 23:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-07 20:25 [PATCHSET v2 0/4] xfs: small fixes for 5.12 Darrick J. Wong
2021-03-07 20:25 ` [PATCH 1/4] xfs: fix quota accounting when a mount is idmapped Darrick J. Wong
2021-03-07 22:28 ` Dave Chinner
2021-03-07 20:25 ` [PATCH 2/4] xfs: avoid buffer deadlocks when walking fs inodes Darrick J. Wong
2021-03-07 20:36 ` [PATCH v2.1 " Darrick J. Wong
2021-03-07 22:37 ` Dave Chinner
2021-03-08 3:56 ` Darrick J. Wong
2021-03-08 7:56 ` Christoph Hellwig
2021-03-07 20:25 ` [PATCH 3/4] xfs: force log and push AIL to clear pinned inodes when aborting mount Darrick J. Wong
2021-03-07 23:01 ` Dave Chinner [this message]
2021-03-08 4:47 ` Darrick J. Wong
2021-03-08 4:48 ` [PATCH v2.1 " Darrick J. Wong
2021-03-08 9:16 ` Christoph Hellwig
2021-03-08 23:42 ` Dave Chinner
2021-03-08 7:53 ` [PATCH " Christoph Hellwig
2021-03-07 20:26 ` [PATCH 4/4] xfs: drop freeze protection when running GETFSMAP Darrick J. Wong
2021-03-07 23:05 ` Dave Chinner
2021-03-08 4:45 ` Darrick J. Wong
2021-03-08 7:55 ` Christoph Hellwig
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=20210307230123.GY4662@dread.disaster.area \
--to=david@fromorbit.com \
--cc=christian.brauner@ubuntu.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--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