xfs: ensure extents are read as be64
The debug code reads the extents in cpu-order rather than BE. Make the debug code match.
---
Possibly 2.6.25 material....if it actually is a bug. See elsewhere in the same file that reads as be64. (look for ep->l0).
fs/xfs/xfs_inode.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode.c +2 -2
@@ -85,8 +85,8 @@ xfs_validate_extents(for (i =0 ; i < nrecs; i++) {xfs_bmbt_rec_host_t *ep =xfs_iext_get_ext (ifp, i); - rec.l0 =get_unaligned (&ep->l0); - rec.l1 =get_unaligned (&ep->l1); + rec.l0 =be64_to_cpu (get_unaligned (&ep->l0)); + rec.l1 =be64_to_cpu (get_unaligned (&ep->l1));xfs_bmbt_get_all (&rec, &irec);if (fmt ==XFS_EXTFMT_NOSTATE )ASSERT (irec.br_state ==XFS_EXT_NORM );
Signature · 1 line
1.5.5.144.g3e42
Quoted 2 lines · Harvey Harrison
The debug code reads the extents in cpu-order rather than BE. Make the debug code match.
xfs_validate_extents() is reading in-core extents which have already been byte-swapped when they were read into memory.
FWIW, when changing anything to do with endian conversion, please ensure you run:
$ make C=2 CHECKFLAGS="-D__CHECK_ENDIAN__"
over the change. This change would introduce errors because:
typedef struct xfs_bmbt_rec_host {
__uint64_t l0, l1;
} xfs_bmbt_rec_host_t;is not defined with __beXX types like the disk format version of this structure which is:
typedef struct xfs_bmbt_rec_64 {
__be64 l0, l1;
} xfs_bmbt_rec_64_t;Cheers,
Dave.
Signature · 3 lines
Dave Chinner Principal Engineer SGI Australian Software Group
Quoted 18 lines · David Chinner
Quoted 2 lines · Harvey Harrison
The debug code reads the extents in cpu-order rather than BE. Make the debug code match.
xfs_validate_extents()is reading in-core extents which have already been byte-swapped when they were read into memory.FWIW, when changing anything to do with endian conversion, please ensure you run:
$ make C=2 CHECKFLAGS="-D__CHECK_ENDIAN__"over the change. This change would introduce errors because:
typedef struct xfs_bmbt_rec_host { __uint64_t l0, l1; } xfs_bmbt_rec_host_t;
Quoted 7 lines
is not defined with
__beXXtypes like the disk format version of this structure which is:typedef struct xfs_bmbt_rec_64 { __be64 l0, l1; } xfs_bmbt_rec_64_t;
Sorry for the noise, I didn't notice the (slightly) different struct types. Just the very similar looking blocks in both functions.
My Bad,
Harvey