From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Gao Xiang <hsiangkao@redhat.com>
Cc: linux-xfs@vger.kernel.org, Brian Foster <bfoster@redhat.com>,
Eric Sandeen <sandeen@sandeen.net>
Subject: Re: [PATCH v3 3/4] xfs: hoist out xfs_resizefs_init_new_ags()
Date: Fri, 8 Jan 2021 13:20:16 -0800 [thread overview]
Message-ID: <20210108212016.GR38809@magnolia> (raw)
In-Reply-To: <20210108190919.623672-4-hsiangkao@redhat.com>
On Sat, Jan 09, 2021 at 03:09:18AM +0800, Gao Xiang wrote:
> Move out related logic for initializing new added AGs to a new helper
> in preparation for shrinking. No logic changes.
>
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
> ---
> fs/xfs/xfs_fsops.c | 74 +++++++++++++++++++++++++++-------------------
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> 1 file changed, 44 insertions(+), 30 deletions(-)
>
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index 6c5f6a50da2e..a792d1f0ac55 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -20,6 +20,49 @@
> #include "xfs_ag.h"
> #include "xfs_ag_resv.h"
>
> +static int
> +xfs_resizefs_init_new_ags(
> + xfs_mount_t *mp,
> + struct aghdr_init_data *id,
> + xfs_agnumber_t oagcount,
> + xfs_agnumber_t nagcount,
> + xfs_rfsblock_t *delta)
> +{
> + xfs_rfsblock_t nb = mp->m_sb.sb_dblocks + *delta;
> + int error;
> +
> + /*
> + * Write new AG headers to disk. Non-transactional, but need to be
> + * written and completed prior to the growfs transaction being logged.
> + * To do this, we use a delayed write buffer list and wait for
> + * submission and IO completion of the list as a whole. This allows the
> + * IO subsystem to merge all the AG headers in a single AG into a single
> + * IO and hide most of the latency of the IO from us.
> + *
> + * This also means that if we get an error whilst building the buffer
> + * list to write, we can cancel the entire list without having written
> + * anything.
> + */
> + INIT_LIST_HEAD(&id->buffer_list);
> + for (id->agno = nagcount - 1;
> + id->agno >= oagcount;
> + id->agno--, *delta -= id->agsize) {
> +
> + if (id->agno == nagcount - 1)
> + id->agsize = nb - (id->agno *
> + (xfs_rfsblock_t)mp->m_sb.sb_agblocks);
> + else
> + id->agsize = mp->m_sb.sb_agblocks;
> +
> + error = xfs_ag_init_headers(mp, id);
> + if (error) {
> + xfs_buf_delwri_cancel(&id->buffer_list);
> + return error;
> + }
> + }
> + return xfs_buf_delwri_submit(&id->buffer_list);
> +}
> +
> /*
> * growfs operations
> */
> @@ -74,36 +117,7 @@ xfs_growfs_data_private(
> if (error)
> return error;
>
> - /*
> - * Write new AG headers to disk. Non-transactional, but need to be
> - * written and completed prior to the growfs transaction being logged.
> - * To do this, we use a delayed write buffer list and wait for
> - * submission and IO completion of the list as a whole. This allows the
> - * IO subsystem to merge all the AG headers in a single AG into a single
> - * IO and hide most of the latency of the IO from us.
> - *
> - * This also means that if we get an error whilst building the buffer
> - * list to write, we can cancel the entire list without having written
> - * anything.
> - */
> - INIT_LIST_HEAD(&id.buffer_list);
> - for (id.agno = nagcount - 1;
> - id.agno >= oagcount;
> - id.agno--, delta -= id.agsize) {
> -
> - if (id.agno == nagcount - 1)
> - id.agsize = nb -
> - (id.agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks);
> - else
> - id.agsize = mp->m_sb.sb_agblocks;
> -
> - error = xfs_ag_init_headers(mp, &id);
> - if (error) {
> - xfs_buf_delwri_cancel(&id.buffer_list);
> - goto out_trans_cancel;
> - }
> - }
> - error = xfs_buf_delwri_submit(&id.buffer_list);
> + error = xfs_resizefs_init_new_ags(mp, &id, oagcount, nagcount, &delta);
> if (error)
> goto out_trans_cancel;
>
> --
> 2.27.0
>
next prev parent reply other threads:[~2021-01-08 21:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 19:09 [PATCH v3 0/4] xfs: support shrinking free space in the last AG Gao Xiang
2021-01-08 19:09 ` [PATCH v3 1/4] xfs: rename `new' to `delta' in xfs_growfs_data_private() Gao Xiang
2021-01-08 21:23 ` Darrick J. Wong
2021-01-08 19:09 ` [PATCH v3 2/4] xfs: get rid of xfs_growfs_{data,log}_t Gao Xiang
2021-01-08 21:21 ` Darrick J. Wong
2021-01-08 21:27 ` Eric Sandeen
2021-01-09 0:49 ` Gao Xiang
2021-01-10 21:04 ` Dave Chinner
2021-01-11 0:17 ` Gao Xiang
2021-01-11 17:30 ` Christoph Hellwig
2021-01-11 18:02 ` Gao Xiang
2021-01-08 19:09 ` [PATCH v3 3/4] xfs: hoist out xfs_resizefs_init_new_ags() Gao Xiang
2021-01-08 21:20 ` Darrick J. Wong [this message]
2021-01-11 17:32 ` Christoph Hellwig
2021-01-11 17:47 ` Gao Xiang
2021-01-08 19:09 ` [PATCH v3 4/4] xfs: support shrinking unused space in the last AG Gao Xiang
2021-01-08 21:19 ` Darrick J. Wong
2021-01-09 0:47 ` Gao Xiang
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=20210108212016.GR38809@magnolia \
--to=darrick.wong@oracle.com \
--cc=bfoster@redhat.com \
--cc=hsiangkao@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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