diff options
author | Miguel <miguel.filipe@gmail.com> | 2008-04-11 15:45:51 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:01 -0400 |
commit | a5eb62e345fc1818d0d8b6181463200a9e8dfe39 (patch) | |
tree | 2e67b0628c8312d941f52edadc6c49bd8ac4c914 /fs/btrfs/crc32c.h | |
parent | 587f77043a1c86e2a7900ff2ce86bef3c1f4e075 (diff) |
Btrfs: Endianess bug fix for v0.13 with kernels
Fix for a endianess BUG when using btrfs v0.13 with kernels older than 2.6.23
Problem:
Has of v0.13, btrfs-progs is using crc32c.c equivalent to the one found on
linux-2.6.23/lib/libcrc32c.c Since crc32c_le() changed in linux-2.6.23, when
running btrfs v0.13 with older kernels we have a missmatch between the versions
of crc32c_le() from btrfs-progs and libcrc32c in the kernel. This missmatch
causes a bug when using btrfs on big endian machines.
Solution:
btrfs_crc32c() macro that when compiling for kernels older than 2.6.23, does
endianess conversion to parameters and return value of crc32c().
This endianess conversion nullifies the differences in implementation
of crc32c_le().
If kernel 2.6.23 or better, it calls crc32c().
Signed-off-by: Miguel Sousa Filipe <miguel.filipe@gmail.com>
---
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/crc32c.h')
-rw-r--r-- | fs/btrfs/crc32c.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/btrfs/crc32c.h b/fs/btrfs/crc32c.h new file mode 100644 index 000000000000..a93255b4ee27 --- /dev/null +++ b/fs/btrfs/crc32c.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #include <asm/byteorder.h> | ||
2 | #include <linux/crc32c.h> | ||
3 | #include <linux/version.h> | ||
4 | |||
5 | /** | ||
6 | * implementation of crc32c_le() changed in linux-2.6.23, | ||
7 | * has of v0.13 btrfs-progs is using the latest version. | ||
8 | * We must workaround older implementations of crc32c_le() | ||
9 | * found on older kernel versions. | ||
10 | */ | ||
11 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) | ||
12 | #define btrfs_crc32c(seed, data, length) \ | ||
13 | __cpu_to_le32( crc32c( __le32_to_cpu(seed), data, length) ) | ||
14 | #else | ||
15 | #define btrfs_crc32c(seed, data, length) \ | ||
16 | crc32c(seed, data, length) | ||
17 | #endif | ||