* [PATCH] xfs: replace min & max with clamp() in xfs_max_open_zones()
@ 2025-07-12 14:57 George Hu
2025-07-14 5:55 ` Christoph Hellwig
2025-07-14 7:58 ` John Garry
0 siblings, 2 replies; 5+ messages in thread
From: George Hu @ 2025-07-12 14:57 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs, linux-kernel, George Hu
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>
---
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 01315ed75502..58997afb1a14 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);
}
/*
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: replace min & max with clamp() in xfs_max_open_zones()
2025-07-12 14:57 [PATCH] xfs: replace min & max with clamp() in xfs_max_open_zones() George Hu
@ 2025-07-14 5:55 ` Christoph Hellwig
2025-07-14 7:58 ` John Garry
1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2025-07-14 5:55 UTC (permalink / raw)
To: George Hu; +Cc: Carlos Maiolino, linux-xfs, linux-kernel
On Sat, Jul 12, 2025 at 10:57:41PM +0800, George Hu wrote:
> 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.
Nit: you can use up to 73 characters in each commit message line:
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.
Otherwise looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: replace min & max with clamp() in xfs_max_open_zones()
2025-07-12 14:57 [PATCH] xfs: replace min & max with clamp() in xfs_max_open_zones() George Hu
2025-07-14 5:55 ` Christoph Hellwig
@ 2025-07-14 7:58 ` John Garry
2025-07-14 10:59 ` Christoph Hellwig
1 sibling, 1 reply; 5+ messages in thread
From: John Garry @ 2025-07-14 7:58 UTC (permalink / raw)
To: George Hu, Carlos Maiolino; +Cc: linux-xfs, linux-kernel
On 12/07/2025 15:57, George Hu wrote:
> 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>
FWIW,
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 01315ed75502..58997afb1a14 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
> */
Maybe you can keep this comment, but it was pretty much describing the
code and not explaining the rationale.
> - 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);
> }
>
> /*
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: replace min & max with clamp() in xfs_max_open_zones()
2025-07-14 7:58 ` John Garry
@ 2025-07-14 10:59 ` Christoph Hellwig
2025-07-15 9:49 ` Carlos Maiolino
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2025-07-14 10:59 UTC (permalink / raw)
To: John Garry; +Cc: George Hu, Carlos Maiolino, linux-xfs, linux-kernel
On Mon, Jul 14, 2025 at 08:58:59AM +0100, John Garry wrote:
> > @@ -1133,9 +1133,7 @@ xfs_max_open_zones(
> > /*
> > * Cap the max open limit to 1/4 of available space
> > */
>
> Maybe you can keep this comment, but it was pretty much describing the code
> and not explaining the rationale.
Let me send an incremental patch to explain the rational as long as I
can still remember it :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: replace min & max with clamp() in xfs_max_open_zones()
2025-07-14 10:59 ` Christoph Hellwig
@ 2025-07-15 9:49 ` Carlos Maiolino
0 siblings, 0 replies; 5+ messages in thread
From: Carlos Maiolino @ 2025-07-15 9:49 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: John Garry, George Hu, linux-xfs, linux-kernel
On Mon, Jul 14, 2025 at 03:59:27AM -0700, Christoph Hellwig wrote:
> On Mon, Jul 14, 2025 at 08:58:59AM +0100, John Garry wrote:
> > > @@ -1133,9 +1133,7 @@ xfs_max_open_zones(
> > > /*
> > > * Cap the max open limit to 1/4 of available space
> > > */
> >
> > Maybe you can keep this comment, but it was pretty much describing the code
> > and not explaining the rationale.
>
> Let me send an incremental patch to explain the rational as long as I
> can still remember it :)
Sounds good, I'll wait and merge both together.
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-15 9:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-12 14:57 [PATCH] xfs: replace min & max with clamp() in xfs_max_open_zones() George Hu
2025-07-14 5:55 ` Christoph Hellwig
2025-07-14 7:58 ` John Garry
2025-07-14 10:59 ` Christoph Hellwig
2025-07-15 9:49 ` Carlos Maiolino
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).