aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-08 15:46:27 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:59 -0400
commite4204dedbbaa3a614605cb83cc0ac5161af6b4e6 (patch)
treefbff50ade7beca66eb8652b81045c3e44091cc6a
parent725c8463ea9bcfc2b56cff09b93a90e5bcca59c4 (diff)
Btrfs: Change tree block csum tagging to avoid false error messages
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/disk-io.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 67d9fd728868..a6170ff19e7f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -145,10 +145,25 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
145 btrfs_csum_final(crc, result); 145 btrfs_csum_final(crc, result);
146 146
147 if (verify) { 147 if (verify) {
148 if (memcmp_extent_buffer(buf, result, 0, BTRFS_CRC32_SIZE)) { 148 int from_this_trans = 0;
149 printk("btrfs: %s checksum verify failed on %llu\n", 149
150 if (root->fs_info->running_transaction &&
151 btrfs_header_generation(buf) ==
152 root->fs_info->running_transaction->transid)
153 from_this_trans = 1;
154
155 /* FIXME, this is not good */
156 if (from_this_trans == 0 &&
157 memcmp_extent_buffer(buf, result, 0, BTRFS_CRC32_SIZE)) {
158 u32 val;
159 u32 found = 0;
160 memcpy(&found, result, BTRFS_CRC32_SIZE);
161
162 read_extent_buffer(buf, &val, 0, BTRFS_CRC32_SIZE);
163 printk("btrfs: %s checksum verify failed on %llu "
164 "wanted %X found %X from_this_trans %d\n",
150 root->fs_info->sb->s_id, 165 root->fs_info->sb->s_id,
151 buf->start); 166 buf->start, val, found, from_this_trans);
152 return 1; 167 return 1;
153 } 168 }
154 } else { 169 } else {
@@ -313,6 +328,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
313 struct extent_buffer *buf = NULL; 328 struct extent_buffer *buf = NULL;
314 struct inode *btree_inode = root->fs_info->btree_inode; 329 struct inode *btree_inode = root->fs_info->btree_inode;
315 struct extent_map_tree *extent_tree; 330 struct extent_map_tree *extent_tree;
331 u64 end;
316 int ret; 332 int ret;
317 333
318 extent_tree = &BTRFS_I(btree_inode)->extent_tree; 334 extent_tree = &BTRFS_I(btree_inode)->extent_tree;
@@ -322,19 +338,29 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
322 return NULL; 338 return NULL;
323 read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree, 339 read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree,
324 buf, 0, 1); 340 buf, 0, 1);
325 if (buf->flags & EXTENT_CSUM) { 341
342 if (buf->flags & EXTENT_CSUM)
326 return buf; 343 return buf;
327 } 344
328 if (test_range_bit(extent_tree, buf->start, buf->start + buf->len - 1, 345 end = buf->start + PAGE_CACHE_SIZE - 1;
329 EXTENT_CSUM, 1)) { 346 if (test_range_bit(extent_tree, buf->start, end, EXTENT_CSUM, 1)) {
330 buf->flags |= EXTENT_CSUM; 347 buf->flags |= EXTENT_CSUM;
331 return buf; 348 return buf;
332 } 349 }
350
351 lock_extent(extent_tree, buf->start, end, GFP_NOFS);
352
353 if (test_range_bit(extent_tree, buf->start, end, EXTENT_CSUM, 1)) {
354 buf->flags |= EXTENT_CSUM;
355 goto out_unlock;
356 }
357
333 ret = csum_tree_block(root, buf, 1); 358 ret = csum_tree_block(root, buf, 1);
334 set_extent_bits(extent_tree, buf->start, 359 set_extent_bits(extent_tree, buf->start, end, EXTENT_CSUM, GFP_NOFS);
335 buf->start + buf->len - 1,
336 EXTENT_CSUM, GFP_NOFS);
337 buf->flags |= EXTENT_CSUM; 360 buf->flags |= EXTENT_CSUM;
361
362out_unlock:
363 unlock_extent(extent_tree, buf->start, end, GFP_NOFS);
338 return buf; 364 return buf;
339} 365}
340 366