public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org, david@fromorbit.com, hch@infradead.org
Subject: Re: [PATCH 03/16] xfs: detach dquots from inode if we don't need to inactivate it
Date: Mon, 14 Jun 2021 10:27:35 -0700	[thread overview]
Message-ID: <20210614172735.GM2945738@locust> (raw)
In-Reply-To: <YMeAOGklQwQDZdSM@bfoster>

On Mon, Jun 14, 2021 at 12:13:44PM -0400, Brian Foster wrote:
> On Sun, Jun 13, 2021 at 10:20:13AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > If we don't need to inactivate an inode, we can detach the dquots and
> > move on to reclamation.  This isn't strictly required here; it's a
> > preparation patch for deferred inactivation.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> 
> Seems functional, but a little more explanation on why we're doing this
> might be helpful. Otherwise it's not really clear why we'd duplicate a
> bunch of this logic (as opposed to refactor it), if we want to leave
> around the obvious maintenance landmine, etc..?

<shrug> Dave asked me to break up the deferred inactivation patch so
that it would be shorter.  As you point out, this patch on its own is
unnecessary and a maintenance landmine, so there's really no
justification to keep it separate other than reviewer style comments.

I guess I could put /that/ in the commit message, though:

"If we don't need to inactivate an inode, we can detach the dquots and
move on to reclamation.  This isn't strictly required here; it's a
preparation patch for deferred inactivation per reviewer request[1] to
move the creation of xfs_inode_needs_inactivation into a separate
change.  Eventually this !need_inactive chunk will turn into the code
path for inodes that skip xfs_inactive and go straight to memory
reclaim.

"[1] https://lore.kernel.org/linux-xfs/20210609012838.GW2945738@locust/T/#mca6d958521cb88bbc1bfe1a30767203328d410b5"

--D

