bcachefs: use swab40 for bch_backpointer.bucket_offset bitfield
authorBrian Foster <bfoster@redhat.com>
Fri, 3 Nov 2023 13:09:38 +0000 (09:09 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 5 Nov 2023 02:19:13 +0000 (22:19 -0400)
commit7cb2a7895d94db2979c29e4a20f33b5557c702d5
treeeaa04267abb6b23145f658e0906854f748c7c91a
parent0996c72a0f300bfedf8df52a8e437435494fc204
bcachefs: use swab40 for bch_backpointer.bucket_offset bitfield

The bucket_offset field of bch_backpointer is a 40-bit bitfield, but the
bch2_backpointer_swab() helper uses swab32. This leads to inconsistency
when an on-disk fs is accessed from an opposite endian machine.

As it turns out, we already have an internal swab40() helper that is
used from the bch_alloc_v4 swab callback. Lift it into the backpointers
header file and use it consistently in both places.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/backpointers.c
fs/bcachefs/backpointers.h