summaryrefslogtreecommitdiff
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:22:25 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:57 -0400
commitff79f8190b6e955ff7a71faf804a3017d526e657 (patch)
treed3f56ae2822eb312eba760dcf4df1a058de5a699 /fs/btrfs/inode.c
parentcf786e79e3f96f4bc037c69e1a7afb5fb85c6111 (diff)
downloadlwn-ff79f8190b6e955ff7a71faf804a3017d526e657.tar.gz
lwn-ff79f8190b6e955ff7a71faf804a3017d526e657.zip
Btrfs: Add back file data checksumming
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 80f84b48a70f..ac69f6926afc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -135,7 +135,7 @@ int btrfs_readpage_io_hook(struct page *page, u64 start, u64 end)
struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
struct btrfs_csum_item *item;
struct btrfs_path *path = NULL;
- u64 private;
+ u32 csum;
mutex_lock(&root->fs_info->fs_mutex);
path = btrfs_alloc_path();
@@ -145,11 +145,12 @@ int btrfs_readpage_io_hook(struct page *page, u64 start, u64 end)
/* a csum that isn't present is a preallocated region. */
if (ret == -ENOENT || ret == -EFBIG)
ret = 0;
- private = 0;
+ csum = 0;
goto out;
}
- memcpy((char *)&private, &item->csum, BTRFS_CRC32_SIZE);
- set_state_private(em_tree, start, private);
+ read_extent_buffer(path->nodes[0], &csum, (unsigned long)item,
+ BTRFS_CRC32_SIZE);
+ set_state_private(em_tree, start, csum);
out:
if (path)
btrfs_free_path(path);
@@ -165,21 +166,19 @@ int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end)
char *kaddr;
u64 private;
int ret;
+ struct btrfs_root *root = BTRFS_I(inode)->root;
+ u32 csum = ~(u32)0;
ret = get_state_private(em_tree, start, &private);
kaddr = kmap_atomic(page, KM_IRQ0);
if (ret) {
goto zeroit;
}
- /*
- struct btrfs_root *root = BTRFS_I(inode)->root;
- char csum[BTRFS_CRC32_SIZE];
- ret = btrfs_csum_data(root, kaddr + offset, end - start + 1, csum);
- BUG_ON(ret);
- if (memcmp(csum, &private, BTRFS_CRC32_SIZE)) {
+ csum = btrfs_csum_data(root, kaddr + offset, csum, end - start + 1);
+ btrfs_csum_final(csum, (char *)&csum);
+ if (csum != private) {
goto zeroit;
}
- */
kunmap_atomic(kaddr, KM_IRQ0);
return 0;