]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: process ticket outside global reserve critical section
authorFilipe Manana <fdmanana@suse.com>
Fri, 17 Oct 2025 16:34:36 +0000 (17:34 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:12:37 +0000 (22:12 +0100)
In steal_from_global_rsv() there's no need to process the ticket inside
the critical section of the global reserve. Move the ticket processing to
happen after the critical section. This helps reduce contention on the
global reserve's spinlock.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.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 62e1ba7f09c0a69f157d0c37175c115604564ae9..957477e5f01f95cae9f371eb1f7aa8a9e4e9328f 100644 (file)
@@ -1062,13 +1062,14 @@ static bool steal_from_global_rsv(struct btrfs_space_info *space_info,
                return false;
        }
        global_rsv->reserved -= ticket->bytes;
+       if (global_rsv->reserved < global_rsv->size)
+               global_rsv->full = false;
+       spin_unlock(&global_rsv->lock);
+
        remove_ticket(space_info, ticket);
        ticket->bytes = 0;
        wake_up(&ticket->wait);
        space_info->tickets_id++;
-       if (global_rsv->reserved < global_rsv->size)
-               global_rsv->full = false;
-       spin_unlock(&global_rsv->lock);
 
        return true;
 }