Message ID | 20221115171709.3774614-1-chenxiaosong2@huawei.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2818085wru; Tue, 15 Nov 2022 08:17:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Lb8s/uG+NhzxNaWCEgZWrqgRtRWp3af80DjYKu8nVIlWiLPe63eL0lgQWiJ8wsk2f9NRp X-Received: by 2002:a17:907:8d06:b0:78d:b819:e0e7 with SMTP id tc6-20020a1709078d0600b0078db819e0e7mr14486776ejc.83.1668529033505; Tue, 15 Nov 2022 08:17:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668529033; cv=none; d=google.com; s=arc-20160816; b=tzNuv7QQYNra0z9uiOpXlurGHA1yeyTA/KiStT5snSF/WfmKVrJedQrteQKxsVbk5N bxq9qQ4ygBfWGY0/Ixba9W6lPw+nyD3EvuNBsu4d0sFBLbyJyLoICG/gqae2AogAbsjr muL3HgOzEp8BSixl+a1xQ1w5SDIqhObFofk6uc3AGcVK76gkdgrqMnptkpcBeYmW2nLi qa7kClZqFCUoMG39DjR2DA5S6PZaTStQWolGsWOpio70P0+6iofTGkTwTKF5LhfoqNZ5 wSKK5yy/wA319LHNGsYv/FEZEltUzXHsama06dIVqvB633G9sEmeVw1LkUJxbxv87u/E Skvw== 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 :message-id:date:subject:cc:to:from; bh=VuIT+GW0jN1A9WLEs5+0nc+Rgvtb7fjMIpF+pPH5JVg=; b=MLRPwrxcAxqYQlB75ulZ5tkr1SFGjvef8ZT+m6XBxjxttTjOEHfC7tVKguluLPbnFz me/3xPwWVPZM9XmEK9Bi6lee5c1J6sM84Pzz7tm4wQM4t6yfr7l3UFXI+4OEcMuUGt6l DDjgiZnbeijLYoR9OTalAZRWFoOJTPd2kbfRR5zkUAv89I38AkdatBv7yIhFpRpdSpS0 s50hDrDKFD8jgIepHKlyWAQStYiDhi8Puu/tXpc7+letNDYlITQYq/0Iq8JExKl3GbAt uuoqn3+2lKmj+OTjQdiCL7r7+feao8C/pj98o5sQ9KQ9F7rDHlCOJ4m5WSm2P5IirFtF WCdQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020a056402510d00b0046769e40ee5si11729412edd.321.2022.11.15.08.16.47; Tue, 15 Nov 2022 08:17:13 -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 S231725AbiKOQMf (ORCPT <rfc822;maxim.cournoyer@gmail.com> + 99 others); Tue, 15 Nov 2022 11:12:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiKOQMe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 15 Nov 2022 11:12:34 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F72E1D65A; Tue, 15 Nov 2022 08:12:33 -0800 (PST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NBWQn1FW7zHvsk; Wed, 16 Nov 2022 00:12:01 +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 00:12:31 +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 00:12:30 +0800 From: ChenXiaoSong <chenxiaosong2@huawei.com> To: <clm@fb.com>, <josef@toxicpanda.com>, <dsterba@suse.com> CC: <linux-btrfs@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <chenxiaosong2@huawei.com>, <zhangxiaoxu5@huawei.com>, <yanaijie@huawei.com>, <quwenruo.btrfs@gmx.com>, <wqu@suse.com> Subject: [PATCH v4 0/3] btrfs: fix sleep from invalid context bug in update_qgroup_limit_item() Date: Wed, 16 Nov 2022 01:17:06 +0800 Message-ID: <20221115171709.3774614-1-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749579499888309795?= X-GMAIL-MSGID: =?utf-8?q?1749579499888309795?= |
Series |
btrfs: fix sleep from invalid context bug in update_qgroup_limit_item()
|
|
Message
ChenXiaoSong
Nov. 15, 2022, 5:17 p.m. UTC
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 Fix this by delaying the limit item updates until unlock the spin lock. By the way, add might_sleep() to some places. ChenXiaoSong (3): btrfs: add might_sleep() to some places in update_qgroup_limit_item() btrfs: qgroup: introduce btrfs_update_quoto_limit() helper btrfs: qgroup: fix sleep from invalid context bug in update_qgroup_limit_item() fs/btrfs/ctree.c | 2 ++ fs/btrfs/qgroup.c | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 19 deletions(-)