btrfs: Consolidate btrfs_previous_item ret val handling in btrfs_shrink_device
PATCH 1/1 btrfs: Consolidate btrfs_previous_item ret val handling in btrfs_shrink_device
Instead of having 3 'if' to handle non-null return value consolidate this in 1 'if (ret)'. That way the code is more obvious:
- Always drop dlete_unused_bgs_mutex if ret is non null
- If ret is negative -> goto done
- If it's 1 -> reset ret to 0, release the path and finish the loop.
--- fs/btrfs/volumes.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/btrfs/volumes.c +3 -4
@@ -4667,11 +4667,10 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) } ret =btrfs_previous_item (root, path,0 , key.type); -if (ret) -mutex_unlock (&fs_info->delete_unused_bgs_mutex); -if (ret <0 ) - goto done;if (ret) { +mutex_unlock (&fs_info->delete_unused_bgs_mutex); +if (ret <0 ) + goto done; ret =0 ;btrfs_release_path (path);break ;
Signature · 1 line
2.25.1
Quoted 8 lines · Nikolay Borisov
Instead of having 3 'if' to handle non-null return value consolidate this in 1 'if (ret)'. That way the code is more obvious:
- Always drop
dlete_unused_bgs_mutexif ret is non null
- If ret is negative -> goto done
- If it's 1 -> reset ret to 0, release the path and finish the loop.Signed-off-by Nikolay Borisov <[email protected]>
Thanks,
Josef
Quoted 8 lines · Nikolay Borisov
Instead of having 3 'if' to handle non-null return value consolidate this in 1 'if (ret)'. That way the code is more obvious:
- Always drop
dlete_unused_bgs_mutexif ret is non null
- If ret is negative -> goto done
- If it's 1 -> reset ret to 0, release the path and finish the loop.Signed-off-by Nikolay Borisov <[email protected]>
Added to misc-next, thanks.