aboutsummaryrefslogtreecommitdiffstats
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)
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)
135 struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; 135 struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
136 struct btrfs_csum_item *item; 136 struct btrfs_csum_item *item;
137 struct btrfs_path *path = NULL; 137 struct btrfs_path *path = NULL;
138 u64 private; 138 u32 csum;
139 139
140 mutex_lock(&root->fs_info->fs_mutex); 140 mutex_lock(&root->fs_info->fs_mutex);
141 path = btrfs_alloc_path(); 141 path = btrfs_alloc_path();
@@ -145,11 +145,12 @@ int btrfs_readpage_io_hook(struct page *page, u64 start, u64 end)
145 /* a csum that isn't present is a preallocated region. */ 145 /* a csum that isn't present is a preallocated region. */
146 if (ret == -ENOENT || ret == -EFBIG) 146 if (ret == -ENOENT || ret == -EFBIG)
147 ret = 0; 147 ret = 0;
148 private = 0; 148 csum = 0;
149 goto out; 149 goto out;
150 } 150 }
151 memcpy((char *)&private, &item->csum, BTRFS_CRC32_SIZE); 151 read_extent_buffer(path->nodes[0], &csum, (unsigned long)item,
152 set_state_private(em_tree, start, private); 152 BTRFS_CRC32_SIZE);
153 set_state_private(em_tree, start, csum);
153out: 154out:
154 if (path) 155 if (path)
155 btrfs_free_path(path); 156 btrfs_free_path(path);
@@ -165,21 +166,19 @@ int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end)
165 char *kaddr; 166 char *kaddr;
166 u64 private; 167 u64 private;
167 int ret; 168 int ret;
169 struct btrfs_root *root = BTRFS_I(inode)->root;
170 u32 csum = ~(u32)0;
168 171
169 ret = get_state_private(em_tree, start, &private); 172 ret = get_state_private(em_tree, start, &private);
170 kaddr = kmap_atomic(page, KM_IRQ0); 173 kaddr = kmap_atomic(page, KM_IRQ0);
171 if (ret) { 174 if (ret) {
172 goto zeroit; 175 goto zeroit;
173 } 176 }
174 /* 177 csum = btrfs_csum_data(root, kaddr + offset, csum, end - start + 1);
175 struct btrfs_root *root = BTRFS_I(inode)->root; 178 btrfs_csum_final(csum, (char *)&csum);
176 char csum[BTRFS_CRC32_SIZE]; 179 if (csum != private) {
177 ret = btrfs_csum_data(root, kaddr + offset, end - start + 1, csum);
178 BUG_ON(ret);
179 if (memcmp(csum, &private, BTRFS_CRC32_SIZE)) {
180 goto zeroit; 180 goto zeroit;
181 } 181 }
182 */
183 kunmap_atomic(kaddr, KM_IRQ0); 182 kunmap_atomic(kaddr, KM_IRQ0);
184 return 0; 183 return 0;
185 184