Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp564135rwb; Wed, 16 Nov 2022 04:53:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4iSqVT5nZJ9ImB/t9wjnbfZBFh57at7qP9f1Cgg27WQYKYw8rwjRR0ZzC6VtLcxP49ORin X-Received: by 2002:a63:5c06:0:b0:46e:ccbd:b136 with SMTP id q6-20020a635c06000000b0046eccbdb136mr20584239pgb.515.1668603232816; Wed, 16 Nov 2022 04:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668603232; cv=none; d=google.com; s=arc-20160816; b=uWmRc2A6JjnU0Q5lItaarxSdLxlqO2Pq0PM9teMZxHv3B/NBJJ+5FHcl8yoc7tokQG Gc82iYJSecnROr9nvx3XDrL/bZ18/aM2jLO2ASDMGxpPVXt58RZniT3XVrHYU2R46/eS OP4uoXQpG+Qt4XuaRQ049wkjLYwitSzBRP9xJW4NY6XBKnARodaF6whM5Sq61eLFen4N NLgxGwqksin3QhH/6LcxqMGxDmPkIrjgC1ovCYzJEH6gAAz3vcWx541/GAY80qLzu11L 2ZuJRH6gSpWNJyn7dmZ1SbdyM8p6PvQafxw71oRR0zfglWcQW3WWT5vgZXPWnlPUv4kC xTHw== 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=gDMFa+r5Sga12zgiOcSh/NDoeCEUkIAOuL9mUaOuyW8=; b=iRoeFJ/U8rTQ+cs6DeXrBD2X80eyuD7xI0o5JEfoeoZgjvS/hOZh861iGRsxG4+44X 9SNU81XU4m1IwLSbOdirlXgtZc/ZsteoxuNvu026fKYUFc/HYp78QDJpwdHjX5VTkpZ0 XFSxGCpCW4lJ4S0ogtliClGBM252/hFrpmwKBlcaA7Y29OOH8UzqU2rmt8CR3+0vJ2ec cCwLMjiFvEvlUvyelqLQ35PBxm+ZXwciPC5FPOb/sV9pWFvPrdYuK07rh8RPDIT5M8Cz V13Nhiw04V+wFxqo5eF8DVvaG4YGjgGj0Fu4/CKxMcpt4Gskog1gLuNdzAr+Uhe1mvfb gitA== 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 lp7-20020a17090b4a8700b0020d457c5083si2193007pjb.147.2022.11.16.04.53.40; Wed, 16 Nov 2022 04:53:52 -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 S232298AbiKPMKA (ORCPT + 92 others); Wed, 16 Nov 2022 07:10:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238495AbiKPMJB (ORCPT ); Wed, 16 Nov 2022 07:09:01 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D18A930F70; Wed, 16 Nov 2022 04:02:44 -0800 (PST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NC1n20nNKzJnnc; Wed, 16 Nov 2022 19:59:34 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv703-chm.china.huawei.com (10.3.19.46) 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 20:02:42 +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 20:02:41 +0800 From: ChenXiaoSong To: , , CC: , , , , , , Subject: [PATCH v5 1/2] btrfs: add might_sleep() to btrfs_search_slot() Date: Wed, 16 Nov 2022 21:07:15 +0800 Message-ID: <20221116130716.991901-2-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116130716.991901-1-chenxiaosong2@huawei.com> References: <20221116130716.991901-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 2 places might sleep in btrfs_search_slot(), as shown below: 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_search_slot(). Signed-off-by: ChenXiaoSong --- fs/btrfs/ctree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index a9543f01184c..809053e9cfde 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1934,6 +1934,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