From 0996c72a0f300bfedf8df52a8e437435494fc204 Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Fri, 3 Nov 2023 09:09:37 -0400 Subject: bcachefs: byte order swap bch_alloc_v4.fragmentation_lru field A simple test to populate a filesystem on one CPU architecture and fsck on an arch of the opposite byte order produces errors related to the fragmentation LRU. This occurs because the 64-bit fragmentation_lru field is not byte-order swapped when reads detect that the on-disk/bset key values were written in opposite byte-order of the current CPU. Update the bch2_alloc_v4 swab callback to handle fragmentation_lru as is done for other multi-byte fields. This doesn't affect existing filesystems when accessed by CPUs of the same endianness because the ->swab() callback is only called when the bset flags indicate an endianness mismatch between the CPU and on-disk data. Signed-off-by: Brian Foster Signed-off-by: Kent Overstreet --- fs/bcachefs/alloc_background.c | 1 + 1 file changed, 1 insertion(+) (limited to 'fs/bcachefs/alloc_background.c') diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index bcfae91667af..ad256a88cb5c 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -319,6 +319,7 @@ void bch2_alloc_v4_swab(struct bkey_s k) a->io_time[1] = swab64(a->io_time[1]); a->stripe = swab32(a->stripe); a->nr_external_backpointers = swab32(a->nr_external_backpointers); + a->fragmentation_lru = swab64(a->fragmentation_lru); bps = alloc_v4_backpointers(a); for (bp = bps; bp < bps + BCH_ALLOC_V4_NR_BACKPOINTERS(a); bp++) { -- cgit v1.2.3