diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-12-10 09:10:46 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-12-10 09:10:46 -0500 |
commit | 459931eca5f4b8c9ad259d07cc1ca49afed54804 (patch) | |
tree | 86088c14cff53f93281dc25022b61fb1d86c2458 /fs/btrfs/extent-tree.c | |
parent | 580afd76e451deb6772d0507de580fb1df14da6c (diff) |
Btrfs: Delete csum items when freeing extents
This finishes off the new checksumming code by removing csum items
for extents that are no longer in use.
The trick is doing it without racing because a single csum item may
hold csums for more than one extent. Extra checks are added to
btrfs_csum_file_blocks to make sure that we are using the correct
csum item after dropping locks.
A new btrfs_split_item is added to split a single csum item so it
can be split without dropping the leaf lock. This is used to
remove csum bytes from the middle of an item.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 803647bc8400..cc74316dc426 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2484,7 +2484,6 @@ static int __free_extent(struct btrfs_trans_handle *trans, | |||
2484 | mark_free = 1; | 2484 | mark_free = 1; |
2485 | BUG_ON(ret < 0); | 2485 | BUG_ON(ret < 0); |
2486 | } | 2486 | } |
2487 | |||
2488 | /* block accounting for super block */ | 2487 | /* block accounting for super block */ |
2489 | spin_lock_irq(&info->delalloc_lock); | 2488 | spin_lock_irq(&info->delalloc_lock); |
2490 | super_used = btrfs_super_bytes_used(&info->super_copy); | 2489 | super_used = btrfs_super_bytes_used(&info->super_copy); |
@@ -2504,6 +2503,11 @@ static int __free_extent(struct btrfs_trans_handle *trans, | |||
2504 | mark_free); | 2503 | mark_free); |
2505 | BUG_ON(ret); | 2504 | BUG_ON(ret); |
2506 | 2505 | ||
2506 | if (owner_objectid >= BTRFS_FIRST_FREE_OBJECTID) { | ||
2507 | ret = btrfs_del_csums(trans, root, bytenr, num_bytes); | ||
2508 | BUG_ON(ret); | ||
2509 | } | ||
2510 | |||
2507 | #ifdef BIO_RW_DISCARD | 2511 | #ifdef BIO_RW_DISCARD |
2508 | /* Tell the block device(s) that the sectors can be discarded */ | 2512 | /* Tell the block device(s) that the sectors can be discarded */ |
2509 | ret = btrfs_map_block(&root->fs_info->mapping_tree, READ, | 2513 | ret = btrfs_map_block(&root->fs_info->mapping_tree, READ, |