diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-04-01 11:21:32 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:01 -0400 |
commit | 63b10fc4874a014e22bc4c64e3d92b71180661fe (patch) | |
tree | 683a7b414f269f8b999b666d5f2d6c9fb74a1ee8 /fs/btrfs/disk-io.c | |
parent | 2d2ae547979854d10b75d557b3abdb3eb7511bbc (diff) |
Reorder the flags field in struct btrfs_header and record a flag on writeout
This allows detection of blocks that have already been written in the
running transaction so they can be recowed instead of modified again.
It is step one in trusting the transid field of the block pointers.
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 | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 1c5e097a4df2..709e33d08bb5 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -159,17 +159,19 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, | |||
159 | from_this_trans = 1; | 159 | from_this_trans = 1; |
160 | 160 | ||
161 | /* FIXME, this is not good */ | 161 | /* FIXME, this is not good */ |
162 | if (from_this_trans == 0 && | 162 | if (memcmp_extent_buffer(buf, result, 0, BTRFS_CRC32_SIZE)) { |
163 | memcmp_extent_buffer(buf, result, 0, BTRFS_CRC32_SIZE)) { | ||
164 | u32 val; | 163 | u32 val; |
165 | u32 found = 0; | 164 | u32 found = 0; |
166 | memcpy(&found, result, BTRFS_CRC32_SIZE); | 165 | memcpy(&found, result, BTRFS_CRC32_SIZE); |
167 | 166 | ||
168 | read_extent_buffer(buf, &val, 0, BTRFS_CRC32_SIZE); | 167 | read_extent_buffer(buf, &val, 0, BTRFS_CRC32_SIZE); |
168 | WARN_ON(1); | ||
169 | printk("btrfs: %s checksum verify failed on %llu " | 169 | printk("btrfs: %s checksum verify failed on %llu " |
170 | "wanted %X found %X from_this_trans %d\n", | 170 | "wanted %X found %X from_this_trans %d " |
171 | "level %d\n", | ||
171 | root->fs_info->sb->s_id, | 172 | root->fs_info->sb->s_id, |
172 | buf->start, val, found, from_this_trans); | 173 | buf->start, val, found, from_this_trans, |
174 | btrfs_header_level(buf)); | ||
173 | return 1; | 175 | return 1; |
174 | } | 176 | } |
175 | } else { | 177 | } else { |
@@ -220,6 +222,9 @@ int csum_dirty_buffer(struct btrfs_root *root, struct page *page) | |||
220 | goto err; | 222 | goto err; |
221 | } | 223 | } |
222 | found_level = btrfs_header_level(eb); | 224 | found_level = btrfs_header_level(eb); |
225 | spin_lock(&root->fs_info->hash_lock); | ||
226 | btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN); | ||
227 | spin_unlock(&root->fs_info->hash_lock); | ||
223 | csum_tree_block(root, eb, 0); | 228 | csum_tree_block(root, eb, 0); |
224 | err: | 229 | err: |
225 | free_extent_buffer(eb); | 230 | free_extent_buffer(eb); |