From: Dave Chinner <dgc@kernel.org>
To: Stian Halseth <stian@itx.no>
Cc: Carlos Maiolino <cem@kernel.org>,
linux-xfs@vger.kernel.org, "Darrick J . Wong" <djwong@kernel.org>,
sparclinux@vger.kernel.org, Jan Engelhardt <jengelh@inai.de>,
stable@vger.kernel.org
Subject: Re: [PATCH] xfs: read rmapbt high key offsets with get_unaligned() in scrub
Date: Wed, 11 Nov 2026 07:28:35 +1100 [thread overview]
Message-ID: <avN-c2otlYfqEQ--@dread> (raw)
In-Reply-To: <a69cd8605f2011f348c895a8d892463879f76823.camel@itx.no>
On Tue, Nov 10, 2026 at 09:33:46AM +0100, Stian Halseth wrote:
> Hi Dave,
>
> On Tue, 2026-11-10 at 08:40 +1100, Dave Chinner wrote:
> >
> > That just looks wrong to begin with. Decoding an on-disk structure
> > without using be64_to_cpu() to get it in the correct endian order
> > first?
> >
> > Oh... the code plays "I'm too smart for my own good" micro-
> > optimisation games by endian swapping the badflag variable to avoid
> > needing to endian swap the rm_offset field.
> >
> > It seems to me that the correct fix here is to stop endian swapping
> > the badflag variable, and endian swap the rmap.rm_offset fetches for
> > both the low key and high keys, like all the other places that
> > dereference rmap.rm_offset direct from pointers returned by
> > xfs_btree_key_addr()/xfs_btree_high_key_addr().
> >
>
> Thanks, I've looked a bit deeper than my one-line fix, based on your
> feedback.
>
> Yes, we can remove badflag. be64_to_cpu() alone doesn't fix the
> trap, though, since it's a no-op on big-endian. gcc still reads
> hkey->rmap.rm_offset with the same 8-byte ldx. I tried it on my
> T4-1 and the fault count didn't change.
>
> The other places get away with it because they go through a
> struct xfs_rmap_key pointer first (kp = &key->rmap in
> xfs_rmapbt_cmp_key_with_cur() and xfs_rmapbt_cmp_two_keys()), and since
> that struct is packed gcc uses byte loads.
Ah, that explains why those work without issue - that's the bit I
missed.
> I suggest we do the the same here, with be64_to_cpu() and no badflag.
> That gets the faults to zero on the T4-1. Can send that as a v2 later,
> if no one disagree with that approach.
It sounds like the right approach to me.
-Dave.
--
Dave Chinner
dgc@kernel.org
prev parent reply other threads:[~2026-11-10 20:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 13:48 [PATCH] xfs: read rmapbt high key offsets with get_unaligned() in scrub Stian Halseth
2026-11-09 21:40 ` Dave Chinner
2026-11-10 8:33 ` Stian Halseth
2026-11-10 20:28 ` Dave Chinner [this message]
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=avN-c2otlYfqEQ--@dread \
--to=dgc@kernel.org \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=jengelh@inai.de \
--cc=linux-xfs@vger.kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stian@itx.no \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.