linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 09/15] xfs: remove XFS_BMAP_MAX_SHIFT_EXTENTS
Date: Fri, 20 Oct 2017 17:10:28 -0700	[thread overview]
Message-ID: <20171021001028.GC4755@magnolia> (raw)
In-Reply-To: <20171019065942.18813-10-hch@lst.de>

On Thu, Oct 19, 2017 at 08:59:36AM +0200, Christoph Hellwig wrote:
> The define was always set to 1, which means looping until we reach is
> was dead code from the start.
> 
> Also remove an initialization of next_fsb for the done case that doesn't
> fit the new code flow - it was never checked by the caller in the done
> case to start with.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_bmap.c | 47 ++++++++++++++++++++---------------------------
>  fs/xfs/libxfs/xfs_bmap.h | 12 +-----------
>  fs/xfs/xfs_bmap_util.c   | 14 ++------------
>  3 files changed, 23 insertions(+), 50 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 22e7578e5696..89ea8a5235c0 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -5692,8 +5692,7 @@ xfs_bmse_shift_one(
>  /*
>   * Shift extent records to the left/right to cover/create a hole.
>   *
> - * The maximum number of extents to be shifted in a single operation is
> - * @num_exts. @stop_fsb specifies the file offset at which to stop shift and the
> + * @stop_fsb specifies the file offset at which to stop shift and the
>   * file offset where we've left off is returned in @next_fsb. @offset_shift_fsb
>   * is the length by which each extent is shifted. If there is no hole to shift
>   * the extents into, this will be considered invalid operation and we abort
> @@ -5709,14 +5708,12 @@ xfs_bmap_shift_extents(
>  	xfs_fileoff_t		stop_fsb,
>  	xfs_fsblock_t		*firstblock,
>  	struct xfs_defer_ops	*dfops,
> -	enum shift_direction	direction,
> -	int			num_exts)
> +	enum shift_direction	direction)
>  {
>  	struct xfs_btree_cur		*cur = NULL;
>  	struct xfs_bmbt_irec            got;
>  	struct xfs_mount		*mp = ip->i_mount;
>  	struct xfs_ifork		*ifp;
> -	xfs_extnum_t			nexts = 0;
>  	xfs_extnum_t			current_ext;
>  	xfs_extnum_t			total_extents;
>  	xfs_extnum_t			stop_extent;
> @@ -5814,31 +5811,27 @@ xfs_bmap_shift_extents(
>  		}
>  	}
>  
> -	while (nexts++ < num_exts) {
> -		error = xfs_bmse_shift_one(ip, whichfork, offset_shift_fsb,
> -					   &current_ext, &got, cur, &logflags,
> -					   direction, dfops);
> -		if (error)
> -			goto del_cursor;
> -		/*
> -		 * If there was an extent merge during the shift, the extent
> -		 * count can change. Update the total and grade the next record.
> -		 */
> -		if (direction == SHIFT_LEFT) {
> -			total_extents = xfs_iext_count(ifp);
> -			stop_extent = total_extents;
> -		}
> +	error = xfs_bmse_shift_one(ip, whichfork, offset_shift_fsb,
> +				   &current_ext, &got, cur, &logflags,
> +				   direction, dfops);
> +	if (error)
> +		goto del_cursor;
> +	/*
> +	 * If there was an extent merge during the shift, the extent
> +	 * count can change. Update the total and grade the next record.

/me wonders what "grade the next record" means, but afaict this comment
disappears anyway...

--D

> +	 */
> +	if (direction == SHIFT_LEFT) {
> +		total_extents = xfs_iext_count(ifp);
> +		stop_extent = total_extents;
> +	}
>  
> -		if (current_ext == stop_extent) {
> -			*done = 1;
> -			*next_fsb = NULLFSBLOCK;
> -			break;
> -		}
> -		xfs_iext_get_extent(ifp, current_ext, &got);
> +	if (current_ext == stop_extent) {
> +		*done = 1;
> +		goto del_cursor;
>  	}
> +	xfs_iext_get_extent(ifp, current_ext, &got);
>  
> -	if (!*done)
> -		*next_fsb = got.br_startoff;
> +	*next_fsb = got.br_startoff;
>  
>  del_cursor:
>  	if (cur)
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index c837e88ba19a..985b1c26566a 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -183,15 +183,6 @@ static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec)
>  		!isnullstartblock(irec->br_startblock);
>  }
>  
> -/*
> - * This macro is used to determine how many extents will be shifted
> - * in one write transaction. We could require two splits,
> - * an extent move on the first and an extent merge on the second,
> - * So it is proper that one extent is shifted inside write transaction
> - * at a time.
> - */
> -#define XFS_BMAP_MAX_SHIFT_EXTENTS	1
> -
>  enum shift_direction {
>  	SHIFT_LEFT = 0,
>  	SHIFT_RIGHT,
> @@ -239,8 +230,7 @@ uint	xfs_default_attroffset(struct xfs_inode *ip);
>  int	xfs_bmap_shift_extents(struct xfs_trans *tp, struct xfs_inode *ip,
>  		xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
>  		int *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock,
> -		struct xfs_defer_ops *dfops, enum shift_direction direction,
> -		int num_exts);
> +		struct xfs_defer_ops *dfops, enum shift_direction direction);
>  int	xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset);
>  int	xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
>  		xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 47b53c88de7c..3273f083c496 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1359,14 +1359,9 @@ xfs_collapse_file_space(
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  
>  		xfs_defer_init(&dfops, &first_block);
> -
> -		/*
> -		 * We are using the write transaction in which max 2 bmbt
> -		 * updates are allowed
> -		 */
>  		error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb,
>  				&done, stop_fsb, &first_block, &dfops,
> -				SHIFT_LEFT, XFS_BMAP_MAX_SHIFT_EXTENTS);
> +				SHIFT_LEFT);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> @@ -1438,14 +1433,9 @@ xfs_insert_file_space(
>  		xfs_ilock(ip, XFS_ILOCK_EXCL);
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  		xfs_defer_init(&dfops, &first_block);
> -
> -		/*
> -		 * We are using the write transaction in which max 2 bmbt
> -		 * updates are allowed
> -		 */
>  		error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb,
>  				&done, stop_fsb, &first_block, &dfops,
> -				SHIFT_RIGHT, XFS_BMAP_MAX_SHIFT_EXTENTS);
> +				SHIFT_RIGHT);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> -- 
> 2.14.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-10-21  0:10 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19  6:59 more extent mapping cleanups Christoph Hellwig
2017-10-19  6:59 ` [PATCH 01/15] xfs: add a xfs_bmap_fork_to_state helper Christoph Hellwig
2017-10-19 22:48   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 02/15] xfs: make better use of the 'state' variable in xfs_bmap_del_extent_real Christoph Hellwig
2017-10-19 22:49   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 03/15] xfs: remove post-bmap tracing in xfs_bmap_local_to_extents Christoph Hellwig
2017-10-19 22:49   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 04/15] xfs: move pre/post-bmap tracing into xfs_iext_update_extent Christoph Hellwig
2017-10-19 22:50   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 05/15] xfs: remove XFS_BMAP_TRACE_EXLIST Christoph Hellwig
2017-10-19 22:50   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 06/15] xfs: remove the never fully implemented UUID fork format Christoph Hellwig
2017-10-19 22:48   ` Darrick J. Wong
2017-10-20  7:02     ` Christoph Hellwig
2017-10-20 16:52       ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 07/15] xfs: remove if_rdev Christoph Hellwig
2017-10-19 22:52   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 08/15] xfs: inline xfs_shift_file_space into callers Christoph Hellwig
2017-10-21  0:07   ` Darrick J. Wong
2017-10-21  8:13     ` Christoph Hellwig
2017-10-21 18:06       ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 09/15] xfs: remove XFS_BMAP_MAX_SHIFT_EXTENTS Christoph Hellwig
2017-10-21  0:10   ` Darrick J. Wong [this message]
2017-10-19  6:59 ` [PATCH 10/15] xfs: split xfs_bmap_shift_extents Christoph Hellwig
2017-10-21  0:22   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 11/15] xfs: remove xfs_bmse_shift_one Christoph Hellwig
2017-10-21  0:25   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 12/15] xfs: update got in xfs_bmap_shift_update_extent Christoph Hellwig
2017-10-21  0:25   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 13/15] xfs: don't rely on extent indices in xfs_bmap_collapse_extents Christoph Hellwig
2017-10-21  0:26   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 14/15] xfs: don't rely on extent indices in xfs_bmap_insert_extents Christoph Hellwig
2017-10-21  0:27   ` Darrick J. Wong
2017-10-19  6:59 ` [PATCH 15/15] xfs: rewrite xfs_bmap_first_unused to make better use of xfs_iext_get_extent Christoph Hellwig
2017-10-21  0:27   ` Darrick J. Wong
2017-10-19 20:04 ` more extent mapping cleanups 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=20171021001028.GC4755@magnolia \
    --to=darrick.wong@oracle.com \
    --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;
as well as URLs for NNTP newsgroup(s).