All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>,
	kaixuxia <xiakaixu1987@gmail.com>,
	linux-xfs@vger.kernel.org, newtongao@tencent.com,
	jasperwang@tencent.com
Subject: Re: [PATCH v2] xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename()
Date: Fri, 8 Nov 2019 06:48:38 -0500	[thread overview]
Message-ID: <20191108114838.GA24009@bfoster> (raw)
In-Reply-To: <20191107034621.GG4614@dread.disaster.area>

On Thu, Nov 07, 2019 at 02:46:21PM +1100, Dave Chinner wrote:
> On Wed, Nov 06, 2019 at 07:46:12AM -0800, Darrick J. Wong wrote:
> > On Wed, Nov 06, 2019 at 07:49:32AM -0500, Brian Foster wrote:
> > > > >  /*
> > > > > + * Check whether the replace operation need more blocks.
> > > > > + */
> > > > > +bool
> > > > > +xfs_dir2_sf_replace_needblock(
> > > > 
> > > > Urgggh.  This is a predicate that we only ever call from xfs_rename(),
> > > > right?  And it addresses a particular quirk of the locking when the
> > > > caller wants us to rename on top of an existing entry and drop the link
> > > > count of the old inode, right?  So why can't this just be a predicate in
> > > > xfs_inode.c ?  Nobody else needs to know this particular piece of
> > > > information, AFAICT.
> > > > 
> > > > (Apologies, for Brian and I clearly aren't on the same page about
> > > > that...)
> > > > 
> > > 
> > > Hmm.. the crux of my feedback on the previous version was simply that if
> > > we wanted to take this approach of pulling up lower level dir logic into
> > > the higher level rename code, to simply factor out the existing checks
> > > down in the dir replace code that currently trigger a format conversion,
> > > and use that new helper in both places. That doesn't appear to be what
> > > this patch does, and I'm not sure why there are now two new helpers that
> > > each only have one caller instead of one new helper with two callers...
> > 
> > Aha, got it.  I'd wondered if that had been your intent. :)
> 
> So as a structural question: should this be folded into
> xfs_dir_canenter(), which is the function used to check if the
> directory modification can go ahead without allocating blocks....
> 
> This seems very much like it is a "do we need to allocate blocks
> during the directory modification?" sort of question being asked
> here...
> 

I _think_ Kaixu brought this up briefly in looking at the previous
version of this patch. From a code standpoint, I agree that this path
seems like the most logical fit, but my understanding was that the
canenter thing is kind of an inconsistent and unreliable mechanism at
this point. IIRC, we've explicitly removed its use from the create path
to work around things like block reservation overruns leading to fs
shutdowns as opposed to digging into the mechanism and fixing whatever
accounting was broken. See commit f59cf5c299 ("xfs: remove
"no-allocation" reservations for file creations"), for example. I
believe the discussion around that patch basically concluded that the
complexity of maintaining/debugging the canenter path wasn't worth the
benefit of squeezing every last block out of the fs, but that was a
while ago now.

That aside, I don't have a strong opinion on the best way to fix this
particular deadlock problem. The only other thing (outside of
reliability) I might question with the canenter approach is whether it
has ever been used in situations outside of -ENOSPC, and if not, whether
there's any potential performance impact of invoking it more frequently.

Brian

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com


  reply	other threads:[~2019-11-08 11:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05  9:52 [PATCH v2] xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename() kaixuxia
2019-11-06  4:56 ` Darrick J. Wong
2019-11-06 12:49   ` Brian Foster
2019-11-06 15:46     ` Darrick J. Wong
2019-11-07  3:46       ` Dave Chinner
2019-11-08 11:48         ` Brian Foster [this message]
2019-11-07  5:15   ` 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=20191108114838.GA24009@bfoster \
    --to=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.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 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.