diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-30 14:27:56 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-30 14:27:56 -0400 |
commit | d6025579531b7ea170ba283b171ff7a6bf7d0e12 (patch) | |
tree | c3b742fda3a6ac8541c06011bb3c26635db99212 /fs/btrfs/disk-io.c | |
parent | 22b0ebda6c63a1ad66b6a9e806bd226a4a03a049 (diff) |
Btrfs: corruption hunt continues
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 6c010463b9db..bb133104e2e9 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -8,6 +8,17 @@ | |||
8 | #include "disk-io.h" | 8 | #include "disk-io.h" |
9 | #include "transaction.h" | 9 | #include "transaction.h" |
10 | 10 | ||
11 | #define PATTERN 0xDEADBEEFUL | ||
12 | static inline void check_pattern(struct buffer_head *buf) | ||
13 | { | ||
14 | if (buf->b_private != (void *)PATTERN) | ||
15 | WARN_ON(1); | ||
16 | } | ||
17 | |||
18 | static inline void set_pattern(struct buffer_head *buf) | ||
19 | { | ||
20 | buf->b_private = (void *)PATTERN; | ||
21 | } | ||
11 | 22 | ||
12 | static int check_tree_block(struct btrfs_root *root, struct buffer_head *buf) | 23 | static int check_tree_block(struct btrfs_root *root, struct buffer_head *buf) |
13 | { | 24 | { |
@@ -51,8 +62,10 @@ struct buffer_head *btrfs_find_tree_block(struct btrfs_root *root, u64 blocknr) | |||
51 | } while (bh != head); | 62 | } while (bh != head); |
52 | out_unlock: | 63 | out_unlock: |
53 | unlock_page(page); | 64 | unlock_page(page); |
54 | if (ret) | 65 | if (ret) { |
55 | touch_buffer(ret); | 66 | touch_buffer(ret); |
67 | check_pattern(ret); | ||
68 | } | ||
56 | page_cache_release(page); | 69 | page_cache_release(page); |
57 | return ret; | 70 | return ret; |
58 | } | 71 | } |
@@ -82,6 +95,7 @@ struct buffer_head *btrfs_find_create_tree_block(struct btrfs_root *root, | |||
82 | bh->b_bdev = root->fs_info->sb->s_bdev; | 95 | bh->b_bdev = root->fs_info->sb->s_bdev; |
83 | bh->b_blocknr = first_block; | 96 | bh->b_blocknr = first_block; |
84 | set_buffer_mapped(bh); | 97 | set_buffer_mapped(bh); |
98 | set_pattern(bh); | ||
85 | } | 99 | } |
86 | if (bh->b_blocknr == blocknr) { | 100 | if (bh->b_blocknr == blocknr) { |
87 | ret = bh; | 101 | ret = bh; |
@@ -225,6 +239,7 @@ struct buffer_head *read_tree_block(struct btrfs_root *root, u64 blocknr) | |||
225 | if (!buffer_uptodate(bh)) | 239 | if (!buffer_uptodate(bh)) |
226 | goto fail; | 240 | goto fail; |
227 | csum_tree_block(root, bh, 1); | 241 | csum_tree_block(root, bh, 1); |
242 | set_pattern(bh); | ||
228 | } else { | 243 | } else { |
229 | unlock_buffer(bh); | 244 | unlock_buffer(bh); |
230 | } | 245 | } |
@@ -240,6 +255,7 @@ fail: | |||
240 | int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 255 | int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
241 | struct buffer_head *buf) | 256 | struct buffer_head *buf) |
242 | { | 257 | { |
258 | WARN_ON(atomic_read(&buf->b_count) == 0); | ||
243 | mark_buffer_dirty(buf); | 259 | mark_buffer_dirty(buf); |
244 | return 0; | 260 | return 0; |
245 | } | 261 | } |
@@ -247,6 +263,7 @@ int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
247 | int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 263 | int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
248 | struct buffer_head *buf) | 264 | struct buffer_head *buf) |
249 | { | 265 | { |
266 | WARN_ON(atomic_read(&buf->b_count) == 0); | ||
250 | clear_buffer_dirty(buf); | 267 | clear_buffer_dirty(buf); |
251 | return 0; | 268 | return 0; |
252 | } | 269 | } |
@@ -431,6 +448,7 @@ int close_ctree(struct btrfs_root *root) | |||
431 | 448 | ||
432 | void btrfs_block_release(struct btrfs_root *root, struct buffer_head *buf) | 449 | void btrfs_block_release(struct btrfs_root *root, struct buffer_head *buf) |
433 | { | 450 | { |
451 | check_pattern(buf); | ||
434 | brelse(buf); | 452 | brelse(buf); |
435 | } | 453 | } |
436 | 454 | ||