linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null
Date: Tue, 3 Jul 2018 17:24:15 -0700	[thread overview]
Message-ID: <20180704002415.GA32415@magnolia> (raw)
In-Reply-To: <20180703172319.24509-2-bfoster@redhat.com>

On Tue, Jul 03, 2018 at 01:22:55PM -0400, Brian Foster wrote:
> xfs_bmapi_write() always expects a valid firstblock pointer. It
> immediately dereferences the pointer to help determine how to
> initialize the bma.minleft field. The remaining accesses are
> related to modifying btree format forks, which is only relevant for
> !COW fork callers.
> 
> The reflink code passes a NULL transaction to xfs_bmapi_write() in a
> couple places that do COW fork unwritten conversion. The purpose of
> the firstblock field is to track the first block allocation in the
> current transaction, so technically firstblock should not be
> required for these callers either.
> 
> Tweak xfs_bmapi_write() to initialize the bma correctly without
> accessing the firstblock pointer if no transaction is provided in
> the first place. Update the reflink callers to pass NULL instead of
> otherwise unused firstblock references.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

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

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 2 +-
>  fs/xfs/xfs_reflink.c     | 9 +++------
>  2 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 2e2a9661600b..c6a5a957674d 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4304,7 +4304,7 @@ xfs_bmapi_write(
>  
>  	XFS_STATS_INC(mp, xs_blk_mapw);
>  
> -	if (*firstblock == NULLFSBLOCK) {
> +	if (!tp || *firstblock == NULLFSBLOCK) {
>  		if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
>  			bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
>  		else
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 8496312dde6a..92b6e1b5d33c 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -314,7 +314,6 @@ xfs_reflink_convert_cow_extent(
>  	xfs_fileoff_t			offset_fsb,
>  	xfs_filblks_t			count_fsb)
>  {
> -	xfs_fsblock_t			first_block = NULLFSBLOCK;
>  	int				nimaps = 1;
>  
>  	if (imap->br_state == XFS_EXT_NORM)
> @@ -325,8 +324,8 @@ xfs_reflink_convert_cow_extent(
>  	if (imap->br_blockcount == 0)
>  		return 0;
>  	return xfs_bmapi_write(NULL, ip, imap->br_startoff, imap->br_blockcount,
> -			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, &first_block,
> -			0, imap, &nimaps);
> +			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, NULL, 0, imap,
> +			&nimaps);
>  }
>  
>  /* Convert all of the unwritten CoW extents in a file's range to real ones. */
> @@ -341,7 +340,6 @@ xfs_reflink_convert_cow(
>  	xfs_fileoff_t		end_fsb = XFS_B_TO_FSB(mp, offset + count);
>  	xfs_filblks_t		count_fsb = end_fsb - offset_fsb;
>  	struct xfs_bmbt_irec	imap;
> -	xfs_fsblock_t		first_block = NULLFSBLOCK;
>  	int			nimaps = 1, error = 0;
>  
>  	ASSERT(count != 0);
> @@ -349,8 +347,7 @@ xfs_reflink_convert_cow(
>  	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);
> +			XFS_BMAPI_CONVERT_ONLY, NULL, 0, &imap, &nimaps);
>  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
>  	return error;
>  }
> -- 
> 2.17.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:[~2018-07-04  0:24 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
2018-07-03 17:22 ` [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null Brian Foster
2018-07-04  0:24   ` Darrick J. Wong [this message]
2018-07-08 15:26   ` Christoph Hellwig
2018-07-03 17:22 ` [PATCH 02/25] xfs: add firstblock field to xfs_trans Brian Foster
2018-07-04  0:41   ` Darrick J. Wong
2018-07-08 15:26   ` Christoph Hellwig
2018-07-03 17:22 ` [PATCH 03/25] xfs: use ->t_firstblock in dir ops Brian Foster
2018-07-04  0:42   ` Darrick J. Wong
2018-07-03 17:22 ` [PATCH 04/25] xfs: remove firstblock param from xfs " Brian Foster
2018-07-03 18:06   ` Darrick J. Wong
2018-07-03 18:15     ` Brian Foster
2018-07-03 17:22 ` [PATCH 05/25] xfs: use ->t_firstblock in attrfork add Brian Foster
2018-07-04  0:43   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 06/25] xfs: use ->t_firstblock in xattr ops Brian Foster
2018-07-04  0:45   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 07/25] xfs: use ->t_firstblock for all xfs_bmapi_write() callers Brian Foster
2018-07-04  0:47   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 08/25] xfs: use ->t_firstblock for all xfs_bunmapi() callers Brian Foster
2018-07-04  0:47   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 09/25] xfs: use ->t_firstblock in xfs_bmapi_remap() Brian Foster
2018-07-04  0:47   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 10/25] xfs: use ->t_firstblock in insert/collapse range Brian Foster
2018-07-04  0:48   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 11/25] xfs: remove xfs_bmapi_write() firstblock param Brian Foster
2018-07-04  0:50   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 12/25] xfs: remove xfs_bunmapi() " Brian Foster
2018-07-04  0:51   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 13/25] xfs: remove bmap insert/collapse " Brian Foster
2018-07-04  0:51   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 14/25] xfs: use ->t_firstblock in bmap extent split Brian Foster
2018-07-04  0:51   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 15/25] xfs: remove xfs_bmalloca firstblock field Brian Foster
2018-07-04  0:52   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 16/25] xfs: remove bmap extent add helper firstblock params Brian Foster
2018-07-04  0:52   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 17/25] xfs: remove bmap format helpers " Brian Foster
2018-07-04  0:53   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 18/25] xfs: remove xfs_btree_cur private firstblock field Brian Foster
2018-07-04  0:54   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 19/25] xfs: remove xfs_alloc_arg " Brian Foster
2018-07-04  0:54   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 20/25] xfs: use ->t_firstblock in dq alloc Brian Foster
2018-07-04  0:54   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 21/25] xfs: replace no-op firstblock init with ->t_firstblock Brian Foster
2018-07-04  0:54   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 22/25] xfs: use ->t_firstblock in reflink cow block cancel Brian Foster
2018-07-04  0:55   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 23/25] xfs: use ->t_firstblock in extent swap Brian Foster
2018-07-04  0:55   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 24/25] xfs: use ->t_firstblock in inode inactivate Brian Foster
2018-07-04  0:55   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param Brian Foster
2018-07-04  1:27   ` Darrick J. Wong
2018-07-08 15:37     ` Christoph Hellwig
2018-07-08 16:34       ` Darrick J. Wong
2018-07-10  1:07       ` Brian Foster
2018-07-10  7:11 ` [PATCH 00/25] xfs: embed firstblock in xfs_trans 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=20180704002415.GA32415@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=bfoster@redhat.com \
    --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).