Received: from fout-b7-smtp.messagingengine.com (fout-b7-smtp.messagingengine.com [202.12.124.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DBDA1AA1D9 for ; Fri, 7 Mar 2025 21:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.150 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741383590; cv=none; b=ZneNO/Z/DVWBeBSLewR6Dke3Xla/H+fGwOLsa2AtJ9oJaspyRauvYSSeSDLVG2AJO4it6g3+lfzbV+zbQ2MXqhH495CY9RpZbZLrCN299KXT6toptrXLRAJfYy2DL5VKmXil5LZkfpFXgKSZsjperTPutS2dljsGsrs+31yZ7/w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741383590; c=relaxed/simple; bh=FOvF6icIufMmz9YD9rO0NwyJ1d801IfWOcw9g7mJSxI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SZjx/ldO2KvzAYRBxwMEBgaTKJuKRW61s5vtpfw71ZxBNagrDbrKBwd/yfBPZ0PizAZYOgbs6ywLqpJrnY0a9nFsUQNGRe5Uzgqsx1XUFjSAOzvDLfGVyecdnJC/TQAaouczP6gvxbck4AMW+CRfNPjTxguLv1ql6M0g4o6uwAI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bur.io; spf=pass smtp.mailfrom=bur.io; dkim=pass (2048-bit key) header.d=bur.io header.i=@bur.io header.b=QunrMQcm; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=7P8f54QB; arc=none smtp.client-ip=202.12.124.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bur.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bur.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bur.io header.i=@bur.io header.b="QunrMQcm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="7P8f54QB" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.stl.internal (Postfix) with ESMTP id 9B5B21140195; Fri, 7 Mar 2025 16:39:47 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Fri, 07 Mar 2025 16:39:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1741383587; x=1741469987; bh=no6DVR45LnkKAZfk68ah4Qg3THqJ7pP2CMs9sDSiiOU=; b= QunrMQcm97+QLUy4Otb7sitJ+pz3HC25WVyKVxm+c7z6AC8F3SGoSuFm0h8rLEG9 McITITW2gvFsBBHQxl3pqSeuaLYklOGOz+TnhUCCoaes3n3izmJQQheN1bo6S1M6 NBzYD0EPB5rHTVQaovHmi7CZk7oUNd2g64+FN/9OPFodzAk2Qu4C8xFuGwQnMqRJ m+92d5zhcQixNGIrDF5+lpNzfJH9q+g9qhafhnPPgjWwAkRcq1V/mEInLKAb1Lkf ssjwaVDO38yp0vkgtx0LsY14yi/s0pzRR64qpxp70hIWJlSUVvu7nfRQzM9Q1Y+R CAqFCIZRRtwwt4spaG5i/g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1741383587; x= 1741469987; bh=no6DVR45LnkKAZfk68ah4Qg3THqJ7pP2CMs9sDSiiOU=; b=7 P8f54QBCRSJz05fuhCGZ22KNbotgEt2u7yBifKn/RzC5lg9DzutVa2seh8MK4+dB dG4Z4hA3d3zzp1k+crFJB4CEHhoTzDQoGx/iiSyQt3eSSNMEO1Akl1CcY0ceLUk6 G4hKnGuMkAPBTiBQfT1MgdJvQt4WNgcdwUQCRtM621pT05h1dDiS7HY3erORNO4p ++fGpKgbP1cGt7PdeDBg0/q03sJjO4+ae/KndnVeayxproJZuEUAETGEPyE2oO/S y0qHLCNWxflS5aRMqzJIfW2GJmAAwdOVEvVBkbAP5uLEPz3S2EM/J4E+ZI0125/l MsozzBKPsTTPflTY9fmzw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduuddujeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkfhggtggugfgjsehtkeertddt tdejnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhioh eqnecuggftrfgrthhtvghrnhepudelhfdthfetuddvtefhfedtiedtteehvddtkedvledt vdevgedtuedutdeitdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepsghorhhishessghurhdrihhopdhnsggprhgtphhtthhopeefpdhmohgu vgepshhmthhpohhuthdprhgtphhtthhopehfughmrghnrghnrgeskhgvrhhnvghlrdhorh hgpdhrtghpthhtoheplhhinhhugidqsghtrhhfshesvhhgvghrrdhkvghrnhgvlhdrohhr ghdprhgtphhtthhopehkvghrnhgvlhdqthgvrghmsehfsgdrtghomh X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Mar 2025 16:39:46 -0500 (EST) Date: Fri, 7 Mar 2025 13:40:40 -0800 From: Boris Burkov To: Filipe Manana Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 4/5] btrfs: explicitly ref count block_group on new_bgs list Message-ID: <20250307214040.GC3554015@zen.localdomain> References: <817581cbc85cfda4c2232fecbfdb6b615b7067ca.1741306938.git.boris@bur.io> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Mar 07, 2025 at 02:37:28PM +0000, Filipe Manana wrote: > On Fri, Mar 7, 2025 at 12:31 AM Boris Burkov wrote: > > > > All other users of the bg_list list_head inc the refcount when adding to > > a list and dec it when deleting from the list. Just for the sake of > > uniformity and to try to avoid refcounting bugs, do it for this list as > > well. > > Please add a note that the reason why it's not ref counted is because > the list of new block groups belongs to a transaction handle, which is > local and therefore no other tasks can access it. > Just to make sure, I understand you correctly: you'd like me to add this as a historical note to the commit message? Happy to do so if that's what you mean. Otherwise, I'm confused about your intent. If you are saying that it's better to not refcount it, then we can drop this patch, it's not a fix, just another "try to establish invariants" kinda thing. > > > > Signed-off-by: Boris Burkov > > --- > > fs/btrfs/block-group.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c > > index 2db1497b58d9..e4071897c9a8 100644 > > --- a/fs/btrfs/block-group.c > > +++ b/fs/btrfs/block-group.c > > @@ -2801,6 +2801,7 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans) > > spin_lock(&fs_info->unused_bgs_lock); > > list_del_init(&block_group->bg_list); > > clear_bit(BLOCK_GROUP_FLAG_NEW, &block_group->runtime_flags); > > + btrfs_put_block_group(block_group); > > spin_unlock(&fs_info->unused_bgs_lock); > > > > /* > > @@ -2939,6 +2940,7 @@ struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *tran > > } > > #endif > > > > + btrfs_get_block_group(cache); > > list_add_tail(&cache->bg_list, &trans->new_bgs); > > btrfs_inc_delayed_refs_rsv_bg_inserts(fs_info); > > There's a missing btrfs_put_block_group() call at > btrfs_cleanup_pending_block_groups(). Good catch, thanks. > > Thanks. > > > > > > -- > > 2.48.1 > > > >