From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Chandan Babu R <chandan.babu@oracle.com>,
"Darrick J. Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/7] xfs: merge the perag freeing helpers
Date: Thu, 10 Oct 2024 10:02:59 -0400 [thread overview]
Message-ID: <Zwfek7DWa-MNRTRu@bfoster> (raw)
In-Reply-To: <20240930164211.2357358-3-hch@lst.de>
On Mon, Sep 30, 2024 at 06:41:43PM +0200, Christoph Hellwig wrote:
> There is no good reason to have two different routines for freeing perag
> structures for the unmount and error cases. Add two arguments to specify
> the range of AGs to free to xfs_free_perag, and use that to replace
> xfs_free_unused_perag_range.
>
> The addition RCU grace period for the error case is harmless, and the
> extra check for the AG to actually exist is not required now that the
> callers pass the exact known allocated range.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/libxfs/xfs_ag.c | 40 ++++++++++------------------------------
> fs/xfs/libxfs/xfs_ag.h | 5 ++---
> fs/xfs/xfs_fsops.c | 2 +-
> fs/xfs/xfs_mount.c | 5 ++---
> 4 files changed, 15 insertions(+), 37 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
> index 652376aa52e990..8fac0ce45b1559 100644
> --- a/fs/xfs/libxfs/xfs_ag.c
> +++ b/fs/xfs/libxfs/xfs_ag.c
> @@ -185,17 +185,20 @@ xfs_initialize_perag_data(
> }
>
> /*
> - * Free up the per-ag resources associated with the mount structure.
> + * Free up the per-ag resources within the specified AG range.
> */
> void
> -xfs_free_perag(
> - struct xfs_mount *mp)
> +xfs_free_perag_range(
> + struct xfs_mount *mp,
> + xfs_agnumber_t first_agno,
> + xfs_agnumber_t end_agno)
> +
> {
> - struct xfs_perag *pag;
> xfs_agnumber_t agno;
>
> - for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
> - pag = xa_erase(&mp->m_perags, agno);
> + for (agno = first_agno; agno < end_agno; agno++) {
> + struct xfs_perag *pag = xa_erase(&mp->m_perags, agno);
> +
> ASSERT(pag);
> XFS_IS_CORRUPT(pag->pag_mount, atomic_read(&pag->pag_ref) != 0);
> xfs_defer_drain_free(&pag->pag_intents_drain);
> @@ -270,29 +273,6 @@ xfs_agino_range(
> return __xfs_agino_range(mp, xfs_ag_block_count(mp, agno), first, last);
> }
>
> -/*
> - * Free perag within the specified AG range, it is only used to free unused
> - * perags under the error handling path.
> - */
> -void
> -xfs_free_unused_perag_range(
> - struct xfs_mount *mp,
> - xfs_agnumber_t agstart,
> - xfs_agnumber_t agend)
> -{
> - struct xfs_perag *pag;
> - xfs_agnumber_t index;
> -
> - for (index = agstart; index < agend; index++) {
> - pag = xa_erase(&mp->m_perags, index);
> - if (!pag)
> - break;
> - xfs_buf_cache_destroy(&pag->pag_bcache);
> - xfs_defer_drain_free(&pag->pag_intents_drain);
> - kfree(pag);
> - }
> -}
> -
> int
> xfs_initialize_perag(
> struct xfs_mount *mp,
> @@ -369,7 +349,7 @@ xfs_initialize_perag(
> out_free_pag:
> kfree(pag);
> out_unwind_new_pags:
> - xfs_free_unused_perag_range(mp, old_agcount, index);
> + xfs_free_perag_range(mp, old_agcount, index);
> return error;
> }
>
> diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h
> index 69fc31e7b84728..6e68d6a3161a0f 100644
> --- a/fs/xfs/libxfs/xfs_ag.h
> +++ b/fs/xfs/libxfs/xfs_ag.h
> @@ -144,13 +144,12 @@ __XFS_AG_OPSTATE(prefers_metadata, PREFERS_METADATA)
> __XFS_AG_OPSTATE(allows_inodes, ALLOWS_INODES)
> __XFS_AG_OPSTATE(agfl_needs_reset, AGFL_NEEDS_RESET)
>
> -void xfs_free_unused_perag_range(struct xfs_mount *mp, xfs_agnumber_t agstart,
> - xfs_agnumber_t agend);
> int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t old_agcount,
> xfs_agnumber_t agcount, xfs_rfsblock_t dcount,
> xfs_agnumber_t *maxagi);
> +void xfs_free_perag_range(struct xfs_mount *mp, xfs_agnumber_t first_agno,
> + xfs_agnumber_t end_agno);
> int xfs_initialize_perag_data(struct xfs_mount *mp, xfs_agnumber_t agno);
> -void xfs_free_perag(struct xfs_mount *mp);
>
> /* Passive AG references */
> struct xfs_perag *xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno);
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index de2bf0594cb474..b247d895c276d2 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -229,7 +229,7 @@ xfs_growfs_data_private(
> xfs_trans_cancel(tp);
> out_free_unused_perag:
> if (nagcount > oagcount)
> - xfs_free_unused_perag_range(mp, oagcount, nagcount);
> + xfs_free_perag_range(mp, oagcount, nagcount);
> return error;
> }
>
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 6fa7239a4a01b6..25bbcc3f4ee08b 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -1048,7 +1048,7 @@ xfs_mountfs(
> xfs_buftarg_drain(mp->m_logdev_targp);
> xfs_buftarg_drain(mp->m_ddev_targp);
> out_free_perag:
> - xfs_free_perag(mp);
> + xfs_free_perag_range(mp, 0, mp->m_sb.sb_agcount);
> out_free_dir:
> xfs_da_unmount(mp);
> out_remove_uuid:
> @@ -1129,8 +1129,7 @@ xfs_unmountfs(
> xfs_errortag_clearall(mp);
> #endif
> shrinker_free(mp->m_inodegc_shrinker);
> - xfs_free_perag(mp);
> -
> + xfs_free_perag_range(mp, 0, mp->m_sb.sb_agcount);
> xfs_errortag_del(mp);
> xfs_error_sysfs_del(mp);
> xchk_stats_unregister(mp->m_scrub_stats);
> --
> 2.45.2
>
>
next prev parent reply other threads:[~2024-10-10 14:01 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 16:41 fix recovery of allocator ops after a growfs Christoph Hellwig
2024-09-30 16:41 ` [PATCH 1/7] xfs: pass the exact range to initialize to xfs_initialize_perag Christoph Hellwig
2024-10-10 14:02 ` Brian Foster
2024-10-11 7:53 ` Christoph Hellwig
2024-10-11 14:01 ` Brian Foster
2024-09-30 16:41 ` [PATCH 2/7] xfs: merge the perag freeing helpers Christoph Hellwig
2024-10-10 14:02 ` Brian Foster [this message]
2024-09-30 16:41 ` [PATCH 3/7] xfs: update the file system geometry after recoverying superblock buffers Christoph Hellwig
2024-09-30 16:50 ` Darrick J. Wong
2024-10-01 8:49 ` Christoph Hellwig
2024-10-10 16:02 ` Darrick J. Wong
2024-10-10 14:03 ` Brian Foster
2024-09-30 16:41 ` [PATCH 4/7] xfs: error out when a superblock buffer updates reduces the agcount Christoph Hellwig
2024-09-30 16:51 ` Darrick J. Wong
2024-10-01 8:47 ` Christoph Hellwig
2024-10-10 14:04 ` Brian Foster
2024-09-30 16:41 ` [PATCH 5/7] xfs: don't use __GFP_RETRY_MAYFAIL in xfs_initialize_perag Christoph Hellwig
2024-10-10 14:04 ` Brian Foster
2024-09-30 16:41 ` [PATCH 6/7] xfs: don't update file system geometry through transaction deltas Christoph Hellwig
2024-10-10 14:05 ` Brian Foster
2024-10-11 7:57 ` Christoph Hellwig
2024-10-11 14:02 ` Brian Foster
2024-10-11 17:13 ` Darrick J. Wong
2024-10-11 18:41 ` Brian Foster
2024-10-11 23:12 ` Darrick J. Wong
2024-10-11 23:29 ` Darrick J. Wong
2024-10-14 5:58 ` Christoph Hellwig
2024-10-14 15:30 ` Darrick J. Wong
2024-10-14 18:50 ` Brian Foster
2024-10-15 16:42 ` Darrick J. Wong
2024-10-18 12:27 ` Brian Foster
2024-10-21 16:59 ` Darrick J. Wong
2024-10-23 14:45 ` Brian Foster
2024-10-24 18:02 ` Darrick J. Wong
2024-10-21 13:38 ` Dave Chinner
2024-10-23 15:06 ` Brian Foster
2024-10-10 19:01 ` Darrick J. Wong
2024-10-11 7:59 ` Christoph Hellwig
2024-10-11 16:44 ` Darrick J. Wong
2024-09-30 16:41 ` [PATCH 7/7] xfs: split xfs_trans_mod_sb Christoph Hellwig
2024-10-10 14:06 ` Brian Foster
2024-10-11 7:54 ` Christoph Hellwig
2024-10-11 14:05 ` Brian Foster
2024-10-11 16:50 ` Darrick J. Wong
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=Zwfek7DWa-MNRTRu@bfoster \
--to=bfoster@redhat.com \
--cc=chandan.babu@oracle.com \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--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