All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 06/10] xfs: make imaxpct changes in growfs separate
Date: Fri, 11 May 2018 17:57:25 -0700	[thread overview]
Message-ID: <20180512005725.GS11261@magnolia> (raw)
In-Reply-To: <20180511225107.27171-7-david@fromorbit.com>

On Sat, May 12, 2018 at 08:51:03AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> When growfs changes the imaxpct value of the filesystem, it runs
> through all the "change size" growfs code, whether it needs to or
> not. Separate out changing imaxpct into it's own function and
> transaction to simplify the rest of the growfs code.
> 
> Signed-Off-By: Dave Chinner <dchinner@redhat.com>

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

--D

> ---
>  fs/xfs/xfs_fsops.c | 69 +++++++++++++++++++++++++++++++++-------------
>  1 file changed, 50 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index 263f9b5da991..0fd50c68f1b0 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -400,25 +400,21 @@ xfs_growfs_data_private(
>  	xfs_agi_t		*agi;
>  	xfs_agnumber_t		agno;
>  	xfs_buf_t		*bp;
> -	int			dpct;
>  	int			error, saved_error = 0;
>  	xfs_agnumber_t		nagcount;
>  	xfs_agnumber_t		nagimax = 0;
>  	xfs_rfsblock_t		nb, nb_mod;
>  	xfs_rfsblock_t		new;
>  	xfs_agnumber_t		oagcount;
> -	int			pct;
>  	xfs_trans_t		*tp;
>  	LIST_HEAD		(buffer_list);
>  	struct aghdr_init_data	id = {};
>  
>  	nb = in->newblocks;
> -	pct = in->imaxpct;
> -	if (nb < mp->m_sb.sb_dblocks || pct < 0 || pct > 100)
> +	if (nb < mp->m_sb.sb_dblocks)
>  		return -EINVAL;
>  	if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb)))
>  		return error;
> -	dpct = pct - mp->m_sb.sb_imax_pct;
>  	error = xfs_buf_read_uncached(mp->m_ddev_targp,
>  				XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1),
>  				XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL);
> @@ -551,8 +547,6 @@ xfs_growfs_data_private(
>  				 nb - mp->m_sb.sb_dblocks);
>  	if (id.nfree)
>  		xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, id.nfree);
> -	if (dpct)
> -		xfs_trans_mod_sb(tp, XFS_TRANS_SB_IMAXPCT, dpct);
>  	xfs_trans_set_sync(tp);
>  	error = xfs_trans_commit(tp);
>  	if (error)
> @@ -561,12 +555,6 @@ xfs_growfs_data_private(
>  	/* New allocation groups fully initialized, so update mount struct */
>  	if (nagimax)
>  		mp->m_maxagi = nagimax;
> -	if (mp->m_sb.sb_imax_pct) {
> -		uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct;
> -		do_div(icount, 100);
> -		mp->m_maxicount = icount << mp->m_sb.sb_inopblog;
> -	} else
> -		mp->m_maxicount = 0;
>  	xfs_set_low_space_thresholds(mp);
>  	mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
>  
> @@ -670,25 +658,68 @@ xfs_growfs_log_private(
>  	return -ENOSYS;
>  }
>  
> +static int
> +xfs_growfs_imaxpct(
> +	struct xfs_mount	*mp,
> +	__u32			imaxpct)
> +{
> +	struct xfs_trans	*tp;
> +	int64_t			dpct;
> +	int			error;
> +
> +	if (imaxpct > 100)
> +		return -EINVAL;
> +
> +	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata,
> +			XFS_GROWFS_SPACE_RES(mp), 0, XFS_TRANS_RESERVE, &tp);
> +	if (error)
> +		return error;
> +
> +	dpct = (int64_t)imaxpct - mp->m_sb.sb_imax_pct;
> +	xfs_trans_mod_sb(tp, XFS_TRANS_SB_IMAXPCT, dpct);
> +	xfs_trans_set_sync(tp);
> +	return xfs_trans_commit(tp);
> +}
> +
>  /*
>   * protected versions of growfs function acquire and release locks on the mount
>   * point - exported through ioctls: XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG,
>   * XFS_IOC_FSGROWFSRT
>   */
> -
> -
>  int
>  xfs_growfs_data(
> -	xfs_mount_t		*mp,
> -	xfs_growfs_data_t	*in)
> +	struct xfs_mount	*mp,
> +	struct xfs_growfs_data	*in)
>  {
> -	int error;
> +	int			error = 0;
>  
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  	if (!mutex_trylock(&mp->m_growlock))
>  		return -EWOULDBLOCK;
> -	error = xfs_growfs_data_private(mp, in);
> +
> +	/* update imaxpct separately to the physical grow of the filesystem */
> +	if (in->imaxpct != mp->m_sb.sb_imax_pct) {
> +		error = xfs_growfs_imaxpct(mp, in->imaxpct);
> +		if (error)
> +			goto out_error;
> +	}
> +
> +	if (in->newblocks != mp->m_sb.sb_dblocks) {
> +		error = xfs_growfs_data_private(mp, in);
> +		if (error)
> +			goto out_error;
> +	}
> +
> +	/* Post growfs calculations needed to reflect new state in operations */
> +	if (mp->m_sb.sb_imax_pct) {
> +		uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct;
> +		do_div(icount, 100);
> +		mp->m_maxicount = icount << mp->m_sb.sb_inopblog;
> +	} else
> +		mp->m_maxicount = 0;
> +
> +out_error:
>  	/*
>  	 * Increment the generation unconditionally, the error could be from
>  	 * updating the secondary superblocks, in which case the new size
> -- 
> 2.17.0
> 
> --
> 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-05-12  0:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11 22:50 [PATCH v2] xfs: refactor and tablise growfs Dave Chinner
2018-05-11 22:50 ` [PATCH 01/10] xfs: one-shot cached buffers Dave Chinner
2018-05-12  0:24   ` Darrick J. Wong
2018-05-12  2:06     ` Dave Chinner
2018-05-12  2:08       ` Darrick J. Wong
2018-05-11 22:50 ` [PATCH 02/10] xfs: factor out AG header initialisation from growfs core Dave Chinner
2018-05-12  0:36   ` Darrick J. Wong
2018-05-11 22:51 ` [PATCH 03/10] xfs: convert growfs AG header init to use buffer lists Dave Chinner
2018-05-12  0:39   ` Darrick J. Wong
2018-05-11 22:51 ` [PATCH 04/10] xfs: factor ag btree root block initialisation Dave Chinner
2018-05-12  0:48   ` Darrick J. Wong
2018-05-12  2:01     ` Dave Chinner
2018-05-11 22:51 ` [PATCH 05/10] xfs: turn ag header initialisation into a table driven operation Dave Chinner
2018-05-12  0:55   ` Darrick J. Wong
2018-05-12  2:03     ` Dave Chinner
2018-05-12  2:05       ` Darrick J. Wong
2018-05-11 22:51 ` [PATCH 06/10] xfs: make imaxpct changes in growfs separate Dave Chinner
2018-05-12  0:57   ` Darrick J. Wong [this message]
2018-05-11 22:51 ` [PATCH 07/10] xfs: separate secondary sb update in growfs Dave Chinner
2018-05-12  1:20   ` Darrick J. Wong
2018-05-11 22:51 ` [PATCH 08/10] xfs: rework secondary superblock updates " Dave Chinner
2018-05-12  1:47   ` Darrick J. Wong
2018-05-11 22:51 ` [PATCH 09/10] xfs: move growfs core to libxfs Dave Chinner
2018-05-12  1:48   ` Darrick J. Wong
2018-05-11 22:51 ` [PATCH 10/10] xfs: factor the ag length extension code into libxfs Dave Chinner
2018-05-12  1:48   ` Darrick J. Wong
2018-05-14  4:18 [PATCH 0/10 v3] xfs: refactor and tablise growfs Dave Chinner
2018-05-14  4:19 ` [PATCH 06/10] xfs: make imaxpct changes in growfs separate Dave Chinner

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=20180512005725.GS11261@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.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 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.