btrfs: consolidate btrfs_previous_item ret val handling in btrfs_shrink_device
authorNikolay Borisov <nborisov@suse.com>
Thu, 17 Dec 2020 13:21:16 +0000 (15:21 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Feb 2021 21:58:51 +0000 (22:58 +0100)
Instead of having three 'if' to handle non-NULL return value consolidate
this in one 'if (ret)'. That way the code is more obvious:

 - Always drop delete_unused_bgs_mutex if ret is not NULL
 - If ret is negative -> goto done
 - If it's 1 -> reset ret to 0, release the path and finish the loop.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index d6c24c8..a8ec853 100644 (file)
@@ -4668,11 +4668,10 @@ again:
                }
 
                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;