Btrfs: Delete csum items when freeing extents
[linux-2.6-block.git] / fs / btrfs / extent-tree.c
index 803647bc8400990e192a7bde7fb57fbff728683f..cc74316dc42666bc89ff991e66fdcd4940e7b084 100644 (file)
@@ -2484,7 +2484,6 @@ static int __free_extent(struct btrfs_trans_handle *trans,
                                mark_free = 1;
                        BUG_ON(ret < 0);
                }
-
                /* block accounting for super block */
                spin_lock_irq(&info->delalloc_lock);
                super_used = btrfs_super_bytes_used(&info->super_copy);
@@ -2504,6 +2503,11 @@ static int __free_extent(struct btrfs_trans_handle *trans,
                                         mark_free);
                BUG_ON(ret);
 
+               if (owner_objectid >= BTRFS_FIRST_FREE_OBJECTID) {
+                       ret = btrfs_del_csums(trans, root, bytenr, num_bytes);
+                       BUG_ON(ret);
+               }
+
 #ifdef BIO_RW_DISCARD
                /* Tell the block device(s) that the sectors can be discarded */
                ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,