On Jul 17, 2025, at 00:02, Darrick J. Wong <djwong@xxxxxxxxxx> wrote: > > On Wed, Jul 16, 2025 at 02:54:05PM +0200, Christoph Hellwig wrote: >> From: George Hu <integral@xxxxxxxxxxxxx> >> >> 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@xxxxxxxxxxxxx> >> Reviewed-by: John Garry <john.g.garry@xxxxxxxxxx> >> --- >> 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? No, it only has BUILD_BUG_ON_MSG(statically_true(ulo > uhi), “xxx") > 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