From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 10/10] xfs: factor the ag length extension code into libxfs
Date: Fri, 11 May 2018 18:48:30 -0700 [thread overview]
Message-ID: <20180512014830.GV11261@magnolia> (raw)
In-Reply-To: <20180511225107.27171-11-david@fromorbit.com>
On Sat, May 12, 2018 at 08:51:07AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Growfs currently manually codes teh extension of the last AG in a
> filesytem during the growfs process. Factor that out of the growfs
> code and move it into libxfs along with teh rest of the AG header
> modification code.
>
> Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Looks ok, will give this a spin...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/libxfs/xfs_ag.c | 60 ++++++++++++++++++++++++++++++++++++++++++
> fs/xfs/libxfs/xfs_ag.h | 7 ++++-
> fs/xfs/xfs_fsops.c | 58 ++--------------------------------------
> 3 files changed, 68 insertions(+), 57 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
> index 638bc162afb5..81c3c5b2fa65 100644
> --- a/fs/xfs/libxfs/xfs_ag.c
> +++ b/fs/xfs/libxfs/xfs_ag.c
> @@ -16,6 +16,7 @@
> #include "xfs_alloc_btree.h"
> #include "xfs_rmap_btree.h"
> #include "xfs_alloc.h"
> +#include "xfs_ialloc.h"
> #include "xfs_rmap.h"
> #include "xfs_ag.h"
>
> @@ -374,3 +375,62 @@ xfs_ag_init_headers(
> }
> return error;
> }
> +
> +/*
> + * Extent the AG indicated by the @id by the length passed in
> + */
> +int
> +xfs_ag_extend_space(
> + struct xfs_mount *mp,
> + struct xfs_trans *tp,
> + struct aghdr_init_data *id,
> + xfs_extlen_t len)
> +{
> + struct xfs_owner_info oinfo;
> + struct xfs_buf *bp;
> + struct xfs_agi *agi;
> + struct xfs_agf *agf;
> + int error;
> +
> + /*
> + * Change the agi length.
> + */
> + error = xfs_ialloc_read_agi(mp, tp, id->agno, &bp);
> + if (error)
> + return error;
> +
> + agi = XFS_BUF_TO_AGI(bp);
> + be32_add_cpu(&agi->agi_length, len);
> + ASSERT(id->agno == mp->m_sb.sb_agcount - 1 ||
> + be32_to_cpu(agi->agi_length) == mp->m_sb.sb_agblocks);
> + xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH);
> +
> + /*
> + * Change agf length.
> + */
> + error = xfs_alloc_read_agf(mp, tp, id->agno, 0, &bp);
> + if (error)
> + return error;
> +
> + agf = XFS_BUF_TO_AGF(bp);
> + be32_add_cpu(&agf->agf_length, len);
> + ASSERT(agf->agf_length == agi->agi_length);
> + xfs_alloc_log_agf(tp, bp, XFS_AGF_LENGTH);
> +
> + /*
> + * Free the new space.
> + *
> + * XFS_RMAP_OWN_NULL is used here to tell the rmap btree that
> + * this doesn't actually exist in the rmap btree.
> + */
> + xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_NULL);
> + error = xfs_rmap_free(tp, bp, id->agno,
> + be32_to_cpu(agf->agf_length) - len,
> + len, &oinfo);
> + if (error)
> + return error;
> +
> + return xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, id->agno,
> + be32_to_cpu(agf->agf_length) - len),
> + len, &oinfo, XFS_AG_RESV_NONE);
> +}
> diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h
> index 788f37df6610..695953db41e5 100644
> --- a/fs/xfs/libxfs/xfs_ag.h
> +++ b/fs/xfs/libxfs/xfs_ag.h
> @@ -7,6 +7,9 @@
> #ifndef __LIBXFS_AG_H
> #define __LIBXFS_AG_H 1
>
> +struct xfs_mount;
> +struct xfs_trans;
> +
> struct aghdr_init_data {
> /* per ag data */
> xfs_agblock_t agno; /* ag to init */
> @@ -21,6 +24,8 @@ struct aghdr_init_data {
> int numrecs; /* recs in btree root block */
> };
>
> -int xfs_ag_init_headers( struct xfs_mount *mp, struct aghdr_init_data *id);
> +int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id);
> +int xfs_ag_extend_space(struct xfs_mount *mp, struct xfs_trans *tp,
> + struct aghdr_init_data *id, xfs_extlen_t len);
>
> #endif /* __LIBXFS_AG_H */
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index c5087b79bcea..bc7ef18da243 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -27,16 +27,12 @@
> #include "xfs_trans.h"
> #include "xfs_error.h"
> #include "xfs_btree.h"
> -#include "xfs_alloc_btree.h"
> #include "xfs_alloc.h"
> -#include "xfs_rmap_btree.h"
> -#include "xfs_ialloc.h"
> #include "xfs_fsops.h"
> #include "xfs_trans_space.h"
> #include "xfs_rtalloc.h"
> #include "xfs_trace.h"
> #include "xfs_log.h"
> -#include "xfs_rmap.h"
> #include "xfs_ag.h"
> #include "xfs_ag_resv.h"
>
> @@ -48,8 +44,6 @@ xfs_growfs_data_private(
> xfs_mount_t *mp, /* mount point for filesystem */
> xfs_growfs_data_t *in) /* growfs data input struct */
> {
> - xfs_agf_t *agf;
> - xfs_agi_t *agi;
> xfs_buf_t *bp;
> int error;
> xfs_agnumber_t nagcount;
> @@ -132,57 +126,9 @@ xfs_growfs_data_private(
>
> xfs_trans_agblocks_delta(tp, id.nfree);
>
> - /*
> - * There are new blocks in the old last a.g.
> - */
> + /* If there are new blocks in the old last AG, extend it. */
> if (new) {
> - struct xfs_owner_info oinfo;
> -
> - /*
> - * Change the agi length.
> - */
> - error = xfs_ialloc_read_agi(mp, tp, id.agno, &bp);
> - if (error)
> - goto out_trans_cancel;
> -
> - ASSERT(bp);
> - agi = XFS_BUF_TO_AGI(bp);
> - be32_add_cpu(&agi->agi_length, new);
> - ASSERT(nagcount == oagcount ||
> - be32_to_cpu(agi->agi_length) == mp->m_sb.sb_agblocks);
> - xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH);
> -
> - /*
> - * Change agf length.
> - */
> - error = xfs_alloc_read_agf(mp, tp, id.agno, 0, &bp);
> - if (error)
> - goto out_trans_cancel;
> -
> - ASSERT(bp);
> - agf = XFS_BUF_TO_AGF(bp);
> - be32_add_cpu(&agf->agf_length, new);
> - ASSERT(be32_to_cpu(agf->agf_length) ==
> - be32_to_cpu(agi->agi_length));
> -
> - xfs_alloc_log_agf(tp, bp, XFS_AGF_LENGTH);
> -
> - /*
> - * Free the new space.
> - *
> - * XFS_RMAP_OWN_NULL is used here to tell the rmap btree that
> - * this doesn't actually exist in the rmap btree.
> - */
> - xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_NULL);
> - error = xfs_rmap_free(tp, bp, id.agno,
> - be32_to_cpu(agf->agf_length) - new,
> - new, &oinfo);
> - if (error)
> - goto out_trans_cancel;
> - error = xfs_free_extent(tp,
> - XFS_AGB_TO_FSB(mp, id.agno,
> - be32_to_cpu(agf->agf_length) - new),
> - new, &oinfo, XFS_AG_RESV_NONE);
> + error = xfs_ag_extend_space(mp, tp, &id, new);
> if (error)
> goto out_trans_cancel;
> }
> --
> 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
next prev parent reply other threads:[~2018-05-12 1:48 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
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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-05-14 4:18 [PATCH 0/10 v3] xfs: refactor and tablise growfs Dave Chinner
2018-05-14 4:19 ` [PATCH 10/10] xfs: factor the ag length extension code into libxfs 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=20180512014830.GV11261@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 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).