From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>,
Hans Holmberg <hans.holmberg@wdc.com>,
linux-xfs@vger.kernel.org, George Hu <integral@archlinux.org>,
John Garry <john.g.garry@oracle.com>
Subject: Re: [PATCH 5/7] xfs: replace min & max with clamp() in xfs_max_open_zones()
Date: Wed, 16 Jul 2025 09:02:06 -0700 [thread overview]
Message-ID: <20250716160206.GL2672049@frogsfrogsfrogs> (raw)
In-Reply-To: <20250716125413.2148420-6-hch@lst.de>
On Wed, Jul 16, 2025 at 02:54:05PM +0200, Christoph Hellwig wrote:
> From: George Hu <integral@archlinux.org>
>
> Refactor the xfs_max_open_zones() function by replacing the usage of
> min() and max() macro with clamp() to simplify the code and improve
> readability.
>
> Signed-off-by: George Hu <integral@archlinux.org>
> Reviewed-by: John Garry <john.g.garry@oracle.com>
> ---
> fs/xfs/xfs_zone_alloc.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
> index 729d80ff52c1..d9e2b1411434 100644
> --- a/fs/xfs/xfs_zone_alloc.c
> +++ b/fs/xfs/xfs_zone_alloc.c
> @@ -1133,9 +1133,7 @@ xfs_max_open_zones(
> /*
> * Cap the max open limit to 1/4 of available space
> */
> - max_open = min(max_open, mp->m_sb.sb_rgcount / 4);
> -
> - return max(XFS_MIN_OPEN_ZONES, max_open);
> + return clamp(max_open, XFS_MIN_OPEN_ZONES, mp->m_sb.sb_rgcount / 4);
Does clamp() handle the case where @max < @min properly?
I'm worried about shenanigans on a runt 7-zone drive, though I can't
remember off the top of my head if we actually prohibit that...
--D
> }
>
> /*
> --
> 2.47.2
>
>
next prev parent reply other threads:[~2025-07-16 16:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 12:54 misc zoned allocators fixes and cleanups Christoph Hellwig
2025-07-16 12:54 ` [PATCH 1/7] xfs: don't allocate the xfs_extent_busy structure for zoned RTGs Christoph Hellwig
2025-07-16 15:50 ` Darrick J. Wong
2025-07-17 8:11 ` Carlos Maiolino
2025-07-16 12:54 ` [PATCH 2/7] xfs: use a uint32_t to cache i_used_blocks in xfs_init_zone Christoph Hellwig
2025-07-16 15:51 ` Darrick J. Wong
2025-07-16 12:54 ` [PATCH 3/7] xfs: rename oz_write_pointer to oz_allocated Christoph Hellwig
2025-07-16 15:58 ` Darrick J. Wong
2025-07-16 12:54 ` [PATCH 4/7] xfs: stop passing an inode to the zone space reservation helpers Christoph Hellwig
2025-07-16 15:59 ` Darrick J. Wong
2025-07-16 12:54 ` [PATCH 5/7] xfs: replace min & max with clamp() in xfs_max_open_zones() Christoph Hellwig
2025-07-16 16:02 ` Darrick J. Wong [this message]
2025-07-16 16:52 ` Alan Huang
2025-07-17 5:16 ` Christoph Hellwig
2025-07-17 6:42 ` Alan Huang
2025-07-16 12:54 ` [PATCH 6/7] xfs: improve the comments in xfs_max_open_zones Christoph Hellwig
2025-07-16 16:03 ` Darrick J. Wong
2025-07-16 12:54 ` [PATCH 7/7] xfs: improve the comments in xfs_select_zone_nowait Christoph Hellwig
2025-07-16 16:03 ` 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=20250716160206.GL2672049@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hans.holmberg@wdc.com \
--cc=hch@lst.de \
--cc=integral@archlinux.org \
--cc=john.g.garry@oracle.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).