All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 07/12] xfs: refactor eofblocks inode match code
Date: Thu, 17 Jan 2019 10:05:15 -0800	[thread overview]
Message-ID: <20190117180515.GD4424@magnolia> (raw)
In-Reply-To: <c645b822-405e-cc3a-15e1-62a099e300b2@suse.com>

On Wed, Jan 02, 2019 at 11:50:58AM +0200, Nikolay Borisov wrote:
> 
> 
> On 1.01.19 г. 4:17 ч., Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Refactor the code that determines if an inode matches an eofblocks
> > structure into a helper, since we already use it twice and we're about
> > to use it a third time.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  fs/xfs/xfs_icache.c |  146 ++++++++++++++++++++++++++-------------------------
> >  1 file changed, 74 insertions(+), 72 deletions(-)
> > 
> > 
> > diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> > index 7e031eb6f048..c1b457ba1b7b 100644
> > --- a/fs/xfs/xfs_icache.c
> > +++ b/fs/xfs/xfs_icache.c
> > @@ -27,6 +27,76 @@
> >  #include <linux/freezer.h>
> >  #include <linux/iversion.h>
> >  
> > +STATIC int
> > +xfs_inode_match_id(
> 
> This is a predicate so make it bool
> 
> > +	struct xfs_inode	*ip,
> > +	struct xfs_eofblocks	*eofb)
> > +{
> > +	if ((eofb->eof_flags & XFS_EOF_FLAGS_UID) &&
> > +	    !uid_eq(VFS_I(ip)->i_uid, eofb->eof_uid))
> > +		return 0;
> > +
> > +	if ((eofb->eof_flags & XFS_EOF_FLAGS_GID) &&
> > +	    !gid_eq(VFS_I(ip)->i_gid, eofb->eof_gid))
> > +		return 0;
> > +
> > +	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
> > +	    xfs_get_projid(ip) != eofb->eof_prid)
> > +		return 0;
> > +
> > +	return 1;
> > +}
> > +
> > +/*
> > + * A union-based inode filtering algorithm. Process the inode if any of the
> > + * criteria match. This is for global/internal scans only.
> > + */
> > +STATIC int
> 
> ditto

The originals returned int, but sure, I'll convert them to bool.

--D

