Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>
To: linux-xfs@vger.kernel.org
Cc: ritesh.list@gmail.com, ojaswin@linux.ibm.com, djwong@kernel.org,
	bfoster@redhat.com, david@fromorbit.com,
	hsiangkao@linux.alibaba.com
Subject: Re: [RFC V2 0/3] Add support to shrink multiple empty AGs
Date: Tue, 16 Sep 2025 20:44:12 +0530	[thread overview]
Message-ID: <261b9066-6480-45ee-845a-7fb34851ce0f@gmail.com> (raw)
In-Reply-To: <cover.1758034274.git.nirjhar.roy.lists@gmail.com>


On 9/16/25 20:34, Nirjhar Roy (IBM) wrote:
> This work is based on a previous RFC[1] by Gao Xiang and various ideas
> proposed by Dave Chinner in the RFC[1].
>
> Currently the functionality of shrink is limited to shrinking the last
> AG partially but not beyond that. This patch extends the functionality
> to support shrinking beyond 1 AG. However the AGs that we will be remove
> have to empty in order to prevent any loss of data.
>
> The patch begins with the re-introduction of some of the data
> structures that were removed, some code refactoring and
> finally the patch that implements the multi AG shrink design.
> The final patch has all the details including the definition of the
> terminologies and the overall design.
>
> We will have the tests soon.

Tests are here[1]

[1] 
https://lore.kernel.org/all/cover.1758035262.git.nirjhar.roy.lists@gmail.com/

--NR

>
> [rfc_v1] --> v2
> 1) Function renamings:
>      1.a xfs_activate_ag() -> xfs_perag_activate()
>      1.b xfs_deactivate_ag() -> xfs_perag_deactivate()
>      1.c xfs_pag_populate_cached_bufs() -> xfs_buf_cache_grab_all()
>      1.d xfs_buf_offline_perag_rele_cached() -> xfs_buf_cache_invalidate()
>      1.e xfs_extent_busy_wait_range() -> xfs_extent_busy_wait_ags()
>      1.f xfs_growfs_get_delta() -> xfs_growfs_compute_delta()
>
> 2) Fixed several coding style fixes and typos in the code and
>     commit messages.
>
> 3) Introduced for_each_perag_range_reverse() macro and used in
>     instead of using for loops directly.
>
> 4) Design changes:
>     4.a In function xfs_ag_is_empty() - Removed the
>         ASSERT(!xfs_ag_contains_log(mp, pag_agno(pag)));
>     4.b In function xfs_shrinkfs_reactivate_ags() - Replaced
>         if (nagcount >= oagcount) return; with ASSERT(nagcount < oagcount);
>     4.c In function xfs_perag_deactivate() - Add one extra step where
>         we manually reduce/reserve (pagf_freeblks + pagf_flcount) worth of
>         free datablocks from the global counters. This is necessary
>         in order to prevent a race where, some AGs have been temporarily
>         offlined but the delayed allocator has already promised some bytes
>         and later the real extent/block allocation is failing due to
>         the AG(s) being offline.
>     4.d In function xfs_perag_activate() - Add one extra step where
>         we restore the global free block counter which we reduced in
>         xfs_perag_deactivate.
>     4.e In function xfs_shrinkfs_deactivate_ags() -
>             1. Flushing the xfs_discard_wq after the log force/flush.
> 	   2. Removed the direct usage of xfs_log_quiesce(). The reason
> 	      is that xfs_log_quiesce() is expected to be called when the
> 	      caller has made sure that the log/filesystem is idle but
> 	      for shrink, we don't necessarily need the log/filesystem
> 	      to be idle.
> 	      However, we still need the checkpointing to take place,
> 	      so we are doing a xfs_sync_sb+AIL flush twice - something
> 	      similar that is being done in xfs_log_cover().
> 	      More details are in the patch.
>             3. Moved the entire code of ag stabilization (after ag
> 	      offlining) into a separate function -
> 	      xfs_shrinkfs_stabilize_ags().
>     4.f Fixed a bug where if the size of the new tail AG was less than
>         XFS_MIN_AG_BLOCKS, then shrink was passing - the correct behavior
>         is to fail with -EINVAL. Thank you Ritesh[2] for pointing this out.
>
> 5) Added RBs from Darrick in patch 1/3 and patch 2/3 (after addressing his
>     comments).
>
> [1] https://lore.kernel.org/all/20210414195240.1802221-1-hsiangkao@redhat.com/
> [2] https://lore.kernel.org/all/875xfas2f6.fsf@gmail.com/
> [rfc_v1] https://lore.kernel.org/all/cover.1752746805.git.nirjhar.roy.lists@gmail.com/
>
> Nirjhar Roy (IBM) (3):
>    xfs: Re-introduce xg_active_wq field in struct xfs_group
>    xfs: Refactoring the nagcount and delta calculation
>    xfs: Add support to shrink multiple empty AGs
>
>   fs/xfs/libxfs/xfs_ag.c        | 193 +++++++++++++++++-
>   fs/xfs/libxfs/xfs_ag.h        |  17 ++
>   fs/xfs/libxfs/xfs_alloc.c     |   9 +-
>   fs/xfs/libxfs/xfs_group.c     |   4 +-
>   fs/xfs/libxfs/xfs_group.h     |   2 +
>   fs/xfs/xfs_buf.c              |  78 ++++++++
>   fs/xfs/xfs_buf.h              |   1 +
>   fs/xfs/xfs_buf_item_recover.c |  37 ++--
>   fs/xfs/xfs_extent_busy.c      |  30 +++
>   fs/xfs/xfs_extent_busy.h      |   2 +
>   fs/xfs/xfs_fsops.c            | 358 +++++++++++++++++++++++++++++++---
>   fs/xfs/xfs_trans.c            |   1 -
>   12 files changed, 678 insertions(+), 54 deletions(-)
>
> --
> 2.43.5
>
-- 
Nirjhar Roy
Linux Kernel Developer
IBM, Bangalore


      parent reply	other threads:[~2025-09-16 15:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16 15:04 [RFC V2 0/3] Add support to shrink multiple empty AGs Nirjhar Roy (IBM)
2025-09-16 15:04 ` [RFC V2 1/3] xfs: Re-introduce xg_active_wq field in struct xfs_group Nirjhar Roy (IBM)
2025-09-16 15:04 ` [RFC V2 2/3] xfs: Refactoring the nagcount and delta calculation Nirjhar Roy (IBM)
2025-09-16 15:04 ` [RFC V2 3/3] xfs: Add support to shrink multiple empty AGs Nirjhar Roy (IBM)
2025-10-14 23:13   ` Darrick J. Wong
2025-10-15 11:02     ` Nirjhar Roy (IBM)
2025-10-15 19:26       ` Darrick J. Wong
2025-10-16  9:16         ` Nirjhar Roy (IBM)
2025-10-16 15:53           ` Darrick J. Wong
2025-10-16 16:34             ` Nirjhar Roy (IBM)
2025-10-17 23:07               ` Darrick J. Wong
2025-10-21  4:42                 ` Nirjhar Roy (IBM)
2025-09-16 15:14 ` Nirjhar Roy (IBM) [this message]

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=261b9066-6480-45ee-845a-7fb34851ce0f@gmail.com \
    --to=nirjhar.roy.lists@gmail.com \
    --cc=bfoster@redhat.com \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    /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