diff options
author | Chris Mason <clm@fb.com> | 2016-10-12 13:16:00 -0700 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-10-12 13:16:00 -0700 |
commit | d9ed71e5457c8c5bf1dc706e06468eab9e2aa87e (patch) | |
tree | ddc02c4207fc2c828ea4612d45f4af32d5dc292f /fs/btrfs/extent_io.h | |
parent | 19c4d2f994788a954af1aa7e53b0fdb46fd7925a (diff) | |
parent | 0e6757859efea6ed919fc37e4ee468634220b2d2 (diff) | |
download | linux-stable-d9ed71e5457c8c5bf1dc706e06468eab9e2aa87e.tar.gz linux-stable-d9ed71e5457c8c5bf1dc706e06468eab9e2aa87e.tar.bz2 linux-stable-d9ed71e5457c8c5bf1dc706e06468eab9e2aa87e.zip |
Merge branch 'fst-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.9
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/extent_io.h')
-rw-r--r-- | fs/btrfs/extent_io.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 4a094f1dc7ef..ab31d145227e 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -59,6 +59,28 @@ */ #define EXTENT_PAGE_PRIVATE 1 +/* + * 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))); +} + +extern void le_bitmap_set(u8 *map, unsigned int start, int len); +extern void le_bitmap_clear(u8 *map, unsigned int start, int len); + struct extent_state; struct btrfs_root; struct btrfs_io_bio; |