diff options
author | Omar Sandoval <osandov@fb.com> | 2016-07-15 12:12:48 -0700 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-07-26 18:35:05 +0200 |
commit | 1d6c7cb725bb7d25981d44915b316e24751b7b72 (patch) | |
tree | 7199982cc55d2a8631191bcd98ac9cbabd54f3b9 /extent_io.h | |
parent | 029772be1152bbdf921ee74b95cfcde4003f5e46 (diff) |
btrfs-progs: fix btrfsck of space_cache=v2 bitmaps on big-endian
Copy le_test_bit() from the kernel and use that for the free space tree
bitmaps.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'extent_io.h')
-rw-r--r-- | extent_io.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/extent_io.h b/extent_io.h index a9a73535..94a42bf5 100644 --- a/extent_io.h +++ b/extent_io.h @@ -49,6 +49,25 @@ #define BLOCK_GROUP_DIRTY EXTENT_DIRTY +/* + * The extent buffer bitmap operations are done with byte granularity instead of + * word granularity for two reasons: + * 1. The bitmaps must be little-endian on disk. + * 2. Bitmap items are not guaranteed to be aligned to a word and therefore a + * single word in a bitmap may straddle two pages in the extent buffer. + */ +#define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE) +#define BYTE_MASK ((1 << BITS_PER_BYTE) - 1) +#define BITMAP_FIRST_BYTE_MASK(start) \ + ((BYTE_MASK << ((start) & (BITS_PER_BYTE - 1))) & BYTE_MASK) +#define BITMAP_LAST_BYTE_MASK(nbits) \ + (BYTE_MASK >> (-(nbits) & (BITS_PER_BYTE - 1))) + +static inline int le_test_bit(int nr, const u8 *addr) +{ + return 1U & (addr[BIT_BYTE(nr)] >> (nr & (BITS_PER_BYTE-1))); +} + struct btrfs_fs_info; struct extent_io_tree { |