From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.137.202.133 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796043080; b=BbcmeixzHEZVYM2Tl5qj/Jr6+Etjw5UTjYnYpaV54cASRAs//9nAm6DZDm+IUsonEnqG JnqJYgaf54yEOBiulQA8V5MsUrcl++txnw4F7Wmge/3q/0GVd+0reG1GDJlYVBMqxqPe+ mq5hSckk6yP6v6D16qjV9mRng5nUJupDunuLHgDdAhrk5mMomGz8utswNu2p7Xu9LHDAG plN0zUzFDJow35OioqAwhazOBumLKFDaAVaPmRS2ilWanJZ5dadtV6MWcfkHTfflc1yb7 Q6e7IYGVkG2mQRJ4spS1CeclDngperWfP++M6t5wJH1nHdMTMScM17oUWOUYw+UCpiw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796043080; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:X-SRS-Rewrite; bh=uJzmylCwW0wWYv5d7KHgvqq7dqCI3Bzu0PMmnc9Shx0=; b=vWNpe/sBLLDPQjh0+8deUjrmS2JNTe2pRU+dojIxOHAlQr/Hb0JRixAVlJwUtiTaIEMH r+O+OP8h43sUMApcQHSgfoSsNPgHPnW2j9Z4CInWs5oWbtVqQ3rgYvleHgxo0XS1sNbQ7 e3GzQ7/XKG+we1Aj0zgstue1FV6+cV/ilmcHhbr4Gc3rb+mtZDoL7lNpFuYAXNfgmQIRJ PsofJqJka5AHtEH/b+SYiaaAinoIvsHQ6KKmI6Vh93nw5OwjUEnatalP6oSCXeU5hQkrs uvybk22Pkep894D0u4lfBYnn75cSLFaeNfK32i6V/dB35nDEu0Un6Ca8QMxlT8zQCgA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=infradead.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ALKKl1rO; arc=none smtp.remote-ip=198.137.202.133 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F32FB606A31C; Mon, 30 Nov 2026 12:51:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F32FB606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ALKKl1rO DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uJzmylCwW0wWYv5d7KHgvqq7dqCI3Bzu0PMmnc9Shx0=; b=ALKKl1rONx5i0cScU8A+V0I5lm M0Bj0tgWEvxceXZ15ZHkrFkV61VsZebYGWJhfMtrFefYUosjdu17//Dp4Wfs5xhkOD7hkL+Yk1EIR yMvGtSn/G49PNCfHrPVaDkFYPiWm4dic9XV/lvvwifec5NeW8awJqeXj7n8GU9kQn502tvMg7rG/0 cctkUNesXvvgmBoLl3GxsEQeLzM/0zzsEYqouQoI/asSB/ziydKJvwt/N78nuB3IQozqyGkUiDahe AXBR8eVaeE3oKOFJSltClYXwshbwUbYrOQzW6QauGaCFivlSkWlAj7p3GWX1qHS4RixqUu7vjKFzn Vj6jlGlA==; Received: from hch by bombadil.infradead.org with local (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY0qS-00000004Xj0-3tc1; Mon, 30 Nov 2026 12:51:17 +0000 Date: Mon, 30 Nov 2026 04:51:00 -0800 From: Christoph Hellwig To: zhangshida2026@163.com Cc: Carlos Maiolino , "Darrick J . Wong" , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, Shida Zhang Subject: Re: [PATCH v2 2/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor Message-ID: References: <20261123075048.3658960-1-zhangshida@kylinos.cn> <20261126013009.533557-1-zhangshida2026@163.com> <20261126013009.533557-3-zhangshida2026@163.com> X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261126013009.533557-3-zhangshida2026@163.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html On Thu, Nov 26, 2026 at 09:30:09AM +0800, zhangshida2026@163.com wrote: > Suggested-by: Christoph Hellwig Not really, this was all your own idea. I just did a round of feedback. > + struct xfs_btree_cur *refcount_cur; /* cached refcountbt cursor */ > + struct xfs_refcount_irec rc_cur; /* current refcount record */ > + bool rc_eof; /* refcount cursor past end */ I should have pointed that out before, but the name for the flag is a bit odd. eof stands for end of file, so it doesn't really apply here. Maybe call this rc_done > struct xfs_group *group; /* group info, if applicable */ > xfs_daddr_t next_daddr; /* next daddr we expect */ > /* daddr of low fsmap key when we're using the rtbitmap */ > @@ -205,15 +210,79 @@ xfs_getfsmap_dev_compare( > /* Delete the btree cursors used by a getfsmap group walk. */ > static void > xfs_getfsmap_del_cursors( > - struct xfs_btree_cur *bt_cur, > - int error) > + struct xfs_getfsmap_info *info, > + struct xfs_btree_cur *bt_cur, > + int error) Next time just adjust to the final alignment in the firstr patch. > { > + if (info->refcount_cur) { > + xfs_btree_del_cursor(info->refcount_cur, error < 0 ? > + XFS_BTREE_ERROR : XFS_BTREE_NOERROR); > + info->refcount_cur = NULL; > + info->rc_eof = false; > + } > if (bt_cur) > xfs_btree_del_cursor(bt_cur, error < 0 ? > XFS_BTREE_ERROR : XFS_BTREE_NOERROR); And maybe keep a local variable for XFS_BTREE_ERROR vs XFS_BTREE_NOERROR. (and we should probably turn XFS_BTREE_NOERROR/XFS_BTREE_ERROR into an enum pass that to xfs_btree_del_cursor, but that's a separate project). > } > > -/* Decide if this mapping is shared. */ > +/* > + * Allocate the refcount cursor for this group and position it at the last > + * record at or before agbno, or the first record if there is none. Set > + * rc_eof if the btree has no records at or after agbno. This is just a summar of what the code does and not really adds any additional information. Please don't bother with such comments. Comments are useful to explain why something is done, or if something done is really non-obvious. > @@ -223,31 +292,55 @@ xfs_getfsmap_is_shared( > { > struct xfs_mount *mp = tp->t_mountp; > struct xfs_btree_cur *cur; > - xfs_agblock_t fbno; > - xfs_extlen_t flen = 0; > - int error; > + struct xfs_refcount_irec *rc = &info->rc_cur; struct xfs_refcount_irec *rc = &info->rc_cur; > + xfs_agblock_t agbno = frec->rec_key; > + xfs_extlen_t aglen = XFS_BB_TO_FSBT(mp, frec->len_daddr); > xfs_extlen_t aglen = XFS_BB_TO_FSBT(mp, frec->len_daddr); .. or just do away with the variable as it just has a single user. > + } > + cur = info->refcount_cur; I'd probably do away with this variable. Given that the function deals with two different cursors, having the local variable isn't super helpful. > > + /* Advance to the first SHARED record that ends after agbno. */ > + while (rc->rc_domain != XFS_REFC_DOMAIN_SHARED || > + rc->rc_startblock + rc->rc_blockcount <= agbno) { Sashiko complains that this iterators over XFS_REFC_DOMAIN_COW unintentionally and I think it is right.