linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>,
	Damien Le Moal <dlemoal@kernel.org>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/6] xfs: use blkdev_get_zone_info to simply zone reporting
Date: Fri, 9 Jan 2026 17:28:43 -0800	[thread overview]
Message-ID: <20260110012843.GZ15551@frogsfrogsfrogs> (raw)
In-Reply-To: <20260109172139.2410399-7-hch@lst.de>

On Fri, Jan 09, 2026 at 06:20:51PM +0100, Christoph Hellwig wrote:
> Unwind the callback based programming model by querying the cached
> zone information using blkdev_get_zone_info.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Ok, so now I see what's going here -- the libxfs zone code does the
validation, but it's up to the code in fs/xfs/ (or libxfs/init.c in
userspace) to find the zone information.  Let's hope the cached zone
information reduces the noticeable(ish) mount delays on some of my zoned
hardware.

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_zone_alloc.c | 104 +++++++++++++++++-----------------------
>  1 file changed, 45 insertions(+), 59 deletions(-)
> 
> diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
> index 00260f70242f..2849be19369e 100644
> --- a/fs/xfs/xfs_zone_alloc.c
> +++ b/fs/xfs/xfs_zone_alloc.c
> @@ -976,7 +976,6 @@ xfs_free_open_zones(
>  }
>  
>  struct xfs_init_zones {
> -	struct xfs_mount	*mp;
>  	uint32_t		zone_size;
>  	uint32_t		zone_capacity;
>  	uint64_t		available;
> @@ -1009,6 +1008,39 @@ xfs_rmap_write_pointer(
>  	return highest_rgbno + 1;
>  }
>  
> +static int
> +xfs_query_write_pointer(
> +	struct xfs_init_zones	*iz,
> +	struct xfs_rtgroup	*rtg,
> +	xfs_rgblock_t		*write_pointer)
> +{
> +	struct xfs_mount	*mp = rtg_mount(rtg);
> +	struct block_device	*bdev = mp->m_rtdev_targp->bt_bdev;
> +	sector_t		start = xfs_gbno_to_daddr(&rtg->rtg_group, 0);
> +	struct blk_zone		zone = {
> +		.cond	= BLK_ZONE_COND_NOT_WP,
> +	};
> +	int			error;
> +
> +	if (bdev_is_zoned(bdev)) {
> +		error = blkdev_get_zone_info(bdev, start, &zone);
> +		if (error)
> +			return error;
> +		if (zone.start != start) {
> +			xfs_warn(mp, "mismatched zone start: 0x%llx/0x%llx.",
> +				zone.start, start);
> +			return -EFSCORRUPTED;
> +		}
> +		if (!xfs_zone_validate(mp, &zone, rtg_rgno(rtg), iz->zone_size,
> +				iz->zone_capacity, write_pointer))
> +			return -EFSCORRUPTED;
> +	}
> +
> +	if (zone.cond == BLK_ZONE_COND_NOT_WP)
> +		*write_pointer = xfs_rmap_write_pointer(rtg);
> +	return 0;
> +}
> +
>  static int
>  xfs_init_zone(
>  	struct xfs_init_zones	*iz,
> @@ -1084,43 +1116,6 @@ xfs_init_zone(
>  	return 0;
>  }
>  
> -static int
> -xfs_get_zone_info_cb(
> -	struct blk_zone		*zone,
> -	unsigned int		idx,
> -	void			*data)
> -{
> -	struct xfs_init_zones	*iz = data;
> -	struct xfs_mount	*mp = iz->mp;
> -	xfs_fsblock_t		zsbno = xfs_daddr_to_rtb(mp, zone->start);
> -	xfs_rgnumber_t		rgno;
> -	xfs_rgblock_t		write_pointer;
> -	struct xfs_rtgroup	*rtg;
> -	int			error;
> -
> -	if (xfs_rtb_to_rgbno(mp, zsbno) != 0) {
> -		xfs_warn(mp, "mismatched zone start 0x%llx.", zsbno);
> -		return -EFSCORRUPTED;
> -	}
> -
> -	rgno = xfs_rtb_to_rgno(mp, zsbno);
> -	rtg = xfs_rtgroup_grab(mp, rgno);
> -	if (!rtg) {
> -		xfs_warn(mp, "realtime group not found for zone %u.", rgno);
> -		return -EFSCORRUPTED;
> -	}
> -	if (!xfs_zone_validate(mp, zone, idx, iz->zone_size,
> -			iz->zone_capacity, &write_pointer)) {
> -		xfs_rtgroup_rele(rtg);
> -		return -EFSCORRUPTED;
> -	}
> -	if (zone->cond == BLK_ZONE_COND_NOT_WP)
> -		write_pointer = xfs_rmap_write_pointer(rtg);
> -	error = xfs_init_zone(iz, rtg, write_pointer);
> -	xfs_rtgroup_rele(rtg);
> -	return error;
> -}
> -
>  /*
>   * Calculate the max open zone limit based on the of number of backing zones
>   * available.
> @@ -1255,15 +1250,13 @@ xfs_mount_zones(
>  	struct xfs_mount	*mp)
>  {
>  	struct xfs_init_zones	iz = {
> -		.mp		= mp,
>  		.zone_capacity	= mp->m_groups[XG_TYPE_RTG].blocks,
>  		.zone_size	= xfs_rtgroup_raw_size(mp),
>  	};
> -	struct xfs_buftarg	*bt = mp->m_rtdev_targp;
> -	xfs_extlen_t		zone_blocks = mp->m_groups[XG_TYPE_RTG].blocks;
> +	struct xfs_rtgroup	*rtg = NULL;
>  	int			error;
>  
> -	if (!bt) {
> +	if (!mp->m_rtdev_targp) {
>  		xfs_notice(mp, "RT device missing.");
>  		return -EINVAL;
>  	}
> @@ -1291,7 +1284,7 @@ xfs_mount_zones(
>  		return -ENOMEM;
>  
>  	xfs_info(mp, "%u zones of %u blocks (%u max open zones)",
> -		 mp->m_sb.sb_rgcount, zone_blocks, mp->m_max_open_zones);
> +		 mp->m_sb.sb_rgcount, iz.zone_capacity, mp->m_max_open_zones);
>  	trace_xfs_zones_mount(mp);
>  
>  	/*
> @@ -1315,25 +1308,18 @@ xfs_mount_zones(
>  	 * or beneficial.
>  	 */
>  	mp->m_super->s_min_writeback_pages =
> -		XFS_FSB_TO_B(mp, min(zone_blocks, XFS_MAX_BMBT_EXTLEN)) >>
> +		XFS_FSB_TO_B(mp, min(iz.zone_capacity, XFS_MAX_BMBT_EXTLEN)) >>
>  			PAGE_SHIFT;
>  
> -	if (bdev_is_zoned(bt->bt_bdev)) {
> -		error = blkdev_report_zones_cached(bt->bt_bdev,
> -				XFS_FSB_TO_BB(mp, mp->m_sb.sb_rtstart),
> -				mp->m_sb.sb_rgcount, xfs_get_zone_info_cb, &iz);
> -		if (error < 0)
> +	while ((rtg = xfs_rtgroup_next(mp, rtg))) {
> +		xfs_rgblock_t		write_pointer;
> +
> +		error = xfs_query_write_pointer(&iz, rtg, &write_pointer);
> +		if (!error)
> +			error = xfs_init_zone(&iz, rtg, write_pointer);
> +		if (error) {
> +			xfs_rtgroup_rele(rtg);
>  			goto out_free_zone_info;
> -	} else {
> -		struct xfs_rtgroup	*rtg = NULL;
> -
> -		while ((rtg = xfs_rtgroup_next(mp, rtg))) {
> -			error = xfs_init_zone(&iz, rtg,
> -					xfs_rmap_write_pointer(rtg));
> -			if (error) {
> -				xfs_rtgroup_rele(rtg);
> -				goto out_free_zone_info;
> -			}
>  		}
>  	}
>  
> -- 
> 2.47.3
> 
> 

  reply	other threads:[~2026-01-10  1:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 17:20 refactor zone reporting Christoph Hellwig
2026-01-09 17:20 ` [PATCH 1/6] xfs: add missing forward declaration in xfs_zones.h Christoph Hellwig
2026-01-10  0:50   ` Darrick J. Wong
2026-01-09 17:20 ` [PATCH 2/6] xfs: add a xfs_rtgroup_raw_size helper Christoph Hellwig
2026-01-10  1:00   ` Darrick J. Wong
2026-01-09 17:20 ` [PATCH 3/6] xfs: pass the write pointer to xfs_init_zone Christoph Hellwig
2026-01-10  1:11   ` Darrick J. Wong
2026-01-12 10:15   ` Damien Le Moal
2026-01-12 21:50     ` Darrick J. Wong
2026-01-13  7:47       ` Christoph Hellwig
2026-01-13  7:47     ` Christoph Hellwig
2026-01-13  9:27       ` Damien Le Moal
2026-01-09 17:20 ` [PATCH 4/6] xfs: split and refactor zone validation Christoph Hellwig
2026-01-10  1:44   ` Darrick J. Wong
2026-01-12 10:12     ` Christoph Hellwig
2026-01-09 17:20 ` [PATCH 5/6] xfs: check that used blocks are smaller than the write pointer Christoph Hellwig
2026-01-10  1:25   ` Darrick J. Wong
2026-01-09 17:20 ` [PATCH 6/6] xfs: use blkdev_get_zone_info to simply zone reporting Christoph Hellwig
2026-01-10  1:28   ` Darrick J. Wong [this message]
2026-01-13 10:33   ` Damien Le Moal

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=20260110012843.GZ15551@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).