Re: [PATCH v3 2/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor

From: Christoph Hellwig

Date: Tue Dec 01 2026 - 03:31:30 EST


On Tue, Dec 01, 2026 at 03:49:47PM +0800, zhangshida2026@xxxxxxx wrote:
>
> + bool rc_done; /* no more shared records to find */

overly long line. Just stip the "to find".

> 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)

As pointed out last time, please just put the final alignment in place
in the previous patch instead of the churn here.

> + /* Advance to the first record that ends after agbno. */
> + while (rc->rc_startblock + rc->rc_blockcount <= agbno) {
> + error = xfs_btree_increment(info->refcount_cur, 0, &have);
> + if (error)
> + goto out_error;
> + if (!have) {
> + info->rc_done = true;
> + return 0;
> + }
> + error = xfs_refcount_get_rec(info->refcount_cur, &info->rc_cur, &i);

Overly long line.

> + if (error)
> + goto out_error;
> + if (XFS_IS_CORRUPT(mp, i != 1)) {
> + xfs_btree_mark_sick(info->refcount_cur);
> + error = -EFSCORRUPTED;
> + goto out_error;
> + }
> + }
>
> - *stat = flen > 0;
> + /* Shared iff this SHARED record overlaps the query range. */
> + if (rc->rc_domain == XFS_REFC_DOMAIN_SHARED &&
> + rc->rc_startblock < agbno + XFS_BB_TO_FSBT(mp, frec->len_daddr))

As point out by Sashiko last round, the iteration above should just
break out once the record isn't in the shared domain, saving potentially
pointless iteration‥