Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2245363rwp; Fri, 14 Jul 2023 03:15:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlHpc6+iYIiAMOX87ggCWUxXrmTsAo9c4aJnDYJiUpStaTsQoCuleuMcSAua9ndRnbuEKXoN X-Received: by 2002:a17:906:109e:b0:98e:1a0c:12c0 with SMTP id u30-20020a170906109e00b0098e1a0c12c0mr2821151eju.7.1689329711809; Fri, 14 Jul 2023 03:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689329711; cv=none; d=google.com; s=arc-20160816; b=s6/B8fqG6UqFm9jmkELMDQuEu9Hctk1txuGACzN6yaCcD9T6VtPqYyKxJQffdnW34z pMP1yRDrrpbiJ52I2Yo6xL4KjKkcsTHamuJ+D869dp5w6oJrQUILWiLor4rLRicwX6ER 6VfIRuZLlLq4rWalbfd98+eMrwFjYa8oILtFeBSo5IUAobvSukQ/pxQ97BFMhfrHRfZH cjOm3hzXjXR5CzCwcz51EZ+YsryScGwlVMfJGMrlZhaqewHSjhzRve9cpXglluHvb7ce SRibZnSKGEE1b1jOGLtzeRwc/W4Ujdo6gEoi6YR4WUXkl5pQXURWaXP56EdY8uw8Q8Ih ncyw== 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=e7Rv1H6fjmBW7mfZ+ZrZR0i86EmB3mqsT9/DnQrSAjs=; fh=LI4X/mLaMRJ1x3i+K8PD1KSe75csGOto6KZeZ3GGCIk=; b=BRrs/wIz5i+7vU9d8PvwmJ/1R6Nc7EaRxKGdDRaQJhze8GnUTIDz8l2NhMY9o0wj0e cpUVl3ZUmo8now05IhWJJyUOG0MrbJBWKmb3qVX+iSi+EmRQ8AcAi++7XQ0LJ1Q2Oinl ObLRcfLDUiK1RmYswJhP9iovyTzWkTC/xv5MtqYW/JepagCP8ucakyT9CU3p8pInmbgI xMtFscwfqeDWudN8uqMkW5fPuH1IY8QcVNcqIxr5EapHSuc1EzmjHwGsjWBYOv2p1/6c uW2YBQ6ajvMi3H2MUEUAUcMSn4fqpu521/GTfMC7ch+pzUCC1jMVOhhqi5eZc8BexK2a uWEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qsMmse8m; dkim=neutral (no key) header.i=@suse.cz; 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 y15-20020a170906448f00b00992e23f0e6asi9044773ejo.822.2023.07.14.03.14.47; Fri, 14 Jul 2023 03:15:11 -0700 (PDT) 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=qsMmse8m; dkim=neutral (no key) header.i=@suse.cz; 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 S236015AbjGNKIY (ORCPT + 99 others); Fri, 14 Jul 2023 06:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235170AbjGNKIX (ORCPT ); Fri, 14 Jul 2023 06:08:23 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 879EDE44; Fri, 14 Jul 2023 03:08:22 -0700 (PDT) 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-out2.suse.de (Postfix) with ESMTPS id 3FAE31FD60; Fri, 14 Jul 2023 10:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1689329301; 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=e7Rv1H6fjmBW7mfZ+ZrZR0i86EmB3mqsT9/DnQrSAjs=; b=qsMmse8mTusoohv3JefPmD7rtFAwwKNHClCQ0HTfc641h+qO4HfMWLwAUw6JK/6NdBGaZ3 4mipH79Z+CbRfFNEwjSAWOdpJgWjT6dfbedZgIbWGQt/uhlHLzPYxioXVlqC/+QpWZux4K Y3ZQdJycLUZW19YxqTjIVmg1M2Ij6cc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1689329301; 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=e7Rv1H6fjmBW7mfZ+ZrZR0i86EmB3mqsT9/DnQrSAjs=; b=Lw/3NxXsnUVhBmQlwadstME3Do+Rr7Sg2IMERJuFKXIfMrLHOVUqp+ivNvM2lvKfellMa2 2bzVGhMBJJmvnGDA== 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 EEB3413A15; Fri, 14 Jul 2023 10:08:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id R0lGOZQesWSrCgAAMHmgww (envelope-from ); Fri, 14 Jul 2023 10:08:20 +0000 Date: Fri, 14 Jul 2023 12:01:44 +0200 From: David Sterba To: xiaoshoukui Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, xiaoshoukui Subject: Re: [PATCH] btrfs: fix balance_ctl not free properly in btrfs_balance Message-ID: <20230714100143.GE20457@suse.cz> Reply-To: dsterba@suse.cz References: <20230714071548.45825-1-xiaoshoukui@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230714071548.45825-1-xiaoshoukui@gmail.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Fri, Jul 14, 2023 at 03:15:48AM -0400, xiaoshoukui wrote: > Signed-off-by: xiaoshoukui > --- > fs/btrfs/volumes.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index 7823168c08a6..c1ab94d8694c 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -4055,14 +4055,6 @@ static int alloc_profile_is_valid(u64 flags, int extended) > return has_single_bit_set(flags); > } > > -static inline int balance_need_close(struct btrfs_fs_info *fs_info) > -{ > - /* cancel requested || normal exit path */ > - return atomic_read(&fs_info->balance_cancel_req) || > - (atomic_read(&fs_info->balance_pause_req) == 0 && > - atomic_read(&fs_info->balance_cancel_req) == 0); > -} > - > /* > * Validate target profile against allowed profiles and return true if it's OK. > * Otherwise print the error message and return false. > @@ -4411,7 +4403,7 @@ int btrfs_balance(struct btrfs_fs_info *fs_info, > } > > if ((ret && ret != -ECANCELED && ret != -ENOSPC) || > - balance_need_close(fs_info)) { > + ret == -ECANCELED || ret == 0) { > reset_balance_state(fs_info); > btrfs_exclop_finish(fs_info); This is a similar patch to what Josef sent but not exactly the same, https://lore.kernel.org/linux-btrfs/9cdf58c2f045863e98a52d7f9d5102ba12b87f07.1687496547.git.josef@toxicpanda.com/ Both remove balance_need_close but your version does not track the paused state. I haven't analyzed it closer, but it looks like you're missing some case. Josef's fix simplifies the error handling so we don't have te enumerate the errors. As you have a reproducer, can you please try it with this patch instead? It's possible that there are still some unhandled states so it would be good to check. Thanks.