xfs: fix xfs_ifree() error handling to not leak perag ref
PATCH 1/1 xfs: fix xfs_ifree() error handling to not leak perag ref
For some reason commit 9a5280b312e2e ("xfs: reorder iunlink remove operation in xfs_ifree") replaced a jump to the exit path in the event of an xfs_difree() error with a direct return, which skips releasing the perag reference acquired at the top of the function. Restore the original code to drop the reference on error.
--- fs/xfs/xfs_inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_inode.c +1 -1
@@ -2622,7 +2622,7 @@ xfs_ifree(*/ error =xfs_difree (tp, pag, ip->i_ino, &xic);if (error) -return error; + goto out; error =xfs_iunlink_remove (tp, pag, ip);if (error)
Signature · 1 line
2.34.1
Quoted 8 lines · Brian Foster
For some reason commit
9a5280b312e2e("xfs: reorder iunlink remove operation inxfs_ifree") replaced a jump to the exit path in the event of anxfs_difree()error with a direct return, which skips releasing the perag reference acquired at the top of the function. Restore the original code to drop the reference on error.Fixes 9a5280b312e2e ("xfs: reorder iunlink remove operation in xfs_ifree")Signed-off-by Brian Foster <[email protected]>
Doh. Good catch!
--D
Quoted 20 lines
--- fs/xfs/xfs_inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_inode.c +1
-1@@ -2622,7 +2622,7 @@ xfs_ifree(*/ error =xfs_difree (tp, pag, ip->i_ino, &xic);if (error) -return error; + goto out; error =xfs_iunlink_remove (tp, pag, ip);if (error)Signature · 1 line
2.34.1
Quoted 3 lines · Brian Foster
For some reason commit
9a5280b312e2e("xfs: reorder iunlink remove operation inxfs_ifree") replaced a jump to the exit path in the event of anxfs_difree()error with a direct return, which skips
Reason: the patchset that the fix was promoted from had moved all the pag handling out of xfs_ifree to the caller, so direct return was, in fact, the correct behaviour in the code it originated from.
The patch applied to upstream with no errors or fuzz, and I had completely forgotten that somewhere in the ~50 patches in the stack before that fix had completely reworked unlink pag handling...
How did you find this? I haven't noticed any specific increase in unmount perag accounting leaks as a result of this, so I'm curious as to how you noticed it and isolated it to this specific bug.
Quoted 13 lines
Restore the original code to drop the reference on error.
Fixes 9a5280b312e2e ("xfs: reorder iunlink remove operation in xfs_ifree")Signed-off-by Brian Foster <[email protected]>--- fs/xfs/xfs_inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_inode.c +0
-0
fs/xfs/xfs_inode.c xfs_ifree( · line 2625
Quoted 5 lines
fs/xfs/xfs_inode.c +1
-1@@ -2622,7 +2622,7 @@ xfs_ifree(*/ error =xfs_difree (tp, pag, ip->i_ino, &xic);if (error) -return error; + goto out;
Looks good,
Signature · 2 lines
Dave Chinner [email protected]