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: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] repair: fix process_rt_rec_dups
Date: Wed, 8 Nov 2023 10:08:27 -0800	[thread overview]
Message-ID: <20231108180827.GW1205143@frogsfrogsfrogs> (raw)
In-Reply-To: <20231108175320.500847-1-hch@lst.de>

On Wed, Nov 08, 2023 at 06:53:20PM +0100, Christoph Hellwig wrote:
> search_rt_dup_extent takes a xfs_rtblock_t, not an RT extent number.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> What scares me about this is that no test seems to hit this and report
> false duplicates.  I'll need to see if I can come up with an
> artifical reproducers of some kind.

I think you've misread the code -- phase 4 builds the rt_dup tree by
walks all the rtextents, and adding the duplicates:

	for (rtx = 0; rtx < mp->m_sb.sb_rextents; rtx++)  {
		bstate = get_rtbmap(rtx);
		switch (bstate)  {
			...
		case XR_E_FS_MAP:
			if (rt_start == 0)
				continue;
			else  {
				/*
				 * add extent and reset extent state
				 */
				add_rt_dup_extent(rt_start, rt_len);
				rt_start = 0;
				rt_len = 0;
			}
			break;
		case XR_E_MULT:
			if (rt_start == 0)  {
				rt_start = rtx;
				rt_len = 1;
			} else if (rt_len == XFS_MAX_BMBT_EXTLEN)  {
				/*
				 * large extent case
				 */
				add_rt_dup_extent(rt_start, rt_len);
				rt_start = rtx;
				rt_len = 1;
			} else
				rt_len++;
			break;

So I think the reason why you've never seen false duplicates is that the
rt_dup tree intervals measure rt extents, not rt blocks.  The units
conversion in process_rt_rec_dups is correct.

However, none of that is at all obvious because of the dual uses of
xfs_rtblock_t for rt blocks and rt extents.

I guess I ought to post the xfsprogs version of those rt units cleanups.
:)

--D

>  repair/dinode.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/repair/dinode.c b/repair/dinode.c
> index c10dd1fa3..9aa367138 100644
> --- a/repair/dinode.c
> +++ b/repair/dinode.c
> @@ -194,13 +194,11 @@ process_rt_rec_dups(
>  	struct xfs_bmbt_irec	*irec)
>  {
>  	xfs_fsblock_t		b;
> -	xfs_rtblock_t		ext;
>  
>  	for (b = rounddown(irec->br_startblock, mp->m_sb.sb_rextsize);
>  	     b < irec->br_startblock + irec->br_blockcount;
>  	     b += mp->m_sb.sb_rextsize) {
> -		ext = (xfs_rtblock_t) b / mp->m_sb.sb_rextsize;
> -		if (search_rt_dup_extent(mp, ext))  {
> +		if (search_rt_dup_extent(mp, b))  {
>  			do_warn(
>  _("data fork in rt ino %" PRIu64 " claims dup rt extent,"
>  "off - %" PRIu64 ", start - %" PRIu64 ", count %" PRIu64 "\n"),
> -- 
> 2.39.2
> 

  reply	other threads:[~2023-11-08 18:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08 17:53 [PATCH] repair: fix process_rt_rec_dups Christoph Hellwig
2023-11-08 18:08 ` Darrick J. Wong [this message]
2023-11-08 18:21   ` Christoph Hellwig
2023-11-08 19:20     ` Darrick J. Wong
2023-11-09  4:44       ` Christoph Hellwig

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=20231108180827.GW1205143@frogsfrogsfrogs \
    --to=djwong@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