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 05/11] xfs: make xfs_bmbt_to_iomap more useful
Date: Tue, 18 Dec 2018 13:46:37 -0800	[thread overview]
Message-ID: <20181218214637.GO27208@magnolia> (raw)
In-Reply-To: <20181203222503.30649-6-hch@lst.de>

On Mon, Dec 03, 2018 at 05:24:57PM -0500, Christoph Hellwig wrote:
> Move checking for invalid zero blocks and setting of various iomap flags
> into this helper.  Also make it deal with "raw" delalloc extents to
> avoid clutter in the callers.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

--D

> ---
>  fs/xfs/xfs_iomap.c | 84 +++++++++++++++++++++-------------------------
>  fs/xfs/xfs_iomap.h |  4 +--
>  fs/xfs/xfs_pnfs.c  |  2 +-
>  3 files changed, 41 insertions(+), 49 deletions(-)
> 
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 6acfed2ae858..9f1fd224bb06 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -35,18 +35,40 @@
>  #define XFS_WRITEIO_ALIGN(mp,off)	(((off) >> mp->m_writeio_log) \
>  						<< mp->m_writeio_log)
>  
> -void
> +static int
> +xfs_alert_fsblock_zero(
> +	xfs_inode_t	*ip,
> +	xfs_bmbt_irec_t	*imap)
> +{
> +	xfs_alert_tag(ip->i_mount, XFS_PTAG_FSBLOCK_ZERO,
> +			"Access to block zero in inode %llu "
> +			"start_block: %llx start_off: %llx "
> +			"blkcnt: %llx extent-state: %x",
> +		(unsigned long long)ip->i_ino,
> +		(unsigned long long)imap->br_startblock,
> +		(unsigned long long)imap->br_startoff,
> +		(unsigned long long)imap->br_blockcount,
> +		imap->br_state);
> +	return -EFSCORRUPTED;
> +}
> +
> +int
>  xfs_bmbt_to_iomap(
>  	struct xfs_inode	*ip,
>  	struct iomap		*iomap,
> -	struct xfs_bmbt_irec	*imap)
> +	struct xfs_bmbt_irec	*imap,
> +	bool			shared)
>  {
>  	struct xfs_mount	*mp = ip->i_mount;
>  
> +	if (unlikely(!imap->br_startblock && !XFS_IS_REALTIME_INODE(ip)))
> +		return xfs_alert_fsblock_zero(ip, imap);
> +
>  	if (imap->br_startblock == HOLESTARTBLOCK) {
>  		iomap->addr = IOMAP_NULL_ADDR;
>  		iomap->type = IOMAP_HOLE;
> -	} else if (imap->br_startblock == DELAYSTARTBLOCK) {
> +	} else if (imap->br_startblock == DELAYSTARTBLOCK ||
> +		   isnullstartblock(imap->br_startblock)) {
>  		iomap->addr = IOMAP_NULL_ADDR;
>  		iomap->type = IOMAP_DELALLOC;
>  	} else {
> @@ -60,6 +82,13 @@ xfs_bmbt_to_iomap(
>  	iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount);
>  	iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip));
>  	iomap->dax_dev = xfs_find_daxdev_for_inode(VFS_I(ip));
> +
> +	if (xfs_ipincount(ip) &&
> +	    (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP))
> +		iomap->flags |= IOMAP_F_DIRTY;
> +	if (shared)
> +		iomap->flags |= IOMAP_F_SHARED;
> +	return 0;
>  }
>  
>  static void
> @@ -138,23 +167,6 @@ xfs_iomap_eof_align_last_fsb(
>  	return 0;
>  }
>  
> -STATIC int
> -xfs_alert_fsblock_zero(
> -	xfs_inode_t	*ip,
> -	xfs_bmbt_irec_t	*imap)
> -{
> -	xfs_alert_tag(ip->i_mount, XFS_PTAG_FSBLOCK_ZERO,
> -			"Access to block zero in inode %llu "
> -			"start_block: %llx start_off: %llx "
> -			"blkcnt: %llx extent-state: %x",
> -		(unsigned long long)ip->i_ino,
> -		(unsigned long long)imap->br_startblock,
> -		(unsigned long long)imap->br_startoff,
> -		(unsigned long long)imap->br_blockcount,
> -		imap->br_state);
> -	return -EFSCORRUPTED;
> -}
> -
>  int
>  xfs_iomap_write_direct(
>  	xfs_inode_t	*ip,
> @@ -649,17 +661,7 @@ xfs_file_iomap_begin_delay(
>  	iomap->flags |= IOMAP_F_NEW;
>  	trace_xfs_iomap_alloc(ip, offset, count, XFS_DATA_FORK, &got);
>  done:
> -	if (isnullstartblock(got.br_startblock))
> -		got.br_startblock = DELAYSTARTBLOCK;
> -
> -	if (!got.br_startblock) {
> -		error = xfs_alert_fsblock_zero(ip, &got);
> -		if (error)
> -			goto out_unlock;
> -	}
> -
> -	xfs_bmbt_to_iomap(ip, iomap, &got);
> -
> +	error = xfs_bmbt_to_iomap(ip, iomap, &got, false);
>  out_unlock:
>  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
>  	return error;
> @@ -1097,15 +1099,7 @@ xfs_file_iomap_begin(
>  	trace_xfs_iomap_alloc(ip, offset, length, XFS_DATA_FORK, &imap);
>  
>  out_finish:
> -	if (xfs_ipincount(ip) && (ip->i_itemp->ili_fsync_fields
> -				& ~XFS_ILOG_TIMESTAMP))
> -		iomap->flags |= IOMAP_F_DIRTY;
> -
> -	xfs_bmbt_to_iomap(ip, iomap, &imap);
> -
> -	if (shared)
> -		iomap->flags |= IOMAP_F_SHARED;
> -	return 0;
> +	return xfs_bmbt_to_iomap(ip, iomap, &imap, shared);
>  
>  out_found:
>  	ASSERT(nimaps);
> @@ -1228,12 +1222,10 @@ xfs_xattr_iomap_begin(
>  out_unlock:
>  	xfs_iunlock(ip, lockmode);
>  
> -	if (!error) {
> -		ASSERT(nimaps);
> -		xfs_bmbt_to_iomap(ip, iomap, &imap);
> -	}
> -
> -	return error;
> +	if (error)
> +		return error;
> +	ASSERT(nimaps);
> +	return xfs_bmbt_to_iomap(ip, iomap, &imap, false);
>  }
>  
>  const struct iomap_ops xfs_xattr_iomap_ops = {
> diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h
> index c6170548831b..ed27e41b687c 100644
> --- a/fs/xfs/xfs_iomap.h
> +++ b/fs/xfs/xfs_iomap.h
> @@ -17,8 +17,8 @@ int xfs_iomap_write_allocate(struct xfs_inode *, int, xfs_off_t,
>  			struct xfs_bmbt_irec *, unsigned int *);
>  int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool);
>  
> -void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
> -		struct xfs_bmbt_irec *);
> +int xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
> +		struct xfs_bmbt_irec *, bool shared);
>  xfs_extlen_t xfs_eof_alignment(struct xfs_inode *ip, xfs_extlen_t extsize);
>  
>  static inline xfs_filblks_t
> diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
> index f44c3599527d..bde2c9f56a46 100644
> --- a/fs/xfs/xfs_pnfs.c
> +++ b/fs/xfs/xfs_pnfs.c
> @@ -185,7 +185,7 @@ xfs_fs_map_blocks(
>  	}
>  	xfs_iunlock(ip, XFS_IOLOCK_EXCL);
>  
> -	xfs_bmbt_to_iomap(ip, iomap, &imap);
> +	error = xfs_bmbt_to_iomap(ip, iomap, &imap, false);
>  	*device_generation = mp->m_generation;
>  	return error;
>  out_unlock:
> -- 
> 2.19.1
> 

  reply	other threads:[~2018-12-18 21:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-03 22:24 COW improvements and always_cow support V3 Christoph Hellwig
2018-12-03 22:24 ` [PATCH 01/11] xfs: remove xfs_trim_extent_eof Christoph Hellwig
2018-12-18 21:45   ` Darrick J. Wong
2018-12-03 22:24 ` [PATCH 02/11] xfs: remove the io_type field from the writeback context and ioend Christoph Hellwig
2018-12-18 21:45   ` Darrick J. Wong
2018-12-03 22:24 ` [PATCH 03/11] xfs: remove the s_maxbytes checks in xfs_map_blocks Christoph Hellwig
2018-12-18 22:31   ` Darrick J. Wong
2018-12-03 22:24 ` [PATCH 04/11] xfs: rework the truncate race handling in the writeback path Christoph Hellwig
2018-12-18 23:03   ` Darrick J. Wong
2018-12-19 19:32     ` Christoph Hellwig
2018-12-03 22:24 ` [PATCH 05/11] xfs: make xfs_bmbt_to_iomap more useful Christoph Hellwig
2018-12-18 21:46   ` Darrick J. Wong [this message]
2018-12-03 22:24 ` [PATCH 06/11] xfs: don't use delalloc extents for COW on files with extsize hints Christoph Hellwig
2018-12-18 21:44   ` Darrick J. Wong
2018-12-19 19:29     ` Christoph Hellwig
2018-12-19 19:32       ` Darrick J. Wong
2018-12-03 22:24 ` [PATCH 07/11] xfs: also truncate holes covered by COW blocks Christoph Hellwig
2018-12-18 23:39   ` Darrick J. Wong
2018-12-03 22:25 ` [PATCH 08/11] xfs: merge COW handling into xfs_file_iomap_begin_delay Christoph Hellwig
2018-12-18 23:36   ` Darrick J. Wong
2018-12-19 19:38     ` Christoph Hellwig
2018-12-19 20:20       ` Darrick J. Wong
2018-12-03 22:25 ` [PATCH 09/11] xfs: report IOMAP_F_SHARED from xfs_file_iomap_begin_delay Christoph Hellwig
2018-12-18 23:38   ` Darrick J. Wong
2018-12-19 19:39     ` Christoph Hellwig
2018-12-03 22:25 ` [PATCH 10/11] xfs: make COW fork unwritten extent conversions more robust Christoph Hellwig
2018-12-18 22:22   ` Darrick J. Wong
2018-12-19 19:30     ` Christoph Hellwig
2018-12-03 22:25 ` [PATCH 11/11] xfs: introduce an always_cow mode Christoph Hellwig
2018-12-18 23:24   ` Darrick J. Wong
2018-12-19 19:37     ` Christoph Hellwig
2018-12-19 22:43     ` Dave Chinner
2018-12-20  7:07       ` Christoph Hellwig
2018-12-20 21:03         ` Dave Chinner
2018-12-21  6:27           ` Christoph Hellwig
2018-12-06  1:05 ` COW improvements and always_cow support V3 Darrick J. Wong
2018-12-06  4:16   ` Christoph Hellwig
2018-12-06 16:32     ` Darrick J. Wong
2018-12-06 20:09   ` Christoph Hellwig
2018-12-17 17:59     ` Darrick J. Wong
2018-12-18 18:05       ` Christoph Hellwig
2018-12-19  0:44         ` Darrick J. Wong
2018-12-20  7:09           ` Christoph Hellwig
2018-12-20 22:09             ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2019-01-17 16:36 COW improvements and always_cow support V4 Christoph Hellwig
2019-01-17 16:36 ` [PATCH 05/11] xfs: make xfs_bmbt_to_iomap more useful Christoph Hellwig

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=20181218214637.GO27208@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.