Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp643168rwb; Wed, 16 Nov 2022 05:59:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6jCrdZkFsJrCf+8H4B8sGdR4XgxuW22T3+Y8uPCZH30upaXq7ucfxoKY5WmzUbYgZ71HEg X-Received: by 2002:a17:90a:8a86:b0:212:ec84:91d9 with SMTP id x6-20020a17090a8a8600b00212ec8491d9mr3964833pjn.139.1668607172292; Wed, 16 Nov 2022 05:59:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668607172; cv=none; d=google.com; s=arc-20160816; b=WmV5P2ugwqQKDAjn9c29nIiuUfHEBBOnwRuHD0/unqU1BTio3x0TGcgGtZGH9RYzPJ 8okJCJ3/mVF06xF/3IKXdwNmCpwVg0NUOBtIxn7i5sMD7i5hwAaua+IPWFS1/JmC/UuN +EY3pTUgAHMuW3TT6KyvZm3up1wDfEtET6T0ixrXmEVJ/HYApLh1gqKy/lUO/yP3gPD3 Vvy+LkLr0HY+J0w1FmGQNFrJhIScM01EEjgOymV4HRnNADx8RYvbyO+zc8iiQcurLg1k W7W3op82jQ4H0fhpcHRdXPM4pErBfqor//Wv8Mpeymb3dpDfguRitL4zBHTf+UskZpVV aljA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=KLNabC4w3fXYd5E1I/F0yLh6SIliM2sU2E7VFjo+xrQ=; b=s5LuTn0hUdhDBSjZLQLTXta3/G3JJ/4FvWinzeCaSfQP550Hl5tee0FPlFbzlySuYy UNf3wC9DoOn1c91Pc3eN7s3pl91r3+OvlOdVHccuSJ5BuV1T90DeXcGq+uKb3iqQX6LZ 4pTJAQFTBJWyZhJ63CxIaWi7bN0qYu9pDoE9A2B7vf8FGB3UkUE0+vWQ+/qXv0VD+wD8 k9JAzCgVIg5IJcejvG7VDx7LROjGlY9vuxI882kje6CX2E0g3954M0dw4zMKtH5Mkq4H vS4HTv5tWoV74lgUOYapfWyBw16c7wHesGsY0SSdhywsSNLnuplMx22F1l4VEqRC/XWR MmJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o16-20020a17090a169000b0020befc1a93asi1825518pja.100.2022.11.16.05.59.20; Wed, 16 Nov 2022 05:59:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236982AbiKPNTm (ORCPT + 91 others); Wed, 16 Nov 2022 08:19:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232801AbiKPNTg (ORCPT ); Wed, 16 Nov 2022 08:19:36 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AC172126B; Wed, 16 Nov 2022 05:19:35 -0800 (PST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NC3Xv1Dpfz15MjQ; Wed, 16 Nov 2022 21:19:11 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 16 Nov 2022 21:19:32 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 16 Nov 2022 21:19:31 +0800 From: ChenXiaoSong To: , , CC: , , , , , , Subject: [PATCH v6 1/2] btrfs: add might_sleep() to some places in update_qgroup_limit_item() Date: Wed, 16 Nov 2022 22:23:53 +0800 Message-ID: <20221116142354.1228954-2-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116142354.1228954-1-chenxiaosong2@huawei.com> References: <20221116142354.1228954-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At least 3 places might sleep in update_qgroup_limit_item(), as shown below: update_qgroup_limit_item btrfs_alloc_path /* allocate memory non-atomically, might sleep */ kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS) btrfs_search_slot setup_nodes_for_search reada_for_balance btrfs_readahead_node_child btrfs_readahead_tree_block btrfs_find_create_tree_block alloc_extent_buffer kmem_cache_zalloc /* allocate memory non-atomically, might sleep */ kmem_cache_alloc(GFP_NOFS|__GFP_NOFAIL|__GFP_ZERO) read_extent_buffer_pages submit_extent_page /* disk IO, might sleep */ submit_one_bio As the potential sleeping under spin lock is hard to spot, we should add might_sleep() to btrfs_alloc_path() and btrfs_search_slot(). Signed-off-by: ChenXiaoSong --- fs/btrfs/ctree.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index a9543f01184c..1cd0d00ef328 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -78,6 +78,8 @@ size_t __attribute_const__ btrfs_get_num_csums(void) struct btrfs_path *btrfs_alloc_path(void) { + might_sleep(); + return kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS); } @@ -1934,6 +1936,8 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root, int min_write_lock_level; int prev_cmp; + might_sleep(); + lowest_level = p->lowest_level; WARN_ON(lowest_level && ins_len > 0); WARN_ON(p->nodes[0] != NULL); -- 2.31.1