aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2012-03-01 08:56:27 -0500
committerDavid Sterba <dsterba@suse.cz>2012-03-21 20:45:31 -0400
commitd5c13f927fe77b11a67f79559808c68b26474c77 (patch)
tree4725c8b83309fa8431fea85bf9acc99b8e015291 /fs/btrfs/disk-io.c
parentd16cb050e5b1c3a9d754fed7098eefb8237877d1 (diff)
btrfs: clean_tree_block should panic on observed memory corruption and return void
The only error condition in clean_tree_block is an accounting bug. Returning without modifying dirty_metadata_bytes and as if the cleaning as been performed may cause problems later so it should panic instead. It should probably be a BUG_ON but we have btrfs_panic now. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 534266fe505f..d52ec1155204 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1109,8 +1109,8 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
1109 1109
1110} 1110}
1111 1111
1112int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, 1112void clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1113 struct extent_buffer *buf) 1113 struct extent_buffer *buf)
1114{ 1114{
1115 struct inode *btree_inode = root->fs_info->btree_inode; 1115 struct inode *btree_inode = root->fs_info->btree_inode;
1116 if (btrfs_header_generation(buf) == 1116 if (btrfs_header_generation(buf) ==
@@ -1121,8 +1121,14 @@ int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1121 spin_lock(&root->fs_info->delalloc_lock); 1121 spin_lock(&root->fs_info->delalloc_lock);
1122 if (root->fs_info->dirty_metadata_bytes >= buf->len) 1122 if (root->fs_info->dirty_metadata_bytes >= buf->len)
1123 root->fs_info->dirty_metadata_bytes -= buf->len; 1123 root->fs_info->dirty_metadata_bytes -= buf->len;
1124 else 1124 else {
1125 WARN_ON(1); 1125 spin_unlock(&root->fs_info->delalloc_lock);
1126 btrfs_panic(root->fs_info, -EOVERFLOW,
1127 "Can't clear %lu bytes from "
1128 " dirty_mdatadata_bytes (%lu)",
1129 buf->len,
1130 root->fs_info->dirty_metadata_bytes);
1131 }
1126 spin_unlock(&root->fs_info->delalloc_lock); 1132 spin_unlock(&root->fs_info->delalloc_lock);
1127 } 1133 }
1128 1134
@@ -1131,7 +1137,6 @@ int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1131 clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, 1137 clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree,
1132 buf); 1138 buf);
1133 } 1139 }
1134 return 0;
1135} 1140}
1136 1141
1137static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, 1142static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,