aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file-item.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/file-item.c
parentcf786e79e3f96f4bc037c69e1a7afb5fb85c6111 (diff)
Btrfs: Add back file data checksumming
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file-item.c')
-rw-r--r--fs/btrfs/file-item.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 9a65e97a4e28..10a4c7408600 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -136,27 +136,27 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
136 u64 objectid, u64 offset, 136 u64 objectid, u64 offset,
137 char *data, size_t len) 137 char *data, size_t len)
138{ 138{
139 return 0;
140#if 0
141 int ret; 139 int ret;
142 struct btrfs_key file_key; 140 struct btrfs_key file_key;
143 struct btrfs_key found_key; 141 struct btrfs_key found_key;
144 struct btrfs_path *path; 142 struct btrfs_path *path;
145 struct btrfs_csum_item *item; 143 struct btrfs_csum_item *item;
146 struct extent_buffer *leaf; 144 struct extent_buffer *leaf = NULL;
147 u64 csum_offset; 145 u64 csum_offset;
146 u32 csum_result = ~(u32)0;
148 147
149 path = btrfs_alloc_path(); 148 path = btrfs_alloc_path();
150 BUG_ON(!path); 149 BUG_ON(!path);
151 150
152 file_key.objectid = objectid; 151 file_key.objectid = objectid;
153 file_key.offset = offset; 152 file_key.offset = offset;
154 file_key.flags = 0;
155 btrfs_set_key_type(&file_key, BTRFS_CSUM_ITEM_KEY); 153 btrfs_set_key_type(&file_key, BTRFS_CSUM_ITEM_KEY);
156 154
157 item = btrfs_lookup_csum(trans, root, path, objectid, offset, 1); 155 item = btrfs_lookup_csum(trans, root, path, objectid, offset, 1);
158 if (!IS_ERR(item)) 156 if (!IS_ERR(item)) {
157 leaf = path->nodes[0];
159 goto found; 158 goto found;
159 }
160 ret = PTR_ERR(item); 160 ret = PTR_ERR(item);
161 if (ret == -EFBIG) { 161 if (ret == -EFBIG) {
162 u32 item_size; 162 u32 item_size;
@@ -226,14 +226,15 @@ csum:
226 item = (struct btrfs_csum_item *)((unsigned char *)item + 226 item = (struct btrfs_csum_item *)((unsigned char *)item +
227 csum_offset * BTRFS_CRC32_SIZE); 227 csum_offset * BTRFS_CRC32_SIZE);
228found: 228found:
229 /* FIXME!!!!!!!!!!!! */ 229 csum_result = btrfs_csum_data(root, data, csum_result, len);
230 ret = btrfs_csum_data(root, data, len, &item->csum); 230 btrfs_csum_final(csum_result, (char *)&csum_result);
231 write_extent_buffer(leaf, &csum_result, (unsigned long)item,
232 BTRFS_CRC32_SIZE);
231 btrfs_mark_buffer_dirty(path->nodes[0]); 233 btrfs_mark_buffer_dirty(path->nodes[0]);
232fail: 234fail:
233 btrfs_release_path(root, path); 235 btrfs_release_path(root, path);
234 btrfs_free_path(path); 236 btrfs_free_path(path);
235 return ret; 237 return ret;
236#endif
237} 238}
238 239
239int btrfs_csum_truncate(struct btrfs_trans_handle *trans, 240int btrfs_csum_truncate(struct btrfs_trans_handle *trans,