> > +xfs_inode_match_id_union(
> > +	struct xfs_inode	*ip,
> > +	struct xfs_eofblocks	*eofb)
> > +{
> > +	if ((eofb->eof_flags & XFS_EOF_FLAGS_UID) &&
> > +	    uid_eq(VFS_I(ip)->i_uid, eofb->eof_uid))
> > +		return 1;
> > +
> > +	if ((eofb->eof_flags & XFS_EOF_FLAGS_GID) &&
> > +	    gid_eq(VFS_I(ip)->i_gid, eofb->eof_gid))
> > +		return 1;
> > +
> > +	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
> > +	    xfs_get_projid(ip) == eofb->eof_prid)
> > +		return 1;
> > +
> > +	return 0;
> > +}
> > +
> > +/* Does this inode match the given parameters? */
> > +STATIC bool
> > +xfs_inode_matches_eofb(
> > +	struct xfs_inode	*ip,
> > +	struct xfs_eofblocks	*eofb)
> > +{
> > +	int			match;
> > +
> > +	if (!eofb)
> > +		return true;
> > +
> > +	if (eofb->eof_flags & XFS_EOF_FLAGS_UNION)
> > +		match = xfs_inode_match_id_union(ip, eofb);
> > +	else
> > +		match = xfs_inode_match_id(ip, eofb);
> > +	if (!match)
> > +		return false;
> > +
> > +	/* skip the inode if the file size is too small */
> > +	if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&
> > +	    XFS_ISIZE(ip) < eofb->eof_min_file_size)
> > +		return false;
> > +
> > +	return true;
> > +}
> > +
> >  /*
> >   * Allocate and initialise an xfs_inode.
> >   */
> > @@ -1424,50 +1494,6 @@ xfs_reclaim_inodes_count(
> >  	return reclaimable;
> >  }
> >  
> > -STATIC int
> > -xfs_inode_match_id(
> > -	struct xfs_inode	*ip,
> > -	struct xfs_eofblocks	*eofb)
> > -{
> > -	if ((eofb->eof_flags & XFS_EOF_FLAGS_UID) &&
> > -	    !uid_eq(VFS_I(ip)->i_uid, eofb->eof_uid))
> > -		return 0;
> > -
> > -	if ((eofb->eof_flags & XFS_EOF_FLAGS_GID) &&
> > -	    !gid_eq(VFS_I(ip)->i_gid, eofb->eof_gid))
> > -		return 0;
> > -
> > -	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
> > -	    xfs_get_projid(ip) != eofb->eof_prid)
> > -		return 0;
> > -
> > -	return 1;
> > -}
> > -
> > -/*
> > - * A union-based inode filtering algorithm. Process the inode if any of the
> > - * criteria match. This is for global/internal scans only.
> > - */
> > -STATIC int
> > -xfs_inode_match_id_union(
> > -	struct xfs_inode	*ip,
> > -	struct xfs_eofblocks	*eofb)
> > -{
> > -	if ((eofb->eof_flags & XFS_EOF_FLAGS_UID) &&
> > -	    uid_eq(VFS_I(ip)->i_uid, eofb->eof_uid))
> > -		return 1;
> > -
> > -	if ((eofb->eof_flags & XFS_EOF_FLAGS_GID) &&
> > -	    gid_eq(VFS_I(ip)->i_gid, eofb->eof_gid))
> > -		return 1;
> > -
> > -	if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) &&
> > -	    xfs_get_projid(ip) == eofb->eof_prid)
> > -		return 1;
> > -
> > -	return 0;
> > -}
> > -
> >  STATIC int
> >  xfs_inode_free_eofblocks(
> >  	struct xfs_inode	*ip,
> > @@ -1476,7 +1502,6 @@ xfs_inode_free_eofblocks(
> >  {
> >  	int ret = 0;
> >  	struct xfs_eofblocks *eofb = args;
> > -	int match;
> >  
> >  	if (!xfs_can_free_eofblocks(ip, false)) {
> >  		/* inode could be preallocated or append-only */
> > @@ -1493,19 +1518,8 @@ xfs_inode_free_eofblocks(
> >  	    mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY))
> >  		return 0;
> >  
> > -	if (eofb) {
> > -		if (eofb->eof_flags & XFS_EOF_FLAGS_UNION)
> > -			match = xfs_inode_match_id_union(ip, eofb);
> > -		else
> > -			match = xfs_inode_match_id(ip, eofb);
> > -		if (!match)
> > -			return 0;
> > -
> > -		/* skip the inode if the file size is too small */
> > -		if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&
> > -		    XFS_ISIZE(ip) < eofb->eof_min_file_size)
> > -			return 0;
> > -	}
> > +	if (!xfs_inode_matches_eofb(ip, eofb))
> > +		return 0;
> >  
> >  	/*
> >  	 * If the caller is waiting, return -EAGAIN to keep the background
> > @@ -1766,25 +1780,13 @@ xfs_inode_free_cowblocks(
> >  {
> >  	struct xfs_eofblocks	*eofb = args;
> >  	uint			lock_mode = 0;
> > -	int			match;
> >  	int			ret = 0;
> >  
> >  	if (!xfs_prep_free_cowblocks(ip))
> >  		return 0;
> >  
> > -	if (eofb) {
> > -		if (eofb->eof_flags & XFS_EOF_FLAGS_UNION)
> > -			match = xfs_inode_match_id_union(ip, eofb);
> > -		else
> > -			match = xfs_inode_match_id(ip, eofb);
> > -		if (!match)
> > -			return 0;
> > -
> > -		/* skip the inode if the file size is too small */
> > -		if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&
> > -		    XFS_ISIZE(ip) < eofb->eof_min_file_size)
> > -			return 0;
> > -	}
> > +	if (!xfs_inode_matches_eofb(ip, eofb))
> > +		return 0;
> >  
> >  	/*
> >  	 * Free the CoW blocks.  We don't need to lock the inode if we're in
> > 
> > 

  reply	other threads:[~2019-01-17 18:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01  2:16 [PATCH 00/12] xfs: deferred inode inactivation Darrick J. Wong
2019-01-01  2:16 ` [PATCH 01/12] xfs: free COW staging extents when freezing filesystem Darrick J. Wong
2019-01-11 16:28   ` Brian Foster
2019-01-17 17:24     ` Darrick J. Wong
2019-01-17 18:14       ` Brian Foster
2019-01-17 20:20         ` Darrick J. Wong
2019-01-01  2:17 ` [PATCH 02/12] xfs: refactor the predicate part of xfs_free_eofblocks Darrick J. Wong
2019-01-11 19:05   ` Brian Foster
2019-01-17 17:33     ` Darrick J. Wong
2019-01-01  2:17 ` [PATCH 03/12] xfs: decide if inode needs inactivation Darrick J. Wong
2019-01-01  2:17 ` [PATCH 04/12] xfs: track unlinked inactive inode fs summary counters Darrick J. Wong
2019-01-01  2:17 ` [PATCH 05/12] xfs: track unlinked inactive inode quota counters Darrick J. Wong
2019-01-01  2:17 ` [PATCH 06/12] xfs: refactor walking of per-AG RECLAIM inodes Darrick J. Wong
2019-01-11 19:06   ` Brian Foster
2019-01-17 17:43     ` Darrick J. Wong
2019-01-01  2:17 ` [PATCH 07/12] xfs: refactor eofblocks inode match code Darrick J. Wong
2019-01-02  9:50   ` Nikolay Borisov
2019-01-17 18:05     ` Darrick J. Wong [this message]
2019-01-01  2:17 ` [PATCH 08/12] xfs: deferred inode inactivation Darrick J. Wong
2019-01-01  2:17 ` [PATCH 09/12] xfs: retry fs writes when there isn't space Darrick J. Wong
2019-01-01  2:17 ` [PATCH 10/12] xfs: force inactivation before fallocate when space is low Darrick J. Wong
2019-01-01  2:17 ` [PATCH 11/12] xfs: parallelize inode inactivation Darrick J. Wong
2019-01-01  2:18 ` [PATCH 12/12] xfs: wait for deferred inactivation when destroying unlinked inodes Darrick J. Wong
2019-01-03 12:46   ` Dave Chinner
2019-01-17 18:41     ` Darrick J. Wong
2019-01-17 22:21       ` Dave Chinner

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=20190117180515.GD4424@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nborisov@suse.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.