Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp853250rwb; Fri, 18 Nov 2022 09:05:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4IboqAs7e+CaIisyRTlu8ReTXXLXe2HqTJr/VYK30DEX5TdKBJ92HcvaK0zVCXgC5Sb9SP X-Received: by 2002:a63:c46:0:b0:476:ed2a:6228 with SMTP id 6-20020a630c46000000b00476ed2a6228mr7706994pgm.137.1668791148032; Fri, 18 Nov 2022 09:05:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668791148; cv=none; d=google.com; s=arc-20160816; b=XgGXAD5MIql/vn5QVF0IcqQNKsun+Npm8jLUV4BODpdFqy/K1Z9OadnP41Uv5Fl2J7 euTEmf+2MWdHamlJOLHOcpNhC+jeBaUrQnb9+uZ3FBDLR983qtrxnmCOU4Ikosa0iU95 MXQ7XRLroJ7ShEty5ifJe1eHTTlTy5tKgjPYBG/n5jzYAYiFk6VHoVburvnAGlz/G+zl yi/262vbCIMUY3pT260Sdx2t36hwL9jnznUH70orMuL4JC3IS9KKbfPXvSgfgS0USpSg i1ggwyatSlCK/G8mcuzE/4QnS6tDkQScTdY86CFk01iUg5Tc4pcxbj7AY5P2Qy7Fwoo2 cpZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=TmHDNNy7BK2GoEyCC13zO2kb7K0MrJl1jm1K8E97OMI=; b=nOzuVBKKFyrzVjFwx+/3SpAEaDggX8cDBnHu01lkPiSADyI07nUQNic6Y21Ex2WmhT ud1tIyOcJpuldbO9z/oBpE0IWfBvtaXJDnyi1ifY+uOCOV7I7mmMqHCn8GR6HPFnzSOh qFxypVjku64s6/TXtQCXcjkVX7W+UpbvYJ3CmtVRw0ZoFYpoz1PUYrqhD+jd3sTgZIrt 2hv+lI8MLXuY7/Y4dQlmD0g1xgJ0Yx2qDttj5XdHIBkF3zGvNxTYHxwsMKBAkqzw7k5i swhMnxzGlQ6qh3+NFDZ7SNQX8aQFZOhLENfVLXjgcKokDmkUuMmbfG1EHES0sUKOI9a/ Qikw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=fQq58YmA; dkim=neutral (no key) header.i=@suse.cz header.b=0M+DCbr1; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a63e703000000b0047701a23907si4041644pgi.252.2022.11.18.09.05.28; Fri, 18 Nov 2022 09:05:48 -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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=fQq58YmA; dkim=neutral (no key) header.i=@suse.cz header.b=0M+DCbr1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241880AbiKRQh4 (ORCPT + 91 others); Fri, 18 Nov 2022 11:37:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242164AbiKRQhm (ORCPT ); Fri, 18 Nov 2022 11:37:42 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F062C942DC; Fri, 18 Nov 2022 08:37:33 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0988022D0D; Fri, 18 Nov 2022 16:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1668789452; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TmHDNNy7BK2GoEyCC13zO2kb7K0MrJl1jm1K8E97OMI=; b=fQq58YmAep1BITmTRRZH1qa3gG0F+1OQ/XPuwsXHlroCCOxu756fdrNZ7QwU5JQT9vl2J2 Vnpod6XTLpxashJHXIIUahrRBmLvlIKfLVsYx0nj9hpPboxapxUyhI9L/qjPhHPJ71+VlO 0CfiMEMcpxgIyeZLgGeHhe/gB5aoP5g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1668789452; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TmHDNNy7BK2GoEyCC13zO2kb7K0MrJl1jm1K8E97OMI=; b=0M+DCbr11FuGL0f0sFKWOyO3xgGAGm0sMMgxd0TN43mEi2/fInL5kk6WwRcZjtWKsufSwD yEyJiADRUWEaedCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id ADDAE1345B; Fri, 18 Nov 2022 16:37:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /F9aKcu0d2NjDAAAMHmgww (envelope-from ); Fri, 18 Nov 2022 16:37:31 +0000 Date: Fri, 18 Nov 2022 17:37:03 +0100 From: David Sterba To: ChenXiaoSong Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangxiaoxu5@huawei.com, yanaijie@huawei.com, quwenruo.btrfs@gmx.com, wqu@suse.com Subject: Re: [PATCH v6 0/2] btrfs: fix sleep from invalid context bug in update_qgroup_limit_item() Message-ID: <20221118163703.GT5824@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <20221116142354.1228954-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221116142354.1228954-1-chenxiaosong2@huawei.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL 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 Wed, Nov 16, 2022 at 10:23:52PM +0800, ChenXiaoSong wrote: > 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 calling qgroup_dirty() on @dstqgroup, and update limit item in > btrfs_run_qgroups() later. > > By the way, add might_sleep() to some places. > > ChenXiaoSong (2): > btrfs: add might_sleep() to some places in update_qgroup_limit_item() > btrfs: qgroup: fix sleep from invalid context bug in > update_qgroup_limit_item() Added to misc-next with updated subjects and changelogs, thanks.