public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org, hch@infradead.org, david@fromorbit.com
Subject: Re: [PATCH 08/13] xfs: allow reservation of rtblocks with xfs_trans_alloc_inode
Date: Thu, 28 Jan 2021 13:22:58 -0500	[thread overview]
Message-ID: <20210128182258.GG2619139@bfoster> (raw)
In-Reply-To: <161181370983.1523592.13034713028988213055.stgit@magnolia>

On Wed, Jan 27, 2021 at 10:01:49PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Make it so that we can reserve rt blocks with the xfs_trans_alloc_inode
> wrapper function, then convert a few more callsites.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_attr.c |    2 +-
>  fs/xfs/libxfs/xfs_bmap.c |    2 +-
>  fs/xfs/xfs_bmap_util.c   |   29 +++++------------------------
>  fs/xfs/xfs_iomap.c       |   22 +++++-----------------
>  fs/xfs/xfs_trans.c       |    6 ++++--
>  fs/xfs/xfs_trans.h       |    3 ++-
>  6 files changed, 18 insertions(+), 46 deletions(-)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index cb95bc77fe59..472b3039eabb 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -458,7 +458,7 @@ xfs_attr_set(
>  	 * Root fork attributes can use reserved data blocks for this
>  	 * operation if necessary
>  	 */
> -	error = xfs_trans_alloc_inode(dp, &tres, total, rsvd, &args->trans);
> +	error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans);
>  	if (error)
>  		return error;
>  
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index f78fa694f3c2..8131bc5f4bad 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1079,7 +1079,7 @@ xfs_bmap_add_attrfork(
>  
>  	blks = XFS_ADDAFORK_SPACE_RES(mp);
>  
> -	error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_addafork, blks,
> +	error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_addafork, blks, 0,
>  			rsvd, &tp);
>  	if (error)
>  		return error;
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 94ffdeb2dd73..c3b7dff21887 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -730,7 +730,6 @@ xfs_alloc_file_space(
>  	int			rt;
>  	xfs_trans_t		*tp;
>  	xfs_bmbt_irec_t		imaps[1], *imapp;
> -	uint			qblocks, resblks, resrtextents;
>  	int			error;
>  
>  	trace_xfs_alloc_file_space(ip);
> @@ -760,7 +759,7 @@ xfs_alloc_file_space(
>  	 */
>  	while (allocatesize_fsb && !error) {
>  		xfs_fileoff_t	s, e;
> -		unsigned int	dblocks, rblocks;
> +		unsigned int	dblocks, rblocks, resblks;
>  
>  		/*
>  		 * Determine space reservations for data/realtime.
> @@ -790,8 +789,6 @@ xfs_alloc_file_space(
>  		 */
>  		resblks = min_t(xfs_fileoff_t, (e - s), (MAXEXTLEN * nimaps));
>  		if (unlikely(rt)) {
> -			resrtextents = qblocks = resblks;
> -			resrtextents /= mp->m_sb.sb_rextsize;
>  			dblocks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
>  			rblocks = resblks;
>  		} else {
> @@ -802,32 +799,16 @@ xfs_alloc_file_space(
>  		/*
>  		 * Allocate and setup the transaction.
>  		 */
> -		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, dblocks,
> -				resrtextents, 0, &tp);
> -
> -		/*
> -		 * Check for running out of space
> -		 */
> -		if (error) {
> -			/*
> -			 * Free the transaction structure.
> -			 */
> -			ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
> -			break;
> -		}
> -		xfs_ilock(ip, XFS_ILOCK_EXCL);
> -		error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks,
> -				false);
> +		error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write,
> +				dblocks, rblocks, false, &tp);
>  		if (error)
> -			goto error1;
> +			break;
>  
>  		error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
>  				XFS_IEXT_ADD_NOSPLIT_CNT);
>  		if (error)
>  			goto error1;
>  
> -		xfs_trans_ijoin(tp, ip, 0);
> -
>  		error = xfs_bmapi_write(tp, ip, startoffset_fsb,
>  					allocatesize_fsb, alloc_type, 0, imapp,
>  					&nimaps);
> @@ -873,7 +854,7 @@ xfs_unmap_extent(
>  	uint			resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
>  	int			error;
>  
> -	error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, resblks,
> +	error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, resblks, 0,
>  			false, &tp);
>  	if (error)
>  		return error;
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 05de1be20426..f34a76529602 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -195,19 +195,15 @@ xfs_iomap_write_direct(
>  	xfs_filblks_t		resaligned;
>  	int			nimaps;
>  	unsigned int		dblocks, rblocks;
> -	unsigned int		resrtextents = 0;
> +	bool			force = false;
>  	int			error;
>  	int			bmapi_flags = XFS_BMAPI_PREALLOC;
> -	int			tflags = 0;
> -	bool			force = false;
>  
>  	ASSERT(count_fsb > 0);
>  
>  	resaligned = xfs_aligned_fsb_count(offset_fsb, count_fsb,
>  					   xfs_get_extsz_hint(ip));
>  	if (unlikely(XFS_IS_REALTIME_INODE(ip))) {
> -		resrtextents = resaligned;
> -		resrtextents /= mp->m_sb.sb_rextsize;
>  		dblocks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
>  		rblocks = resaligned;
>  	} else {
> @@ -236,28 +232,20 @@ xfs_iomap_write_direct(
>  		bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO;
>  		if (imap->br_state == XFS_EXT_UNWRITTEN) {
>  			force = true;
> -			tflags |= XFS_TRANS_RESERVE;
>  			dblocks = XFS_DIOSTRAT_SPACE_RES(mp, 0) << 1;
>  		}
>  	}
> -	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, dblocks, resrtextents,
> -			tflags, &tp);
> +
> +	error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, dblocks,
> +			rblocks, force, &tp);
>  	if (error)
>  		return error;
>  
> -	xfs_ilock(ip, XFS_ILOCK_EXCL);
> -
> -	error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, force);
> -	if (error)
> -		goto out_trans_cancel;
> -
>  	error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
>  			XFS_IEXT_ADD_NOSPLIT_CNT);
>  	if (error)
>  		goto out_trans_cancel;
>  
> -	xfs_trans_ijoin(tp, ip, 0);
> -
>  	/*
>  	 * From this point onwards we overwrite the imap pointer that the
>  	 * caller gave to us.
> @@ -553,7 +541,7 @@ xfs_iomap_write_unwritten(
>  		 * complete here and might deadlock on the iolock.
>  		 */
>  		error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, resblks,
> -				true, &tp);
> +				0, true, &tp);
>  		if (error)
>  			return error;
>  
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 156b9ed8534f..151f274eee43 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -1038,6 +1038,7 @@ xfs_trans_alloc_inode(
>  	struct xfs_inode	*ip,
>  	struct xfs_trans_res	*resv,
>  	unsigned int		dblocks,
> +	unsigned int		rblocks,
>  	bool			force,
>  	struct xfs_trans	**tpp)
>  {
> @@ -1045,7 +1046,8 @@ xfs_trans_alloc_inode(
>  	struct xfs_mount	*mp = ip->i_mount;
>  	int			error;
>  
> -	error = xfs_trans_alloc(mp, resv, dblocks, 0,
> +	error = xfs_trans_alloc(mp, resv, dblocks,
> +			rblocks / mp->m_sb.sb_rextsize,
>  			force ? XFS_TRANS_RESERVE : 0, &tp);
>  	if (error)
>  		return error;
> @@ -1060,7 +1062,7 @@ xfs_trans_alloc_inode(
>  		goto out_cancel;
>  	}
>  
> -	error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, 0, force);
> +	error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, force);
>  	if (error)
>  		goto out_cancel;
>  
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index aa50be244432..52bbd7e6a552 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -269,6 +269,7 @@ xfs_trans_item_relog(
>  }
>  
>  int xfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv,
> -		unsigned int dblocks, bool force, struct xfs_trans **tpp);
> +		unsigned int dblocks, unsigned int rblocks, bool force,
> +		struct xfs_trans **tpp);
>  
>  #endif	/* __XFS_TRANS_H__ */
> 


  parent reply	other threads:[~2021-01-28 18:27 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28  6:01 [PATCHSET v3 00/13] xfs: minor cleanups of the quota functions Darrick J. Wong
2021-01-28  6:01 ` [PATCH 01/13] xfs: clean up quota reservation callsites Darrick J. Wong
2021-01-28  6:01 ` [PATCH 02/13] xfs: create convenience wrappers for incore quota block reservations Darrick J. Wong
2021-01-28 18:08   ` Brian Foster
2021-01-28  6:01 ` [PATCH 03/13] xfs: remove xfs_trans_unreserve_quota_nblks completely Darrick J. Wong
2021-01-28  9:46   ` Christoph Hellwig
2021-01-28 18:08   ` Brian Foster
2021-01-28  6:01 ` [PATCH 04/13] xfs: clean up icreate quota reservation calls Darrick J. Wong
2021-01-28 18:09   ` Brian Foster
2021-01-28  6:01 ` [PATCH 05/13] xfs: fix up build warnings when quotas are disabled Darrick J. Wong
2021-01-28 18:09   ` Brian Foster
2021-01-28 18:22     ` Darrick J. Wong
2021-01-28 18:23       ` Christoph Hellwig
2021-01-28  6:01 ` [PATCH 06/13] xfs: reserve data and rt quota at the same time Darrick J. Wong
2021-01-28  9:49   ` Christoph Hellwig
2021-01-28 18:01     ` Darrick J. Wong
2021-01-28 18:10   ` Brian Foster
2021-01-28 18:52     ` Darrick J. Wong
2021-01-28  6:01 ` [PATCH 07/13] xfs: refactor common transaction/inode/quota allocation idiom Darrick J. Wong
2021-01-28  9:50   ` Christoph Hellwig
2021-01-28 18:22   ` Brian Foster
2021-01-28  6:01 ` [PATCH 08/13] xfs: allow reservation of rtblocks with xfs_trans_alloc_inode Darrick J. Wong
2021-01-28  9:51   ` Christoph Hellwig
2021-01-28 18:22   ` Brian Foster [this message]
2021-01-28  6:01 ` [PATCH 09/13] xfs: refactor reflink functions to use xfs_trans_alloc_inode Darrick J. Wong
2021-01-28  9:53   ` Christoph Hellwig
2021-01-28 18:06     ` Darrick J. Wong
2021-01-28 18:23   ` Brian Foster
2021-01-28  6:02 ` [PATCH 10/13] xfs: try worst case space reservation upfront in xfs_reflink_remap_extent Darrick J. Wong
2021-01-28  9:55   ` Christoph Hellwig
2021-01-28 18:23   ` Brian Foster
2021-01-28  6:02 ` [PATCH 11/13] xfs: refactor inode creation transaction/inode/quota allocation idiom Darrick J. Wong
2021-01-28  9:57   ` Christoph Hellwig
2021-01-28 18:18     ` Darrick J. Wong
2021-01-28 18:23   ` Brian Foster
2021-01-28  6:02 ` [PATCH 12/13] xfs: move xfs_qm_vop_chown_reserve to xfs_trans_dquot.c Darrick J. Wong
2021-01-28  9:58   ` Christoph Hellwig
2021-01-28 18:23   ` Brian Foster
2021-01-28  6:02 ` [PATCH 13/13] xfs: clean up xfs_trans_reserve_quota_chown a bit Darrick J. Wong
2021-01-28 10:00   ` Christoph Hellwig
2021-01-28 18:23   ` Brian Foster

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=20210128182258.GG2619139@bfoster \
    --to=bfoster@redhat.com \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --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