From: Christoph Hellwig <hch@infradead.org>
To: zhangshida2026@163.com
Cc: Carlos Maiolino <cem@kernel.org>,
"Darrick J . Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Shida Zhang <zhangshida@kylinos.cn>
Subject: Re: [PATCH v2 2/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor
Date: Mon, 30 Nov 2026 04:51:00 -0800 [thread overview]
Message-ID: <aw1xNOd0BCbxmGC-@infradead.org> (raw)
In-Reply-To: <20261126013009.533557-3-zhangshida2026@163.com>
On Thu, Nov 26, 2026 at 09:30:09AM +0800, zhangshida2026@163.com wrote:
> Suggested-by: Christoph Hellwig <hch@infradead.org>
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.
prev parent reply other threads:[~2026-11-30 12:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 7:50 [PATCH] " Shida Zhang
2026-11-25 6:58 ` Christoph Hellwig
2026-11-26 1:30 ` [PATCH v2 0/2] " zhangshida2026
2026-11-26 1:30 ` [PATCH v2 1/2] xfs: factor out a xfs_getfsmap_del_cursors helper zhangshida2026
2026-11-30 12:39 ` Christoph Hellwig
2026-11-26 1:30 ` [PATCH v2 2/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor zhangshida2026
2026-11-30 12:51 ` Christoph Hellwig [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aw1xNOd0BCbxmGC-@infradead.org \
--to=hch@infradead.org \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zhangshida2026@163.com \
--cc=zhangshida@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®