提交 34b3e6c9 编写于 作者: F Feifei Xu 提交者: David Sterba

Btrfs: self-tests: Fix extent buffer bitmap test fail on BE system

In __test_eb_bitmaps(), we write random data to a bitmap. Then copy
the bitmap to another bitmap that resides inside an extent buffer.
Later we verify the values of corresponding bits in the bitmap and the
bitmap inside the extent buffer. However, extent_buffer_test_bit()
reads in byte granularity while test_bit() reads in unsigned long
granularity. Hence we end up comparing wrong bits on big-endian
systems such as ppc64. This commit fixes the issue by reading the
bitmap in byte granularity.
Reviewed-by: NJosef Bacik <jbacik@fb.com>
Reviewed-by: NChandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: NFeifei Xu <xufeifei@linux.vnet.ibm.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 36b3dc05
...@@ -273,6 +273,16 @@ static int test_find_delalloc(u32 sectorsize) ...@@ -273,6 +273,16 @@ static int test_find_delalloc(u32 sectorsize)
return ret; return ret;
} }
/**
* test_bit_in_byte - Determine whether a bit is set in a byte
* @nr: bit number to test
* @addr: Address to start counting from
*/
static inline int test_bit_in_byte(int nr, const u8 *addr)
{
return 1UL & (addr[nr / BITS_PER_BYTE] >> (nr & (BITS_PER_BYTE - 1)));
}
static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb, static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
unsigned long len) unsigned long len)
{ {
...@@ -338,7 +348,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb, ...@@ -338,7 +348,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
for (i = 0; i < len * BITS_PER_BYTE; i++) { for (i = 0; i < len * BITS_PER_BYTE; i++) {
int bit, bit1; int bit, bit1;
bit = !!test_bit(i, bitmap); bit = !!test_bit_in_byte(i, (u8 *)bitmap);
bit1 = !!extent_buffer_test_bit(eb, 0, i); bit1 = !!extent_buffer_test_bit(eb, 0, i);
if (bit1 != bit) { if (bit1 != bit) {
test_msg("Testing bit pattern failed\n"); test_msg("Testing bit pattern failed\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册