From: Brian Foster <bfoster@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/7] xfs: separate secondary sb update in growfs
Date: Fri, 9 Feb 2018 11:11:54 -0500 [thread overview]
Message-ID: <20180209161153.GC21413@bfoster.bfoster> (raw)
In-Reply-To: <20180201064202.7174-7-david@fromorbit.com>
On Thu, Feb 01, 2018 at 05:42:01PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> This happens after all the transactions to update the superblock
> occur, and errors need to be handled slightly differently. Seperate
Separate
> out the code into it's own function, and clean up the error goto
> stack in the core growfs code as it is now much simpler.
>
> Signed-Off-By: Dave Chinner <dchinner@redhat.com>
> ---
> fs/xfs/xfs_fsops.c | 154 ++++++++++++++++++++++++++++++-----------------------
> 1 file changed, 87 insertions(+), 67 deletions(-)
>
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index 5c844e540320..113be7dbdc81 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
...
> @@ -572,16 +572,79 @@ xfs_growfs_data_private(
> error = xfs_ag_resv_free(pag);
> xfs_perag_put(pag);
> if (error)
> - goto out;
> + return error;
> }
>
> /* Reserve AG metadata blocks. */
> - error = xfs_fs_reserve_ag_blocks(mp);
> - if (error && error != -ENOSPC)
> - goto out;
> + return xfs_fs_reserve_ag_blocks(mp);
It looks like we change the semantics of -ENOSPC during perag
reservation init. No mention of whether this is intentional and/or
why..?
Brian
> +
> +out_trans_cancel:
> + xfs_trans_cancel(tp);
> + return error;
> +}
> +
> +static int
> +xfs_growfs_log_private(
> + xfs_mount_t *mp, /* mount point for filesystem */
> + xfs_growfs_log_t *in) /* growfs log input struct */
> +{
> + xfs_extlen_t nb;
> +
> + nb = in->newblocks;
> + if (nb < XFS_MIN_LOG_BLOCKS || nb < XFS_B_TO_FSB(mp, XFS_MIN_LOG_BYTES))
> + return -EINVAL;
> + if (nb == mp->m_sb.sb_logblocks &&
> + in->isint == (mp->m_sb.sb_logstart != 0))
> + return -EINVAL;
> + /*
> + * Moving the log is hard, need new interfaces to sync
> + * the log first, hold off all activity while moving it.
> + * Can have shorter or longer log in the same space,
> + * or transform internal to external log or vice versa.
> + */
> + return -ENOSYS;
> +}
> +
> +static int
> +xfs_growfs_imaxpct(
> + struct xfs_mount *mp,
> + __u32 imaxpct)
> +{
> + struct xfs_trans *tp;
> + int 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 = 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);
> +}
> +
> +/*
> + * After a grow operation, we need to update all the secondary superblocks
> + * to match the new state of the primary. Read/init the superblocks and update
> + * them appropriately.
> + */
> +static int
> +xfs_growfs_update_superblocks(
> + struct xfs_mount *mp,
> + xfs_agnumber_t oagcount)
> +{
> + struct xfs_buf *bp;
> + xfs_agnumber_t agno;
> + int saved_error = 0;
> + int error = 0;
>
> /* update secondary superblocks. */
> - for (agno = 1; agno < nagcount; agno++) {
> + for (agno = 1; agno < mp->m_sb.sb_agcount; agno++) {
> error = 0;
> /*
> * new secondary superblocks need to be zeroed, not read from
> @@ -631,57 +694,7 @@ xfs_growfs_data_private(
> }
> }
>
> - out:
> return saved_error ? saved_error : error;
> -
> - error0:
> - xfs_trans_cancel(tp);
> - return error;
> -}
> -
> -static int
> -xfs_growfs_log_private(
> - xfs_mount_t *mp, /* mount point for filesystem */
> - xfs_growfs_log_t *in) /* growfs log input struct */
> -{
> - xfs_extlen_t nb;
> -
> - nb = in->newblocks;
> - if (nb < XFS_MIN_LOG_BLOCKS || nb < XFS_B_TO_FSB(mp, XFS_MIN_LOG_BYTES))
> - return -EINVAL;
> - if (nb == mp->m_sb.sb_logblocks &&
> - in->isint == (mp->m_sb.sb_logstart != 0))
> - return -EINVAL;
> - /*
> - * Moving the log is hard, need new interfaces to sync
> - * the log first, hold off all activity while moving it.
> - * Can have shorter or longer log in the same space,
> - * or transform internal to external log or vice versa.
> - */
> - 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);
> }
>
> /*
> @@ -694,6 +707,7 @@ xfs_growfs_data(
> struct xfs_mount *mp,
> struct xfs_growfs_data *in)
> {
> + xfs_agnumber_t oagcount;
> int error = 0;
>
> if (!capable(CAP_SYS_ADMIN))
> @@ -708,6 +722,7 @@ xfs_growfs_data(
> goto out_error;
> }
>
> + oagcount = mp->m_sb.sb_agcount;
> error = xfs_growfs_data_private(mp, in);
> if (error)
> goto out_error;
> @@ -722,6 +737,11 @@ xfs_growfs_data(
> } else
> mp->m_maxicount = 0;
>
> + /*
> + * Update secondary superblocks now the physical grow has completed
> + */
> + error = xfs_growfs_update_superblocks(mp, oagcount);
> +
> out_error:
> /*
> * Increment the generation unconditionally, the error could be from
> --
> 2.15.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
next prev parent reply other threads:[~2018-02-09 16:11 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 6:41 [PATCH 0/7] xfs: refactor and tablise growfs Dave Chinner
2018-02-01 6:41 ` [PATCH 1/7] xfs: factor out AG header initialisation from growfs core Dave Chinner
2018-02-08 18:53 ` Brian Foster
2018-02-01 6:41 ` [PATCH 2/7] xfs: convert growfs AG header init to use buffer lists Dave Chinner
2018-02-08 18:53 ` Brian Foster
2018-02-01 6:41 ` [PATCH 3/7] xfs: factor ag btree reoot block initialisation Dave Chinner
2018-02-08 18:54 ` Brian Foster
2018-02-08 20:00 ` Darrick J. Wong
2018-02-09 13:10 ` Brian Foster
2018-02-12 0:45 ` Darrick J. Wong
2018-02-15 5:53 ` Darrick J. Wong
2018-02-01 6:41 ` [PATCH 4/7] xfs: turn ag header initialisation into a table driven operation Dave Chinner
2018-02-09 16:11 ` Brian Foster
2018-02-01 6:42 ` [PATCH 5/7] xfs: make imaxpct changes in growfs separate Dave Chinner
2018-02-09 16:11 ` Brian Foster
2018-02-15 22:10 ` Dave Chinner
2018-02-01 6:42 ` [PATCH 6/7] xfs: separate secondary sb update in growfs Dave Chinner
2018-02-09 16:11 ` Brian Foster [this message]
2018-02-15 22:23 ` Dave Chinner
2018-02-16 12:31 ` Brian Foster
2018-02-01 6:42 ` [PATCH 7/7] xfs: rework secondary superblock updates " Dave Chinner
2018-02-09 16:12 ` Brian Foster
2018-02-15 22:31 ` Dave Chinner
2018-02-16 12:56 ` Brian Foster
2018-02-16 16:20 ` Darrick J. Wong
2018-02-19 2:16 ` Dave Chinner
2018-02-19 13:21 ` Brian Foster
2018-02-19 22:14 ` Dave Chinner
2018-02-20 12:44 ` Brian Foster
2018-03-24 0:37 ` Darrick J. Wong
2018-02-06 23:44 ` [PATCH 0/7] xfs: refactor and tablise growfs Darrick J. Wong
2018-02-07 7:10 ` 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=20180209161153.GC21413@bfoster.bfoster \
--to=bfoster@redhat.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 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).