Skip to content

Commit 0996c72

Browse files
Brian FosterKent Overstreet
authored andcommitted
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 <bfoster@redhat.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 2a4e749 commit 0996c72

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/bcachefs/alloc_background.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ void bch2_alloc_v4_swab(struct bkey_s k)
319319
a->io_time[1] = swab64(a->io_time[1]);
320320
a->stripe = swab32(a->stripe);
321321
a->nr_external_backpointers = swab32(a->nr_external_backpointers);
322+
a->fragmentation_lru = swab64(a->fragmentation_lru);
322323

323324
bps = alloc_v4_backpointers(a);
324325
for (bp = bps; bp < bps + BCH_ALLOC_V4_NR_BACKPOINTERS(a); bp++) {

0 commit comments

Comments
 (0)