diff options
Diffstat (limited to 'fs/btrfs/check-integrity.c')
-rw-r--r-- | fs/btrfs/check-integrity.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index b0c8094528d1..81a9731959a9 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c | |||
@@ -83,7 +83,7 @@ | |||
83 | #include <linux/blkdev.h> | 83 | #include <linux/blkdev.h> |
84 | #include <linux/mm.h> | 84 | #include <linux/mm.h> |
85 | #include <linux/string.h> | 85 | #include <linux/string.h> |
86 | #include <linux/crc32c.h> | 86 | #include <crypto/hash.h> |
87 | #include "ctree.h" | 87 | #include "ctree.h" |
88 | #include "disk-io.h" | 88 | #include "disk-io.h" |
89 | #include "transaction.h" | 89 | #include "transaction.h" |
@@ -1710,9 +1710,9 @@ static int btrfsic_test_for_metadata(struct btrfsic_state *state, | |||
1710 | char **datav, unsigned int num_pages) | 1710 | char **datav, unsigned int num_pages) |
1711 | { | 1711 | { |
1712 | struct btrfs_fs_info *fs_info = state->fs_info; | 1712 | struct btrfs_fs_info *fs_info = state->fs_info; |
1713 | SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); | ||
1713 | struct btrfs_header *h; | 1714 | struct btrfs_header *h; |
1714 | u8 csum[BTRFS_CSUM_SIZE]; | 1715 | u8 csum[BTRFS_CSUM_SIZE]; |
1715 | u32 crc = ~(u32)0; | ||
1716 | unsigned int i; | 1716 | unsigned int i; |
1717 | 1717 | ||
1718 | if (num_pages * PAGE_SIZE < state->metablock_size) | 1718 | if (num_pages * PAGE_SIZE < state->metablock_size) |
@@ -1723,14 +1723,17 @@ static int btrfsic_test_for_metadata(struct btrfsic_state *state, | |||
1723 | if (memcmp(h->fsid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE)) | 1723 | if (memcmp(h->fsid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE)) |
1724 | return 1; | 1724 | return 1; |
1725 | 1725 | ||
1726 | shash->tfm = fs_info->csum_shash; | ||
1727 | crypto_shash_init(shash); | ||
1728 | |||
1726 | for (i = 0; i < num_pages; i++) { | 1729 | for (i = 0; i < num_pages; i++) { |
1727 | u8 *data = i ? datav[i] : (datav[i] + BTRFS_CSUM_SIZE); | 1730 | u8 *data = i ? datav[i] : (datav[i] + BTRFS_CSUM_SIZE); |
1728 | size_t sublen = i ? PAGE_SIZE : | 1731 | size_t sublen = i ? PAGE_SIZE : |
1729 | (PAGE_SIZE - BTRFS_CSUM_SIZE); | 1732 | (PAGE_SIZE - BTRFS_CSUM_SIZE); |
1730 | 1733 | ||
1731 | crc = crc32c(crc, data, sublen); | 1734 | crypto_shash_update(shash, data, sublen); |
1732 | } | 1735 | } |
1733 | btrfs_csum_final(crc, csum); | 1736 | crypto_shash_final(shash, csum); |
1734 | if (memcmp(csum, h->csum, state->csum_size)) | 1737 | if (memcmp(csum, h->csum, state->csum_size)) |
1735 | return 1; | 1738 | return 1; |
1736 | 1739 | ||