* [PATCH] btrfs: Consolidate btrfs_previous_item ret val handling in btrfs_shrink_device
@ 2020-12-17 13:21 Nikolay Borisov
2020-12-17 14:44 ` Josef Bacik
2020-12-21 17:02 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Nikolay Borisov @ 2020-12-17 13:21 UTC (permalink / raw)
To: linux-btrfs; +Cc: 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_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.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/volumes.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 7930e1c78c45..a34eded1bfbe 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -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;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Consolidate btrfs_previous_item ret val handling in btrfs_shrink_device
2020-12-17 13:21 [PATCH] btrfs: Consolidate btrfs_previous_item ret val handling in btrfs_shrink_device Nikolay Borisov
@ 2020-12-17 14:44 ` Josef Bacik
2020-12-21 17:02 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2020-12-17 14:44 UTC (permalink / raw)
To: Nikolay Borisov, linux-btrfs
On 12/17/20 8:21 AM, Nikolay Borisov wrote:
> 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.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Consolidate btrfs_previous_item ret val handling in btrfs_shrink_device
2020-12-17 13:21 [PATCH] btrfs: Consolidate btrfs_previous_item ret val handling in btrfs_shrink_device Nikolay Borisov
2020-12-17 14:44 ` Josef Bacik
@ 2020-12-21 17:02 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2020-12-21 17:02 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Thu, Dec 17, 2020 at 03:21:16PM +0200, Nikolay Borisov wrote:
> 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.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-21 17:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17 13:21 [PATCH] btrfs: Consolidate btrfs_previous_item ret val handling in btrfs_shrink_device Nikolay Borisov
2020-12-17 14:44 ` Josef Bacik
2020-12-21 17:02 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.