Btrfs: Fix extent_map and extent_state leaks by flushing lrus on FS unmount
authorChris Mason <chris.mason@oracle.com>
Tue, 18 Dec 2007 01:14:04 +0000 (20:14 -0500)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:03:58 +0000 (11:03 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/disk-io.c

index 4338b00c2a254858953cb932045d71438eb359a6..2785641789932ae8b097b482c4ba5df4f6431217 100644 (file)
@@ -765,8 +765,18 @@ int close_ctree(struct btrfs_root *root)
 
        btrfs_free_block_groups(root->fs_info);
        del_fs_roots(fs_info);
+
+       filemap_write_and_wait(fs_info->btree_inode->i_mapping);
+
+       extent_map_tree_empty_lru(&fs_info->free_space_cache);
+       extent_map_tree_empty_lru(&fs_info->block_group_cache);
+       extent_map_tree_empty_lru(&fs_info->pinned_extents);
+       extent_map_tree_empty_lru(&fs_info->pending_del);
+       extent_map_tree_empty_lru(&fs_info->extent_ins);
        extent_map_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->extent_tree);
+
        truncate_inode_pages(fs_info->btree_inode->i_mapping, 0);
+
        iput(fs_info->btree_inode);
 #if 0
        while(!list_empty(&fs_info->hashers)) {