diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 09eeeb4d9d28..9bc4ad38876d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -134,6 +134,8 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct | |||
134 | struct btrfs_extent_item extent_item; | 134 | struct btrfs_extent_item extent_item; |
135 | int i; | 135 | int i; |
136 | int ret; | 136 | int ret; |
137 | u64 super_blocks_used; | ||
138 | struct btrfs_fs_info *info = extent_root->fs_info; | ||
137 | 139 | ||
138 | btrfs_set_extent_refs(&extent_item, 1); | 140 | btrfs_set_extent_refs(&extent_item, 1); |
139 | btrfs_set_extent_owner(&extent_item, | 141 | btrfs_set_extent_owner(&extent_item, |
@@ -145,6 +147,9 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct | |||
145 | for (i = 0; i < extent_root->fs_info->current_insert.flags; i++) { | 147 | for (i = 0; i < extent_root->fs_info->current_insert.flags; i++) { |
146 | ins.objectid = extent_root->fs_info->current_insert.objectid + | 148 | ins.objectid = extent_root->fs_info->current_insert.objectid + |
147 | i; | 149 | i; |
150 | super_blocks_used = btrfs_super_blocks_used(info->disk_super); | ||
151 | btrfs_set_super_blocks_used(info->disk_super, | ||
152 | super_blocks_used + 1); | ||
148 | ret = btrfs_insert_item(trans, extent_root, &ins, &extent_item, | 153 | ret = btrfs_insert_item(trans, extent_root, &ins, &extent_item, |
149 | sizeof(extent_item)); | 154 | sizeof(extent_item)); |
150 | BUG_ON(ret); | 155 | BUG_ON(ret); |
@@ -161,7 +166,8 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
161 | { | 166 | { |
162 | struct btrfs_path path; | 167 | struct btrfs_path path; |
163 | struct btrfs_key key; | 168 | struct btrfs_key key; |
164 | struct btrfs_root *extent_root = root->fs_info->extent_root; | 169 | struct btrfs_fs_info *info = root->fs_info; |
170 | struct btrfs_root *extent_root = info->extent_root; | ||
165 | int ret; | 171 | int ret; |
166 | struct btrfs_extent_item *ei; | 172 | struct btrfs_extent_item *ei; |
167 | struct btrfs_key ins; | 173 | struct btrfs_key ins; |
@@ -188,15 +194,18 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
188 | refs = btrfs_extent_refs(ei) - 1; | 194 | refs = btrfs_extent_refs(ei) - 1; |
189 | btrfs_set_extent_refs(ei, refs); | 195 | btrfs_set_extent_refs(ei, refs); |
190 | if (refs == 0) { | 196 | if (refs == 0) { |
197 | u64 super_blocks_used; | ||
191 | if (pin) { | 198 | if (pin) { |
192 | int err; | 199 | int err; |
193 | radix_tree_preload(GFP_KERNEL); | 200 | radix_tree_preload(GFP_KERNEL); |
194 | err = radix_tree_insert( | 201 | err = radix_tree_insert(&info->pinned_radix, |
195 | &extent_root->fs_info->pinned_radix, | 202 | blocknr, (void *)blocknr); |
196 | blocknr, (void *)blocknr); | ||
197 | BUG_ON(err); | 203 | BUG_ON(err); |
198 | radix_tree_preload_end(); | 204 | radix_tree_preload_end(); |
199 | } | 205 | } |
206 | super_blocks_used = btrfs_super_blocks_used(info->disk_super); | ||
207 | btrfs_set_super_blocks_used(info->disk_super, | ||
208 | super_blocks_used - num_blocks); | ||
200 | ret = btrfs_del_item(trans, extent_root, &path); | 209 | ret = btrfs_del_item(trans, extent_root, &path); |
201 | if (!pin && extent_root->fs_info->last_insert.objectid > | 210 | if (!pin && extent_root->fs_info->last_insert.objectid > |
202 | blocknr) | 211 | blocknr) |
@@ -392,7 +401,9 @@ static int alloc_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
392 | { | 401 | { |
393 | int ret; | 402 | int ret; |
394 | int pending_ret; | 403 | int pending_ret; |
395 | struct btrfs_root *extent_root = root->fs_info->extent_root; | 404 | u64 super_blocks_used; |
405 | struct btrfs_fs_info *info = root->fs_info; | ||
406 | struct btrfs_root *extent_root = info->extent_root; | ||
396 | struct btrfs_extent_item extent_item; | 407 | struct btrfs_extent_item extent_item; |
397 | 408 | ||
398 | btrfs_set_extent_refs(&extent_item, 1); | 409 | btrfs_set_extent_refs(&extent_item, 1); |
@@ -413,6 +424,9 @@ static int alloc_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
413 | if (ret) | 424 | if (ret) |
414 | return ret; | 425 | return ret; |
415 | 426 | ||
427 | super_blocks_used = btrfs_super_blocks_used(info->disk_super); | ||
428 | btrfs_set_super_blocks_used(info->disk_super, super_blocks_used + | ||
429 | num_blocks); | ||
416 | ret = btrfs_insert_item(trans, extent_root, ins, &extent_item, | 430 | ret = btrfs_insert_item(trans, extent_root, ins, &extent_item, |
417 | sizeof(extent_item)); | 431 | sizeof(extent_item)); |
418 | 432 | ||