> Brian
> 
> >  fs/xfs/xfs_icache.c |    8 +++++++-
> >  fs/xfs/xfs_inode.c  |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  fs/xfs/xfs_inode.h  |    2 ++
> >  3 files changed, 62 insertions(+), 1 deletion(-)
> > 
> > 
> > diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> > index a2d81331867b..7939eced3a47 100644
> > --- a/fs/xfs/xfs_icache.c
> > +++ b/fs/xfs/xfs_icache.c
> > @@ -338,8 +338,14 @@ xfs_inode_mark_reclaimable(
> >  {
> >  	struct xfs_mount	*mp = ip->i_mount;
> >  	struct xfs_perag	*pag;
> > +	bool			need_inactive = xfs_inode_needs_inactive(ip);
> >  
> > -	xfs_inactive(ip);
> > +	if (!need_inactive) {
> > +		/* Going straight to reclaim, so drop the dquots. */
> > +		xfs_qm_dqdetach(ip);
> > +	} else {
> > +		xfs_inactive(ip);
> > +	}
> >  
> >  	if (!XFS_FORCED_SHUTDOWN(mp) && ip->i_delayed_blks) {
> >  		xfs_check_delalloc(ip, XFS_DATA_FORK);
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 3bee1cd20072..85b2b11b5217 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -1654,6 +1654,59 @@ xfs_inactive_ifree(
> >  	return 0;
> >  }
> >  
> > +/*
> > + * Returns true if we need to update the on-disk metadata before we can free
> > + * the memory used by this inode.  Updates include freeing post-eof
> > + * preallocations; freeing COW staging extents; and marking the inode free in
> > + * the inobt if it is on the unlinked list.
> > + */
> > +bool
> > +xfs_inode_needs_inactive(
> > +	struct xfs_inode	*ip)
> > +{
> > +	struct xfs_mount	*mp = ip->i_mount;
> > +	struct xfs_ifork	*cow_ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
> > +
> > +	/*
> > +	 * If the inode is already free, then there can be nothing
> > +	 * to clean up here.
> > +	 */
> > +	if (VFS_I(ip)->i_mode == 0)
> > +		return false;
> > +
> > +	/* If this is a read-only mount, don't do this (would generate I/O) */
> > +	if (mp->m_flags & XFS_MOUNT_RDONLY)
> > +		return false;
> > +
> > +	/* If the log isn't running, push inodes straight to reclaim. */
> > +	if (XFS_FORCED_SHUTDOWN(mp) || (mp->m_flags & XFS_MOUNT_NORECOVERY))
> > +		return false;
> > +
> > +	/* Metadata inodes require explicit resource cleanup. */
> > +	if (xfs_is_metadata_inode(ip))
> > +		return false;
> > +
> > +	/* Want to clean out the cow blocks if there are any. */
> > +	if (cow_ifp && cow_ifp->if_bytes > 0)
> > +		return true;
> > +
> > +	/* Unlinked files must be freed. */
> > +	if (VFS_I(ip)->i_nlink == 0)
> > +		return true;
> > +
> > +	/*
> > +	 * This file isn't being freed, so check if there are post-eof blocks
> > +	 * to free.  @force is true because we are evicting an inode from the
> > +	 * cache.  Post-eof blocks must be freed, lest we end up with broken
> > +	 * free space accounting.
> > +	 *
> > +	 * Note: don't bother with iolock here since lockdep complains about
> > +	 * acquiring it in reclaim context. We have the only reference to the
> > +	 * inode at this point anyways.
> > +	 */
> > +	return xfs_can_free_eofblocks(ip, true);
> > +}
> > +
> >  /*
> >   * xfs_inactive
> >   *
> > diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> > index 4b6703dbffb8..e3137bbc7b14 100644
> > --- a/fs/xfs/xfs_inode.h
> > +++ b/fs/xfs/xfs_inode.h
> > @@ -493,6 +493,8 @@ extern struct kmem_zone	*xfs_inode_zone;
> >  /* The default CoW extent size hint. */
> >  #define XFS_DEFAULT_COWEXTSZ_HINT 32
> >  
> > +bool xfs_inode_needs_inactive(struct xfs_inode *ip);
> > +
> >  int xfs_iunlink_init(struct xfs_perag *pag);
> >  void xfs_iunlink_destroy(struct xfs_perag *pag);
> >  
> > 
> 

  reply	other threads:[~2021-06-14 17:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13 17:19 [PATCHSET v7 00/16] xfs: deferred inode inactivation Darrick J. Wong
2021-06-13 17:20 ` [PATCH 01/16] xfs: refactor the inode recycling code Darrick J. Wong
2021-06-16  8:13   ` Christoph Hellwig
2021-06-13 17:20 ` [PATCH 02/16] xfs: move xfs_inactive call to xfs_inode_mark_reclaimable Darrick J. Wong
2021-06-16  8:18   ` Christoph Hellwig
2021-06-13 17:20 ` [PATCH 03/16] xfs: detach dquots from inode if we don't need to inactivate it Darrick J. Wong
2021-06-14 16:13   ` Brian Foster
2021-06-14 17:27     ` Darrick J. Wong [this message]
2021-06-16  8:21   ` Christoph Hellwig
2021-06-13 17:20 ` [PATCH 04/16] xfs: clean up xfs_inactive a little bit Darrick J. Wong
2021-06-14 16:14   ` Brian Foster
2021-06-14 17:34     ` Darrick J. Wong
2021-06-16  8:23   ` Christoph Hellwig
2021-06-13 17:20 ` [PATCH 05/16] xfs: separate primary inode selection criteria in xfs_iget_cache_hit Darrick J. Wong
2021-06-14 16:14   ` Brian Foster
2021-06-16  8:26   ` Christoph Hellwig
2021-06-13 17:20 ` [PATCH 06/16] xfs: defer inode inactivation to a workqueue Darrick J. Wong
2021-06-14 16:17   ` Brian Foster
2021-06-14 19:27     ` Darrick J. Wong
2021-06-15 14:43       ` Brian Foster
2021-06-15 20:53         ` Darrick J. Wong
2021-06-17 14:23           ` Brian Foster
2021-06-17 18:41             ` Darrick J. Wong
2021-06-18 14:00               ` Brian Foster
2021-06-18 14:58                 ` Darrick J. Wong
2021-06-21  5:19                   ` Christoph Hellwig
2021-06-13 17:20 ` [PATCH 07/16] xfs: drop dead dquots before scheduling inode for inactivation Darrick J. Wong
2021-06-13 17:20 ` [PATCH 08/16] xfs: expose sysfs knob to control inode inactivation delay Darrick J. Wong
2021-06-13 17:20 ` [PATCH 09/16] xfs: reduce inactivation delay when things are tight Darrick J. Wong
2021-06-13 17:20 ` [PATCH 10/16] xfs: inactivate inodes any time we try to free speculative preallocations Darrick J. Wong
2021-06-13 17:20 ` [PATCH 11/16] xfs: flush inode inactivation work when compiling usage statistics Darrick J. Wong
2021-06-13 17:21 ` [PATCH 12/16] xfs: parallelize inode inactivation Darrick J. Wong
2021-06-13 17:21 ` [PATCH 13/16] xfs: don't run speculative preallocation gc when fs is frozen Darrick J. Wong
2021-06-13 17:21 ` [PATCH 14/16] xfs: scale speculative preallocation gc delay based on free space Darrick J. Wong
2021-06-13 17:21 ` [PATCH 15/16] xfs: use background worker pool when transactions can't get " Darrick J. Wong
2021-06-13 17:21 ` [PATCH 16/16] xfs: avoid buffer deadlocks when walking fs inodes Darrick J. Wong

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=20210614172735.GM2945738@locust \
    --to=djwong@kernel.org \
    --cc=bfoster@redhat.com \
    --cc=david@fromorbit.com \
    --cc=hch@infradead.org \
    --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