Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Andrey Albershteyn <aalbersh@kernel.org>,
	Damien Le Moal <dlemoal@kernel.org>,
	Carlos Maiolino <cem@kernel.org>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/4] libfrog: enable cached report zones
Date: Fri, 9 Jan 2026 08:32:35 -0800	[thread overview]
Message-ID: <20260109163235.GT15551@frogsfrogsfrogs> (raw)
In-Reply-To: <20260109162324.2386829-5-hch@lst.de>

On Fri, Jan 09, 2026 at 05:22:55PM +0100, Christoph Hellwig wrote:
> From: Damien Le Moal <dlemoal@kernel.org>
> 
> Modify the function xfrog_report_zones() to default to always trying
> first a cached report zones using the BLKREPORTZONEV2 ioctl.
> If the kernel does not support BLKREPORTZONEV2, fall back to the
> (slower) regular report zones BLKREPORTZONE ioctl.
> 
> TO enable this feature even if xfsprogs is compiled on a system where
> linux/blkzoned.h does not define BLKREPORTZONEV2, this ioctl is defined
> in libfrog/zones.h, together with the BLK_ZONE_REP_CACHED flag and the
> BLK_ZONE_COND_ACTIVE zone condition.
> 
> Since a cached report zone  always return the condition
> BLK_ZONE_COND_ACTIVE for any zone that is implicitly open, explicitly
> open or closed, the function xfs_zone_validate_seq() is modified to
> handle this new condition as being equivalent to the implicit open,
> explicit open or closed conditions.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> [hch: don't try cached reporting again if not supported]
> Signed-off-by: Christoph Hellwig <hch@lst.de>

That's an amusing use of atomic_t :)
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  libfrog/zones.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/libfrog/zones.c b/libfrog/zones.c
> index 2276c56bec9c..f1ef0b24c564 100644
> --- a/libfrog/zones.c
> +++ b/libfrog/zones.c
> @@ -3,12 +3,24 @@
>   * Copyright (c) 2025, Western Digital Corporation or its affiliates.
>   */
>  #include "platform_defs.h"
> +#include "atomic.h"
>  #include "libfrog/zones.h"
>  #include <sys/ioctl.h>
>  
> +/*
> + * Cached report ioctl (/usr/include/linux/blkzoned.h).
> + * Add in Linux 6.19.
> + */
> +#ifndef BLKREPORTZONEV2
> +#define BLKREPORTZONEV2		_IOWR(0x12, 142, struct blk_zone_report)
> +#define BLK_ZONE_REP_CACHED	(1U << 31)
> +#endif /* BLKREPORTZONEV2 */
> +
>  /* random size that allows efficient processing */
>  #define ZONES_PER_REPORT		16384
>  
> +static atomic_t cached_reporting_disabled;
> +
>  struct xfrog_zone_report *
>  xfrog_report_zones(
>  	int			fd,
> @@ -24,10 +36,27 @@ _("Failed to allocate memory for reporting zones."));
>  		}
>  	}
>  
> +	/*
> +	 * Try cached report zones first. If this fails, fallback to the regular
> +	 * (slower) report zones.
> +	 */
>  	rep->rep.sector = sector;
>  	rep->rep.nr_zones = ZONES_PER_REPORT;
>  
> -	if (ioctl(fd, BLKREPORTZONE, &rep->rep)) {
> +	if (atomic_read(&cached_reporting_disabled))
> +		goto uncached;
> +
> +	rep->rep.flags = BLK_ZONE_REP_CACHED;
> +	if (ioctl(fd, BLKREPORTZONEV2, &rep->rep)) {
> +		atomic_inc(&cached_reporting_disabled);
> +		goto uncached;
> +	}
> +
> +	return rep;
> +
> +uncached:
> +	rep->rep.flags = 0;
> +	if (ioctl(fd, BLKREPORTZONE, rep)) {
>  		fprintf(stderr, "%s %s\n",
>  _("ioctl(BLKREPORTZONE) failed:\n"),
>  			strerror(-errno));
> -- 
> 2.47.3
> 
> 

  reply	other threads:[~2026-01-09 16:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 16:22 enable cached zone report v4 Christoph Hellwig
2026-01-09 16:22 ` [PATCH 1/4] xfs: use blkdev_report_zones_cached() Christoph Hellwig
2026-01-20 14:28   ` Andrey Albershteyn
2026-01-20 17:31     ` Darrick J. Wong
2026-01-21  6:49       ` Christoph Hellwig
2026-01-27 16:39         ` [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check Andrey Albershteyn
2026-01-27 16:43           ` Christoph Hellwig
2026-01-27 16:55             ` Andrey Albershteyn
2026-01-27 16:59               ` Andrey Albershteyn
2026-01-27 17:01                 ` Christoph Hellwig
2026-01-09 16:22 ` [PATCH 2/4] mkfs: remove unnecessary return value affectation Christoph Hellwig
2026-01-09 16:22 ` [PATCH 3/4] libfrog: lift common zone reporting code from mkfs and repair Christoph Hellwig
2026-01-09 16:31   ` Darrick J. Wong
2026-01-09 16:22 ` [PATCH 4/4] libfrog: enable cached report zones Christoph Hellwig
2026-01-09 16:32   ` Darrick J. Wong [this message]
2026-01-12 11:02 ` enable cached zone report v4 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=20260109163235.GT15551@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@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