All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 01/11] FOLD: improve xfs_bmapi_delalloc
Date: Thu, 31 Jan 2019 13:09:58 -0500	[thread overview]
Message-ID: <20190131180957.GC36239@bfoster> (raw)
In-Reply-To: <20190131075524.4769-2-hch@lst.de>

On Thu, Jan 31, 2019 at 08:55:14AM +0100, Christoph Hellwig wrote:
> Give it a more descriptive name, and remove a couple of parameters that
> are better derived internally instead of burdening it on the caller.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_bmap.c | 24 ++++++++++++++++--------
>  fs/xfs/libxfs/xfs_bmap.h |  5 +++--
>  fs/xfs/xfs_iomap.c       | 14 ++------------
>  3 files changed, 21 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 3229a82de1fb..65940b79019a 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4477,21 +4477,29 @@ xfs_bmapi_write(
>   * is not available.
>   */
>  int
> -xfs_bmapi_delalloc(
> +xfs_bmapi_convert_delalloc(
>  	struct xfs_trans	*tp,
>  	struct xfs_inode	*ip,
> -	xfs_fileoff_t		bno,
> -	int			flags,
> -	xfs_extlen_t		total,
> -	struct xfs_bmbt_irec	*imap,
> -	int			*nimaps)
> +	int			whichfork,
> +	xfs_fileoff_t		offset_fsb,
> +	struct xfs_bmbt_irec	*imap)
>  {
> +	int			flags = XFS_BMAPI_DELALLOC, nimaps = 1, error;
> +

I'd rather see these on separate lines.

> +	if (whichfork == XFS_COW_FORK)
> +		flags |= XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC;
> +
>  	/*
> -	 * The reval flag means to allocate the entire extent; pass a dummy
> +	 * The DELALLOC flag always allocates the entire extent; pass a dummy
>  	 * length of 1.
>  	 */
>  	flags |= XFS_BMAPI_DELALLOC;
> -	return xfs_bmapi_write(tp, ip, bno, 1, flags, total, imap, nimaps);
> +	error = xfs_bmapi_write(tp, ip, offset_fsb, 1, flags,
> +			XFS_EXTENTADD_SPACE_RES(ip->i_mount, XFS_DATA_FORK),

Shouldn't this be whichfork?

Brian

> +			imap, &nimaps);
> +	if (!error && !nimaps)
> +		error = -EFSCORRUPTED;
> +	return error;
>  }
>  
>  int
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index 4e8bd2837cb0..c385987251cd 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -227,8 +227,9 @@ int	xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
>  		xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
>  		struct xfs_bmbt_irec *got, struct xfs_iext_cursor *cur,
>  		int eof);
> -int	xfs_bmapi_delalloc(struct xfs_trans *, struct xfs_inode *,
> -		xfs_fileoff_t, int, xfs_extlen_t, struct xfs_bmbt_irec *, int *);
> +int	xfs_bmapi_convert_delalloc(struct xfs_trans *tp, struct xfs_inode *ip,
> +		int whichfork, xfs_fileoff_t offset_fsb,
> +		struct xfs_bmbt_irec *imap);
>  
>  static inline void
>  xfs_bmap_add_free(
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 066c2120f0ba..9849c3a5a435 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -689,14 +689,7 @@ xfs_iomap_write_allocate(
>  	xfs_fileoff_t		map_start_fsb;
>  	xfs_extlen_t		map_count_fsb;
>  	struct xfs_trans	*tp;
> -	int			nimaps;
>  	int			error = 0;
> -	int			flags = XFS_BMAPI_DELALLOC;
> -	int			nres;
> -
> -	if (whichfork == XFS_COW_FORK)
> -		flags |= XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC;
> -	nres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK);
>  
>  	/*
>  	 * Make sure that the dquots are there.
> @@ -744,11 +737,8 @@ xfs_iomap_write_allocate(
>  		 * caller. We'll trim it down to the caller's most recently
>  		 * validated range before we return.
>  		 */
> -		nimaps = 1;
> -		error = xfs_bmapi_delalloc(tp, ip, offset_fsb, flags, nres,
> -					   imap, &nimaps);
> -		if (nimaps == 0)
> -			error = -EFSCORRUPTED;
> +		error = xfs_bmapi_convert_delalloc(tp, ip, whichfork,
> +				offset_fsb, imap);
>  		if (error)
>  			goto trans_cancel;
>  
> -- 
> 2.20.1
> 

  reply	other threads:[~2019-01-31 18:10 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31  7:55 make delalloc conversion more robust and clear Christoph Hellwig
2019-01-31  7:55 ` [PATCH 01/11] FOLD: improve xfs_bmapi_delalloc Christoph Hellwig
2019-01-31 18:09   ` Brian Foster [this message]
2019-02-01  7:23     ` Christoph Hellwig
2019-02-01  7:28       ` Christoph Hellwig
2019-02-01 12:46         ` Brian Foster
2019-02-01 16:08           ` Christoph Hellwig
2019-01-31  7:55 ` [PATCH 02/11] xfs: remove the io_type field from the writeback context and ioend Christoph Hellwig
2019-01-31 18:10   ` Brian Foster
2019-01-31  7:55 ` [PATCH 03/11] xfs: remove the s_maxbytes checks in xfs_map_blocks Christoph Hellwig
2019-01-31 18:10   ` Brian Foster
2019-01-31  7:55 ` [PATCH 04/11] xfs: don't try to map blocks beyond i_size in writeback Christoph Hellwig
2019-01-31 18:11   ` Brian Foster
2019-02-01  7:25     ` Christoph Hellwig
2019-02-01 12:46       ` Brian Foster
2019-02-01 16:07         ` Christoph Hellwig
2019-01-31  7:55 ` [PATCH 05/11] xfs: simplify the xfs_bmap_btree_to_extents calling conventions Christoph Hellwig
2019-01-31 18:11   ` Brian Foster
2019-01-31  7:55 ` [PATCH 06/11] xfs: factor out two helpers from xfs_bmapi_write Christoph Hellwig
2019-01-31 18:28   ` Brian Foster
2019-01-31  7:55 ` [PATCH 07/11] xfs: split XFS_BMAPI_DELALLOC handling " Christoph Hellwig
2019-01-31 19:28   ` Brian Foster
2019-01-31  7:55 ` [PATCH 08/11] xfs: move transaction handling to xfs_bmapi_convert_delalloc Christoph Hellwig
2019-01-31 19:28   ` Brian Foster
2019-01-31  7:55 ` [PATCH 09/11] xfs: move stat accounting " Christoph Hellwig
2019-01-31 19:29   ` Brian Foster
2019-01-31  7:55 ` [PATCH 10/11] xfs: move xfs_iomap_write_allocate to xfs_aops.c Christoph Hellwig
2019-01-31 19:31   ` Brian Foster
2019-01-31  7:55 ` [PATCH 11/11] xfs: retry COW fork delalloc conversion when no extent was found 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=20190131180957.GC36239@bfoster \
    --to=bfoster@redhat.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.