lkml.org 
[lkml]   [2022]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 728/779] btrfs: reset block group chunk force if we have to wait
    Date
    From: Josef Bacik <josef@toxicpanda.com>

    [ Upstream commit 1314ca78b2c35d3e7d0f097268a2ee6dc0d369ef ]

    If you try to force a chunk allocation, but you race with another chunk
    allocation, you will end up waiting on the chunk allocation that just
    occurred and then allocate another chunk. If you have many threads all
    doing this at once you can way over-allocate chunks.

    Fix this by resetting force to NO_FORCE, that way if we think we need to
    allocate we can, otherwise we don't force another chunk allocation if
    one is already happening.

    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    CC: stable@vger.kernel.org # 5.4+
    Signed-off-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    fs/btrfs/block-group.c | 1 +
    1 file changed, 1 insertion(+)

    diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
    index c6c5a22ff6e8..4b2282aa274e 100644
    --- a/fs/btrfs/block-group.c
    +++ b/fs/btrfs/block-group.c
    @@ -3632,6 +3632,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
    * attempt.
    */
    wait_for_alloc = true;
    + force = CHUNK_ALLOC_NO_FORCE;
    spin_unlock(&space_info->lock);
    mutex_lock(&fs_info->chunk_mutex);
    mutex_unlock(&fs_info->chunk_mutex);
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-08-15 21:57    [W:4.188 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site