xfs: improve the xg_active_ref check in xfs_group_free
PATCH 1/1 xfs: improve the xg_active_ref check in xfs_group_free
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.
--- fs/xfs/libxfs/xfs_group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_group.c +2 -1
@@ -172,7 +172,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); }
Signature · 1 line
2.47.2
Quoted 2 lines · Christoph Hellwig
Split up the
XFS_IS_CORRUPTstatement so that it immediately shows if the reference counter overflowed or underflowed.
Should we be using refcount_t for xg_active_ref to detect over/underflows, then?
Quoted 6 lines
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 <[email protected]>
Looks fine though,
--D
Quoted 22 lines
--- fs/xfs/libxfs/xfs_group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/xfs/libxfs/xfs_group.c +2
-1@@ -172,7 +172,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); }Signature · 1 line
2.47.2
Quoted 6 lines · Darrick J. Wong
Quoted 2 lines · Christoph Hellwig
Split up the
XFS_IS_CORRUPTstatement so that it immediately shows if the reference counter overflowed or underflowed.Should we be using
refcount_tforxg_active_refto detect over/underflows, then?
In theory yes. In practice refcount_t still has a lot of performance overhead, so using it in something used a lot in the fast path might not be a good idea.
Quoted 9 lines · Christoph Hellwig
Split up the
XFS_IS_CORRUPTstatement 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.
[...]
Applied to for-next, thanks!
[1/1] xfs: improve the xg_active_ref check in xfs_group_free
commit: a10f18bc67785b947396ddd0529b3df7df3d5d6f
Best regards,
Signature · 1 line
Carlos Maiolino <[email protected]>