From patchwork Wed Oct 13 09:12:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 12555167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C6B8C433EF for ; Wed, 13 Oct 2021 09:12:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C6E360E96 for ; Wed, 13 Oct 2021 09:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238974AbhJMJO4 (ORCPT ); Wed, 13 Oct 2021 05:14:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:38908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238479AbhJMJO4 (ORCPT ); Wed, 13 Oct 2021 05:14:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A04A60E54 for ; Wed, 13 Oct 2021 09:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634116373; bh=9wf+sa2ehIzwlZxZf8O1aKA5Ueq2bR9vL/DxREsP1VI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ha4Wv1gJ7EyGp8URKSDHtOy0GsJtnbsd/oZrLWzf2s//vJ9qHKCXJ8O/uWfpoKLQn fU3AsmeHfwL94rozJsWmdTdB1Ysss6Od014foHJK/ce8bHNHsrzVe6lxkIU9dyBZ56 q5rIUN3+k07hjjm/djPArUylqsjBHUSJ2XD4sghph34bY17MO3zkEXQDevbXsKiKZf 4l5v2/U/ELJqssxVN6O6ZjgQa3FeMXQVmVyTsxR4Ydv6e2Bvd9LVlhqdKWPbVfc76Y F7J/G2w2ytY/eGVLtQKzSK0AQ4ivWqwl7I2CjNwVbPzYriod2cQ4lWAeSh7OyjWHn+ i9MrI1u25meoQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v3 0/2] btrfs: fix a deadlock between chunk allocation and chunk tree modifications Date: Wed, 13 Oct 2021 10:12:48 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Filipe Manana This fixes a deadlock between a task allocating a metadata or data chunk and a task that is modifying the chunk btree and it's not in a chunk allocation or removal context. The first patch is the fix, the second one just updates a couple comments and it's independent of the fix. v2: Updated stale comment after the fix (patch 1/2). v3: Moved the logic to reserve chunk space out of btrfs_search_slot() into every path that modifies the chunk btree (which are the cases listed in the change log of patch 1/2) and updated two more comments in patch 1/2. Filipe Manana (2): btrfs: fix deadlock between chunk allocation and chunk btree modifications btrfs: update comments for chunk allocation -ENOSPC cases fs/btrfs/block-group.c | 166 +++++++++++++++++++++++++++-------------- fs/btrfs/block-group.h | 2 + fs/btrfs/relocation.c | 4 + fs/btrfs/volumes.c | 15 +++- 4 files changed, 128 insertions(+), 59 deletions(-)