All of lore.kernel.org
 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 14/21] xfs: simplify xfs_reflink_convert_cow
Date: Fri, 3 Nov 2017 09:55:07 -0700	[thread overview]
Message-ID: <20171103165507.GO4911@magnolia> (raw)
In-Reply-To: <20171103144539.2187-15-hch@lst.de>

On Fri, Nov 03, 2017 at 05:45:32PM +0300, Christoph Hellwig wrote:
> Instead of looking up extents to convert and calling xfs_bmapi_write on
> each of them just let xfs_bmapi_write handle the full range.  To make
> this robust add a new XFS_BMAPI_CONVERT_ONLY that only converts ranges
> and never allocates blocks.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_bmap.c |  3 ++-
>  fs/xfs/libxfs/xfs_bmap.h |  6 +++++-
>  fs/xfs/xfs_reflink.c     | 29 +++++++++++------------------
>  3 files changed, 18 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index b08c4863c2af..8fcb186341ce 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4331,7 +4331,8 @@ xfs_bmapi_write(
>  		 * First, deal with the hole before the allocated space
>  		 * that we found, if any.
>  		 */
> -		if (need_alloc || wasdelay) {
> +		if ((need_alloc || wasdelay) &&
> +		    !(flags & XFS_BMAPI_CONVERT_ONLY)) {
>  			bma.eof = eof;
>  			bma.conv = !!(flags & XFS_BMAPI_CONVERT);
>  			bma.wasdel = wasdelay;
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index b6a395949d0c..eaf975eb35f8 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -113,6 +113,9 @@ struct xfs_extent_free_item
>  /* Only convert delalloc space, don't allocate entirely new extents */
>  #define XFS_BMAPI_DELALLOC	0x400
>  
> +/* Only convert unwritten extents, don't allocate new blocks */
> +#define XFS_BMAPI_CONVERT_ONLY	0x800
> +
>  #define XFS_BMAPI_FLAGS \
>  	{ XFS_BMAPI_ENTIRE,	"ENTIRE" }, \
>  	{ XFS_BMAPI_METADATA,	"METADATA" }, \
> @@ -124,7 +127,8 @@ struct xfs_extent_free_item
>  	{ XFS_BMAPI_ZERO,	"ZERO" }, \
>  	{ XFS_BMAPI_REMAP,	"REMAP" }, \
>  	{ XFS_BMAPI_COWFORK,	"COWFORK" }, \
> -	{ XFS_BMAPI_DELALLOC,	"DELALLOC" }
> +	{ XFS_BMAPI_DELALLOC,	"DELALLOC" }, \
> +	{ XFS_BMAPI_CONVERT_ONLY, "XFS_BMAPI_CONVERT_ONLY" }

"CONVERT_ONLY" to be consistent with the other flag strings?
I can fix this on the way in.

Otherwise,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

>  
>  
>  static inline int xfs_bmapi_aflag(int w)
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index cf976ed65260..cc041a29eb70 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -353,29 +353,22 @@ xfs_reflink_convert_cow(
>  	xfs_off_t		offset,
>  	xfs_off_t		count)
>  {
> -	struct xfs_bmbt_irec	got;
> -	struct xfs_defer_ops	dfops;
>  	struct xfs_mount	*mp = ip->i_mount;
> -	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
>  	xfs_fileoff_t		offset_fsb = XFS_B_TO_FSBT(mp, offset);
>  	xfs_fileoff_t		end_fsb = XFS_B_TO_FSB(mp, offset + count);
> -	struct xfs_iext_cursor	icur;
> -	bool			found;
> -	int			error = 0;
> -
> -	xfs_ilock(ip, XFS_ILOCK_EXCL);
> +	xfs_filblks_t		count_fsb = end_fsb - offset_fsb;
> +	struct xfs_bmbt_irec	imap;
> +	struct xfs_defer_ops	dfops;
> +	xfs_fsblock_t		first_block = NULLFSBLOCK;
> +	int			nimaps = 1, error = 0;
>  
> -	/* Convert all the extents to real from unwritten. */
> -	for (found = xfs_iext_lookup_extent(ip, ifp, offset_fsb, &icur, &got);
> -	     found && got.br_startoff < end_fsb;
> -	     found = xfs_iext_next_extent(ifp, &icur, &got)) {
> -		error = xfs_reflink_convert_cow_extent(ip, &got, offset_fsb,
> -				end_fsb - offset_fsb, &dfops);
> -		if (error)
> -			break;
> -	}
> +	ASSERT(count != 0);
>  
> -	/* Finish up. */
> +	xfs_ilock(ip, XFS_ILOCK_EXCL);
> +	error = xfs_bmapi_write(NULL, ip, offset_fsb, count_fsb,
> +			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT |
> +			XFS_BMAPI_CONVERT_ONLY, &first_block, 0, &imap, &nimaps,
> +			&dfops);
>  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
>  	return error;
>  }
> -- 
> 2.14.2
> 
> --
> 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-11-03 16:55 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 14:45 b+tree for the incore extent list V2 Christoph Hellwig
2017-11-03 14:45 ` [PATCH 01/21] xfs: don't create overlapping extents in xfs_bmap_add_extent_delay_real Christoph Hellwig
2017-11-03 14:45 ` [PATCH 02/21] xfs: remove a duplicate assignment " Christoph Hellwig
2017-11-03 15:18   ` Brian Foster
2017-11-03 16:32   ` Darrick J. Wong
2017-11-03 14:45 ` [PATCH 03/21] xfs: treat idx as a cursor " Christoph Hellwig
2017-11-03 14:45 ` [PATCH 04/21] xfs: treat idx as a cursor in xfs_bmap_add_extent_hole_delay Christoph Hellwig
2017-11-03 14:45 ` [PATCH 05/21] xfs: treat idx as a cursor in xfs_bmap_add_extent_hole_real Christoph Hellwig
2017-11-03 14:45 ` [PATCH 06/21] xfs: treat idx as a cursor in xfs_bmap_add_extent_unwritten_real Christoph Hellwig
2017-11-03 14:45 ` [PATCH 07/21] xfs: treat idx as a cursor in xfs_bmap_del_extent_* Christoph Hellwig
2017-11-03 14:45 ` [PATCH 08/21] xfs: treat idx as a cursor in xfs_bmap_collapse_extents Christoph Hellwig
2017-11-03 14:45 ` [PATCH 09/21] xfs: pass an on-disk extent to xfs_bmbt_validate_extent Christoph Hellwig
2017-11-03 15:18   ` Brian Foster
2017-11-03 16:33   ` Darrick J. Wong
2017-11-03 14:45 ` [PATCH 10/21] xfs: iterate over extents in xfs_iextents_copy Christoph Hellwig
2017-11-03 14:45 ` [PATCH 11/21] xfs: iterate over extents in xfs_bmap_extents_to_btree Christoph Hellwig
2017-11-03 14:45 ` [PATCH 12/21] xfs: introduce the xfs_iext_cursor abstraction Christoph Hellwig
2017-11-03 15:18   ` Brian Foster
2017-11-03 17:06   ` Darrick J. Wong
2017-11-03 14:45 ` [PATCH 13/21] xfs: iterate backwards in xfs_reflink_cancel_cow_blocks Christoph Hellwig
2017-11-03 16:52   ` Darrick J. Wong
2017-11-03 14:45 ` [PATCH 14/21] xfs: simplify xfs_reflink_convert_cow Christoph Hellwig
2017-11-03 16:55   ` Darrick J. Wong [this message]
2017-11-06  8:47     ` Christoph Hellwig
2017-11-03 14:45 ` [PATCH 15/21] xfs: remove support for inlining data/extents into the inode fork Christoph Hellwig
2017-11-03 16:55   ` Darrick J. Wong
2017-11-03 14:45 ` [PATCH 16/21] xfs: allow unaligned extent records in xfs_bmbt_disk_set_all Christoph Hellwig
2017-11-03 14:45 ` [PATCH 17/21] xfs: use a b+tree for the in-core extent list Christoph Hellwig
2017-11-03 17:35   ` Darrick J. Wong
2017-11-08 13:50   ` Brian Foster
2017-11-08 17:19     ` Christoph Hellwig
2017-11-03 14:45 ` [PATCH 18/21] xfs: remove the nr_extents argument to xfs_iext_insert Christoph Hellwig
2017-11-03 14:45 ` [PATCH 19/21] xfs: remove the nr_extents argument to xfs_iext_remove Christoph Hellwig
2017-11-03 14:45 ` [PATCH 20/21] xfs: pass struct xfs_bmbt_irec to xfs_bmbt_validate_extent Christoph Hellwig
2017-11-03 16:41   ` Darrick J. Wong
2017-11-03 14:45 ` [PATCH 21/21] xfs: move xfs_bmbt_irec and xfs_exntst_t to xfs_types.h Christoph Hellwig
2017-11-03 16:38   ` 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=20171103165507.GO4911@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 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.