Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1297574rwb; Wed, 16 Nov 2022 15:25:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Wpk/bhtOzWegh/QiX6hpvUE4AU7Lj67obTvnmHb/GpEg0yma1r06ZYJw+ZN4q9J6C6u+r X-Received: by 2002:aa7:db46:0:b0:459:278b:7a8b with SMTP id n6-20020aa7db46000000b00459278b7a8bmr20609366edt.355.1668641125983; Wed, 16 Nov 2022 15:25:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668641125; cv=none; d=google.com; s=arc-20160816; b=Se/j6NBzZ6id6soDiZdYZpEr9MH25fQZ+JFRnqFS1Jimge9YdIDJ2P8uvUyiKs8DSv tT7PHtpgAUO1UvXOHiYUOPW7LzgNuZLLl9AfTZ00xwry+zaoHqbBF3Ez6BLpeikOF8GU qn82AjJACOKGN/uveoY5RYNaAij+L6zaeATFfq7nojN8nQFaIfmBfW6o0jzSu24ClnJ4 ES/B6d0p9FNdddl3OGvcomFgJqd10sGjD/mMDIyy7b7KiVLKw0KoA9W7al9sHcltvgqU tlTfeSGmhZ3cNnjxntyHLRAh2OAT7gIPhSj+e0fPB865tl6yVtJlf4s4292a5BIymdMO ZmjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id; bh=VwgenjVDreEXWBFtEen1vB+gNxVWIs1jz2H1mFpd6fk=; b=i6Y8VONNjXHA7XIlvijtfWhd7VRvymyjNMO4PUyzsKuqJOXRXrgx4ddiFkkp0GPZgo fl1kMsPmkKOLd339c//wnHaEd7ixUend7wfKRd6qdtmBXQQAMI0b6mune9vaCbYpTzq4 XAapGPo8VEcnG5wuvbB9lRaNm/HzrmO8sX2BSms83wQnkKYI5vuRJxQL6fbMeo9gL6bJ ooGvv33HdcNoRSCcBgO2a5wCrP9oW1vGyYoThzXocV7fmokX9y66f5f56deM1H5D1dgA xajBUxFOQ7R/rsTjTNEH6PWxVLdComtocvmN5Aqh5E+ylZxAxhdcMJimKHKGDWhgSIDD HYpw== 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=NONE sp=NONE dis=NONE) header.from=gmx.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020a170906868300b0073c14b6560bsi13340973ejx.177.2022.11.16.15.25.05; Wed, 16 Nov 2022 15:25:25 -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=NONE sp=NONE dis=NONE) header.from=gmx.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233842AbiKPXRP (ORCPT + 90 others); Wed, 16 Nov 2022 18:17:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233825AbiKPXRL (ORCPT ); Wed, 16 Nov 2022 18:17:11 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03D5712085; Wed, 16 Nov 2022 15:17:08 -0800 (PST) Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1M9Wyy-1opxTS3gxw-005WXh; Thu, 17 Nov 2022 00:16:51 +0100 Message-ID: Date: Thu, 17 Nov 2022 07:16:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v6 2/2] btrfs: qgroup: fix sleep from invalid context bug in update_qgroup_limit_item() Content-Language: en-US To: ChenXiaoSong , clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangxiaoxu5@huawei.com, yanaijie@huawei.com, wqu@suse.com References: <20221116142354.1228954-1-chenxiaosong2@huawei.com> <20221116142354.1228954-3-chenxiaosong2@huawei.com> From: Qu Wenruo In-Reply-To: <20221116142354.1228954-3-chenxiaosong2@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:4ARWBwaruX9+tgd/2+tyL08LRrkr/UgvVfCSNM0yms5829PmX8U pCS8MGGV2agB/dBQ7kBfAJuYV4XGFgmaIkp1O5PJnTmXILvzSc6PwnmYxUg9RQajDqBsELY SC6/VtcVogZf5ci6ZKYdwkk9yysOJ3PHx/Yr+9REeIXfkwJYxeSCB//k6/Ms+zsJNTZXgLf 4DBWn/SON2j+2drlLU24w== UI-OutboundReport: notjunk:1;M01:P0:Q0jR8L+7en4=;TC3CsQiNZKviEyjScmTPxV7Kftk tMgUGq/GOe5WDJj5+ptb/HbRgVF1Y61pxCotizL10yhYhTWLhBUT4J1Q3uOi16/B7HF5W6p7d 45POMJ3js4ndTG/NoBr+RYaOB5PzOuuIQwUbEkR9izQbNQ25KZam3gpkXErfiX/LTAnEIGGQg 1ylxsD97jQh02KxfAbDKD43/bGCPXiw8a5vAl72H/Yu/etCTYY/HbqCTZIZbWcS2BKsrmzpQq obUqT9xzmk/7dhzKUte+zPsCz/3OmFFCSU9uGFKlUFss5mM3xdlCn4eBIJMsvMjJbzEuXb2Ue +ac5/NEXwIFFSONff/mvrYHkw5F1+1JPGxLxm84JJd1yX9GKgKpI7a7DJkHjKTWwQa9B/icqY GA4gx7u7x5nh3s20xSU3Kt7vq6niuW40mfgUwCtiP2CttgDFoQFtt8uZaJK3Hma5bntT2XqyF q4faiVL4MmoVlYSeRxOB5zVE2tgZA6JDOO5TqejFyDJqu13OoBHYGujjbBpuvzDKvYyjXZ/3V WEyKpCwWfqXoADTHu7ofU89LKxN56gJzsv6/bQRL7mUPOvfA9P1CkaTeXv/GJxABpee4/SqC0 lGVe6JKNyhtHU6trsRi4msNaThTV+P1dI7g0EnHSCmW9YmZHfYMnhvYpJtDufy/zpHGg0cLkf wWbKO3y3nPRqYaWENxSdql3CLHX5s7Ck5tFwNumfDRAWBsAJSkCFpIpYvaFWcDRe4q6CETbpC 8Ps8nBGm7JzwT7InFBUXch3ZyVqflgMm1DDPPCZXHelHtmm9TdHeWk8v35N1hg9Vi1igxzen/ X4QcCwN5C+sKxFNGI24dzlH7jQvWgl/r5Whz1GPwf03I++0MOk78Oe0J9+DPWvlbYsOtgfqGd 6Un4GN5lxCIovPTNTHMOnQK5e38+dMoeH6vqEMxkCE6OkqjynIO2CFDn7ItSQSz+OzBnC904t RS7srDkSkpsMwZkrbd7CRzabUJ8= X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,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 On 2022/11/16 22:23, ChenXiaoSong wrote: > Syzkaller reported BUG as follows: > > BUG: sleeping function called from invalid context at > include/linux/sched/mm.h:274 > Call Trace: > > dump_stack_lvl+0xcd/0x134 > __might_resched.cold+0x222/0x26b > kmem_cache_alloc+0x2e7/0x3c0 > update_qgroup_limit_item+0xe1/0x390 > btrfs_qgroup_inherit+0x147b/0x1ee0 > create_subvol+0x4eb/0x1710 > btrfs_mksubvol+0xfe5/0x13f0 > __btrfs_ioctl_snap_create+0x2b0/0x430 > btrfs_ioctl_snap_create_v2+0x25a/0x520 > btrfs_ioctl+0x2a1c/0x5ce0 > __x64_sys_ioctl+0x193/0x200 > do_syscall_64+0x35/0x80 > > Fix this by calling qgroup_dirty() on @dstqgroup, and update limit item in > btrfs_run_qgroups() later. > > Signed-off-by: ChenXiaoSong Reviewed-by: Qu Wenruo Thanks, Qu > --- > fs/btrfs/qgroup.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c > index 9334c3157c22..b74105a10f16 100644 > --- a/fs/btrfs/qgroup.c > +++ b/fs/btrfs/qgroup.c > @@ -2951,14 +2951,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, > dstgroup->rsv_rfer = inherit->lim.rsv_rfer; > dstgroup->rsv_excl = inherit->lim.rsv_excl; > > - ret = update_qgroup_limit_item(trans, dstgroup); > - if (ret) { > - qgroup_mark_inconsistent(fs_info); > - btrfs_info(fs_info, > - "unable to update quota limit for %llu", > - dstgroup->qgroupid); > - goto unlock; > - } > + qgroup_dirty(fs_info, dstgroup); > } > > if (srcid) {