From: Christoph Hellwig Date: Mon, 6 Oct 2025 12:40:18 +0000 (+0200) Subject: xfs: improve the xg_active_ref check in xfs_group_free X-Git-Tag: v6.17.0~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c6135e4201a1290d9d62a3e5f437b5745ad9c16c;p=thirdparty%2Fxfsprogs-dev.git xfs: improve the xg_active_ref check in xfs_group_free Source kernel commit: 59655147ec34fb72cc090ca4ee688ece05ffac56 Split up the XFS_IS_CORRUPT statement so that it immediately shows if the reference counter overflowed or underflowed. I ran into this quite a bit when developing the zoned allocator, and had to reapply the patch for some work recently. We might as well just apply it upstream given that freeing group is far removed from performance critical code. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino Signed-off-by: Andrey Albershteyn Reviewed-by: "Darrick J. Wong" --- diff --git a/libxfs/xfs_group.c b/libxfs/xfs_group.c index b7ac9dbd..03c50824 100644 --- a/libxfs/xfs_group.c +++ b/libxfs/xfs_group.c @@ -170,7 +170,8 @@ xfs_group_free( /* drop the mount's active reference */ xfs_group_rele(xg); - XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_active_ref) != 0); + XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_active_ref) > 0); + XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_active_ref) < 0); kfree_rcu_mightsleep(xg); }