]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
btrfs: initialize ret to -ENOSPC at __reserve_bytes()
authorFilipe Manana <fdmanana@suse.com>
Tue, 21 Mar 2023 11:13:42 +0000 (11:13 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Apr 2023 16:01:18 +0000 (18:01 +0200)
At space-info.c:__reserve_bytes(), instead of initializing 'ret' to 0 when
it's declared and then shortly after set it to -ENOSPC under the space
info's spinlock, initialize it to -ENOSPC when declaring it.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/space-info.c

index 379a0e778dfb9b71adedac8c577b5fb81d1da8a5..5eb161d96e35c27a3a8611ed687bab7c76d536b5 100644 (file)
@@ -1599,7 +1599,7 @@ static int __reserve_bytes(struct btrfs_fs_info *fs_info,
        struct reserve_ticket ticket;
        u64 start_ns = 0;
        u64 used;
-       int ret = 0;
+       int ret = -ENOSPC;
        bool pending_tickets;
 
        ASSERT(orig_bytes);
@@ -1622,7 +1622,6 @@ static int __reserve_bytes(struct btrfs_fs_info *fs_info,
                async_work = &fs_info->async_reclaim_work;
 
        spin_lock(&space_info->lock);
-       ret = -ENOSPC;
        used = btrfs_space_info_used(space_info, true);
 
        /*