From: Dave Chinner <david@fromorbit.com>
To: kaixuxia <xiakaixu1987@gmail.com>
Cc: linux-xfs@vger.kernel.org,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Brian Foster <bfoster@redhat.com>,
newtongao@tencent.com, jasperwang@tencent.com
Subject: Re: [PATCH v4] xfs: Fix agi&agf ABBA deadlock when performing rename with RENAME_WHITEOUT flag
Date: Thu, 22 Aug 2019 16:06:48 +1000 [thread overview]
Message-ID: <20190822060648.GX1119@dread.disaster.area> (raw)
In-Reply-To: <3d6e190f-f88e-ef75-8dc1-9b0958706e38@gmail.com>
On Thu, Aug 22, 2019 at 01:45:48PM +0800, kaixuxia wrote:
> On 2019/8/22 13:01, Dave Chinner wrote:
> > On Thu, Aug 22, 2019 at 12:33:23PM +0800, kaixuxia wrote:
> >
> >> @@ -3419,25 +3431,15 @@ struct xfs_iunlink {
> >>
> >> /*
> >> * For whiteouts, we need to bump the link count on the whiteout inode.
> >
> > Shouldn't this line be removed as well?
>
> Because the xfs_bumplink() call below will do this.
Oh, yeah, I just assumed that from the "we have a real link" part of
the new comment :P
> >> - * This means that failures all the way up to this point leave the inode
> >> - * on the unlinked list and so cleanup is a simple matter of dropping
> >> - * the remaining reference to it. If we fail here after bumping the link
> >> - * count, we're shutting down the filesystem so we'll never see the
> >> - * intermediate state on disk.
> >> + * The whiteout inode has been removed from the unlinked list and log
> >> + * recovery will clean up the mess for the failures up to this point.
> >> + * After this point we have a real link, clear the tmpfile state flag
> >> + * from the inode so it doesn't accidentally get misused in future.
> >> */
> >> if (wip) {
> >> ASSERT(VFS_I(wip)->i_nlink == 0);
> >> xfs_bumplink(tp, wip);
> >> - error = xfs_iunlink_remove(tp, wip);
> >> - if (error)
> >> - goto out_trans_cancel;
> >> xfs_trans_log_inode(tp, wip, XFS_ILOG_CORE);
> >> -
> >> - /*
> >> - * Now we have a real link, clear the "I'm a tmpfile" state
> >> - * flag from the inode so it doesn't accidentally get misused in
> >> - * future.
> >> - */
> >> VFS_I(wip)->i_state &= ~I_LINKABLE;
> >> }
> >
> > Why not move all this up into the same branch that removes the
> > whiteout from the unlinked list? Why separate this logic as none of
> > what is left here could cause a failure even if it is run earlier?
>
> Yep, it could not cause a failure if we move all this into the same
> branch that xfs_iunlink_remove() call. We move the xfs_iunlink_remove()
> first to preserve correct AGI/AGF locking order, and maybe it is better
> we bump the link count after using the whiteout inode really, such as
> xfs_dir_replace(...,wip,...) ...
It makes no difference where we bump the link count as long as we do
it after the xfs_iunlink_remove() call. At that point, any failure
will result in a shutdown and so it doesn't matter that we've
already bumped the link count because the shutdown with prevent
it from reaching the disk...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2019-08-22 6:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 4:33 [PATCH v4] xfs: Fix agi&agf ABBA deadlock when performing rename with RENAME_WHITEOUT flag kaixuxia
2019-08-22 5:01 ` Dave Chinner
2019-08-22 5:45 ` kaixuxia
2019-08-22 6:06 ` Dave Chinner [this message]
2019-08-22 6:36 ` kaixuxia
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=20190822060648.GX1119@dread.disaster.area \
--to=david@fromorbit.com \
--cc=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=jasperwang@tencent.com \
--cc=linux-xfs@vger.kernel.org \
--cc=newtongao@tencent.com \
--cc=xiakaixu1987@gmail.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