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 <[email protected]>
---
 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

Reply via email to