public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Andrey Albershteyn <aalbersh@kernel.org>,
	Hans Holmberg <hans.holmberg@wdc.com>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 27/45] xfs_repair: support repairing zoned file systems
Date: Wed, 9 Apr 2025 09:10:12 -0700	[thread overview]
Message-ID: <20250409161012.GC6283@frogsfrogsfrogs> (raw)
In-Reply-To: <20250409075557.3535745-28-hch@lst.de>

On Wed, Apr 09, 2025 at 09:55:30AM +0200, Christoph Hellwig wrote:
> Note really much to do here.  Mostly ignore the validation and
> regeneration of the bitmap and summary inodes.  Eventually this
> could grow a bit of validation of the hardware zone state.

What do we actually do about the hardware zone state?  If the write
pointer is lower than wherever the rtrmapbt thinks it is, then we're
screwed, right?

Does it matter if the hw write pointer is higher than where the rtrmapbt
thinks it is?  In that case, a new write will be beyond the last write
that the filesystem knows about, but the device will tell us the disk
address so it's all good aside from the freertx counters being wrong.  I
think?

The code changes presented here look ok to me though.

--D

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  repair/dinode.c        |  4 +++-
>  repair/phase5.c        | 13 +++++++++++++
>  repair/phase6.c        |  6 ++++--
>  repair/rt.c            |  2 ++
>  repair/rtrmap_repair.c | 33 +++++++++++++++++++++++++++++++++
>  repair/xfs_repair.c    |  9 ++++++---
>  6 files changed, 61 insertions(+), 6 deletions(-)
> 
> diff --git a/repair/dinode.c b/repair/dinode.c
> index 8696a838087f..7bdd3dcf15c1 100644
> --- a/repair/dinode.c
> +++ b/repair/dinode.c
> @@ -3585,7 +3585,9 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"),
>  
>  	validate_extsize(mp, dino, lino, dirty);
>  
> -	if (dino->di_version >= 3)
> +	if (dino->di_version >= 3 &&
> +	    (!xfs_has_zoned(mp) ||
> +	     dino->di_metatype != cpu_to_be16(XFS_METAFILE_RTRMAP)))
>  		validate_cowextsize(mp, dino, lino, dirty);
>  
>  	/* nsec fields cannot be larger than 1 billion */
> diff --git a/repair/phase5.c b/repair/phase5.c
> index 4cf28d8ae1a2..e350b411c243 100644
> --- a/repair/phase5.c
> +++ b/repair/phase5.c
> @@ -630,6 +630,19 @@ void
>  check_rtmetadata(
>  	struct xfs_mount	*mp)
>  {
> +	if (xfs_has_zoned(mp)) {
> +		/*
> +		 * Here we could/should verify the zone state a bit when we are
> +		 * on actual zoned devices:
> +		 *	- compare hw write pointer to last written
> +		 *	- compare zone state to last written
> +		 *
> +		 * Note much we can do when running in zoned mode on a
> +		 * conventional device.
> +		 */
> +		return;
> +	}
> +
>  	generate_rtinfo(mp);
>  	check_rtbitmap(mp);
>  	check_rtsummary(mp);
> diff --git a/repair/phase6.c b/repair/phase6.c
> index dbc090a54139..a7187e84daae 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -3460,8 +3460,10 @@ _("        - resetting contents of realtime bitmap and summary inodes\n"));
>  		return;
>  
>  	while ((rtg = xfs_rtgroup_next(mp, rtg))) {
> -		ensure_rtgroup_bitmap(rtg);
> -		ensure_rtgroup_summary(rtg);
> +		if (!xfs_has_zoned(mp)) {
> +			ensure_rtgroup_bitmap(rtg);
> +			ensure_rtgroup_summary(rtg);
> +		}
>  		ensure_rtgroup_rmapbt(rtg, est_fdblocks);
>  		ensure_rtgroup_refcountbt(rtg, est_fdblocks);
>  	}
> diff --git a/repair/rt.c b/repair/rt.c
> index e0a4943ee3b7..a2478fb635e3 100644
> --- a/repair/rt.c
> +++ b/repair/rt.c
> @@ -222,6 +222,8 @@ check_rtfile_contents(
>  	xfs_fileoff_t		bno = 0;
>  	int			error;
>  
> +	ASSERT(!xfs_has_zoned(mp));
> +
>  	if (!ip) {
>  		do_warn(_("unable to open %s file\n"), filename);
>  		return;
> diff --git a/repair/rtrmap_repair.c b/repair/rtrmap_repair.c
> index 2b07e8943e59..955db1738fe2 100644
> --- a/repair/rtrmap_repair.c
> +++ b/repair/rtrmap_repair.c
> @@ -141,6 +141,37 @@ xrep_rtrmap_btree_load(
>  	return error;
>  }
>  
> +static void
> +rtgroup_update_counters(
> +	struct xfs_rtgroup	*rtg)
> +{
> +	struct xfs_inode	*rmapip = rtg->rtg_inodes[XFS_RTGI_RMAP];
> +	struct xfs_mount	*mp = rtg_mount(rtg);
> +	uint64_t		end =
> +		xfs_rtbxlen_to_blen(mp, rtg->rtg_extents);
> +	xfs_agblock_t		gbno = 0;
> +	uint64_t		used = 0;
> +
> +	do {
> +		int		bstate;
> +		xfs_extlen_t	blen;
> +
> +		bstate = get_bmap_ext(rtg_rgno(rtg), gbno, end, &blen, true);
> +		switch (bstate) {
> +		case XR_E_INUSE:
> +		case XR_E_INUSE_FS:
> +			used += blen;
> +			break;
> +		default:
> +			break;
> +		}
> +
> +		gbno += blen;
> +	} while (gbno < end);
> +
> +	rmapip->i_used_blocks = used;
> +}
> +
>  /* Update the inode counters. */
>  STATIC int
>  xrep_rtrmap_reset_counters(
> @@ -153,6 +184,8 @@ xrep_rtrmap_reset_counters(
>  	 * generated.
>  	 */
>  	sc->ip->i_nblocks = rr->new_fork_info.ifake.if_blocks;
> +	if (xfs_has_zoned(sc->mp))
> +		rtgroup_update_counters(rr->rtg);
>  	libxfs_trans_log_inode(sc->tp, sc->ip, XFS_ILOG_CORE);
>  
>  	/* Quotas don't exist so we're done. */
> diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
> index eeaaf6434689..7bf75c09b945 100644
> --- a/repair/xfs_repair.c
> +++ b/repair/xfs_repair.c
> @@ -1388,16 +1388,19 @@ main(int argc, char **argv)
>  	 * Done with the block usage maps, toss them.  Realtime metadata aren't
>  	 * rebuilt until phase 6, so we have to keep them around.
>  	 */
> -	if (mp->m_sb.sb_rblocks == 0)
> +	if (mp->m_sb.sb_rblocks == 0) {
>  		rmaps_free(mp);
> -	free_bmaps(mp);
> +		free_bmaps(mp);
> +	}
>  
>  	if (!bad_ino_btree)  {
>  		phase6(mp);
>  		phase_end(mp, 6);
>  
> -		if (mp->m_sb.sb_rblocks != 0)
> +		if (mp->m_sb.sb_rblocks != 0) {
>  			rmaps_free(mp);
> +			free_bmaps(mp);
> +		}
>  		free_rtgroup_inodes();
>  
>  		phase7(mp, phase2_threads);
> -- 
> 2.47.2
> 
> 

  reply	other threads:[~2025-04-09 16:10 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09  7:55 xfsprogs support for zoned devices Christoph Hellwig
2025-04-09  7:55 ` [PATCH 01/45] xfs: generalize the freespace and reserved blocks handling Christoph Hellwig
2025-04-09  7:55 ` [PATCH 02/45] FIXUP: " Christoph Hellwig
2025-04-09 15:32   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 03/45] xfs: make metabtree reservations global Christoph Hellwig
2025-04-09  7:55 ` [PATCH 04/45] FIXUP: " Christoph Hellwig
2025-04-09 15:43   ` Darrick J. Wong
2025-04-10  6:00     ` Christoph Hellwig
2025-04-09  7:55 ` [PATCH 05/45] xfs: reduce metafile reservations Christoph Hellwig
2025-04-09  7:55 ` [PATCH 06/45] xfs: add a rtg_blocks helper Christoph Hellwig
2025-04-09  7:55 ` [PATCH 07/45] xfs: move xfs_bmapi_reserve_delalloc to xfs_iomap.c Christoph Hellwig
2025-04-09  7:55 ` [PATCH 08/45] xfs: support XFS_BMAPI_REMAP in xfs_bmap_del_extent_delay Christoph Hellwig
2025-04-09  7:55 ` [PATCH 09/45] xfs: add a xfs_rtrmap_highest_rgbno helper Christoph Hellwig
2025-04-09  7:55 ` [PATCH 10/45] xfs: define the zoned on-disk format Christoph Hellwig
2025-04-09  7:55 ` [PATCH 11/45] FIXUP: " Christoph Hellwig
2025-04-09 15:47   ` Darrick J. Wong
2025-04-09 16:04     ` Darrick J. Wong
2025-04-10  6:01     ` Christoph Hellwig
2025-04-10 16:31       ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 12/45] xfs: allow internal RT devices for zoned mode Christoph Hellwig
2025-04-09  7:55 ` [PATCH 13/45] FIXUP: " Christoph Hellwig
2025-04-09 15:55   ` Darrick J. Wong
2025-04-10  6:09     ` Christoph Hellwig
2025-04-09  7:55 ` [PATCH 14/45] xfs: export zoned geometry via XFS_FSOP_GEOM Christoph Hellwig
2025-04-09  7:55 ` [PATCH 15/45] xfs: disable sb_frextents for zoned file systems Christoph Hellwig
2025-04-09  7:55 ` [PATCH 16/45] xfs: parse and validate hardware zone information Christoph Hellwig
2025-04-09  7:55 ` [PATCH 17/45] FIXUP: " Christoph Hellwig
2025-04-09 15:56   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 18/45] xfs: add the zoned space allocator Christoph Hellwig
2025-04-09  7:55 ` [PATCH 19/45] xfs: add support for zoned space reservations Christoph Hellwig
2025-04-09  7:55 ` [PATCH 20/45] FIXUP: " Christoph Hellwig
2025-04-09 15:56   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 21/45] xfs: implement zoned garbage collection Christoph Hellwig
2025-04-09  7:55 ` [PATCH 22/45] xfs: enable fsmap reporting for internal RT devices Christoph Hellwig
2025-04-09  7:55 ` [PATCH 23/45] xfs: enable the zoned RT device feature Christoph Hellwig
2025-04-09  7:55 ` [PATCH 24/45] xfs: support zone gaps Christoph Hellwig
2025-04-09  7:55 ` [PATCH 25/45] FIXUP: " Christoph Hellwig
2025-04-09 15:57   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 26/45] libfrog: report the zoned flag Christoph Hellwig
2025-04-09 15:58   ` Darrick J. Wong
2025-04-10  6:14     ` Christoph Hellwig
2025-04-10 16:36       ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 27/45] xfs_repair: support repairing zoned file systems Christoph Hellwig
2025-04-09 16:10   ` Darrick J. Wong [this message]
2025-04-10  6:27     ` Christoph Hellwig
2025-04-10 16:41       ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 28/45] xfs_repair: fix the RT device check in process_dinode_int Christoph Hellwig
2025-04-09 16:11   ` Darrick J. Wong
2025-04-10  6:29     ` Christoph Hellwig
2025-04-09  7:55 ` [PATCH 29/45] xfs_repair: validate rt groups vs reported hardware zones Christoph Hellwig
2025-04-09 18:41   ` Darrick J. Wong
2025-04-10  6:34     ` Christoph Hellwig
2025-04-10 16:43       ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 30/45] xfs_mkfs: support creating zoned file systems Christoph Hellwig
2025-04-09 18:54   ` Darrick J. Wong
2025-04-10  6:45     ` Christoph Hellwig
2025-04-10 16:45       ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 31/45] xfs_mkfs: calculate zone overprovisioning when specifying size Christoph Hellwig
2025-04-09 19:06   ` Darrick J. Wong
2025-04-10  7:00     ` Christoph Hellwig
2025-04-09  7:55 ` [PATCH 32/45] xfs_mkfs: default to rtinherit=1 for zoned file systems Christoph Hellwig
2025-04-09 18:59   ` Darrick J. Wong
2025-04-10  6:45     ` Christoph Hellwig
2025-04-09  7:55 ` [PATCH 33/45] xfs_mkfs: reflink conflicts with zoned file systems for now Christoph Hellwig
2025-04-09 19:00   ` Darrick J. Wong
2025-04-10  6:46     ` Christoph Hellwig
2025-04-10 16:47       ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 34/45] xfs_mkfs: document the new zoned options in the man page Christoph Hellwig
2025-04-09 19:00   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 35/45] libfrog: report the zoned geometry Christoph Hellwig
2025-04-09 19:01   ` Darrick J. Wong
2025-04-10  7:02     ` Christoph Hellwig
2025-04-09  7:55 ` [PATCH 36/45] man: document XFS_FSOP_GEOM_FLAGS_ZONED Christoph Hellwig
2025-04-09 19:13   ` Darrick J. Wong
2025-04-10  6:53     ` Christoph Hellwig
2025-04-10 16:47       ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 37/45] xfs_io: correctly report RGs with internal rt dev in bmap output Christoph Hellwig
2025-04-09 22:22   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 38/45] xfs_io: don't re-query fs_path information in fsmap_f Christoph Hellwig
2025-04-09 20:48   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 39/45] xfs_io: don't re-query geometry " Christoph Hellwig
2025-04-09 20:46   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 40/45] xfs_io: handle internal RT devices in fsmap output Christoph Hellwig
2025-04-09 21:48   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 41/45] xfs_spaceman: handle internal RT devices Christoph Hellwig
2025-04-09 19:29   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 42/45] xfs_scrub: support internal RT sections Christoph Hellwig
2025-04-09 19:30   ` Darrick J. Wong
2025-04-10  6:57     ` Christoph Hellwig
2025-04-09  7:55 ` [PATCH 43/45] xfs_scrub: handle internal RT devices Christoph Hellwig
2025-04-09 19:34   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 44/45] xfs_mdrestore: support " Christoph Hellwig
2025-04-09 19:36   ` Darrick J. Wong
2025-04-09  7:55 ` [PATCH 45/45] xfs_growfs: " Christoph Hellwig
2025-04-09 19:35   ` Darrick J. Wong

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=20250409161012.GC6283@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@kernel.org \
    --cc=hans.holmberg@wdc.com \
    --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