aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.yan@oracle.com>2010-05-16 10:49:58 -0400
committerChris Mason <chris.mason@oracle.com>2010-05-25 10:34:52 -0400
commitd68fc57b7e3245cfacf2e3b47acfed1946a11786 (patch)
treec2572fcd935017440c8370c8a12ceb49a7fc4f1f /fs/btrfs/disk-io.c
parent8929ecfa50f266163832eeacfbc3642ed5eb83b6 (diff)
Btrfs: Metadata reservation for orphan inodes
reserve metadata space for handling orphan inodes Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 309d8c08a640..82955b73a962 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -894,7 +894,8 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
894 root->ref_cows = 0; 894 root->ref_cows = 0;
895 root->track_dirty = 0; 895 root->track_dirty = 0;
896 root->in_radix = 0; 896 root->in_radix = 0;
897 root->clean_orphans = 0; 897 root->orphan_item_inserted = 0;
898 root->orphan_cleanup_state = 0;
898 899
899 root->fs_info = fs_info; 900 root->fs_info = fs_info;
900 root->objectid = objectid; 901 root->objectid = objectid;
@@ -904,12 +905,13 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
904 root->in_sysfs = 0; 905 root->in_sysfs = 0;
905 root->inode_tree = RB_ROOT; 906 root->inode_tree = RB_ROOT;
906 root->block_rsv = NULL; 907 root->block_rsv = NULL;
908 root->orphan_block_rsv = NULL;
907 909
908 INIT_LIST_HEAD(&root->dirty_list); 910 INIT_LIST_HEAD(&root->dirty_list);
909 INIT_LIST_HEAD(&root->orphan_list); 911 INIT_LIST_HEAD(&root->orphan_list);
910 INIT_LIST_HEAD(&root->root_list); 912 INIT_LIST_HEAD(&root->root_list);
911 spin_lock_init(&root->node_lock); 913 spin_lock_init(&root->node_lock);
912 spin_lock_init(&root->list_lock); 914 spin_lock_init(&root->orphan_lock);
913 spin_lock_init(&root->inode_lock); 915 spin_lock_init(&root->inode_lock);
914 spin_lock_init(&root->accounting_lock); 916 spin_lock_init(&root->accounting_lock);
915 mutex_init(&root->objectid_mutex); 917 mutex_init(&root->objectid_mutex);
@@ -1193,19 +1195,23 @@ again:
1193 if (root) 1195 if (root)
1194 return root; 1196 return root;
1195 1197
1196 ret = btrfs_find_orphan_item(fs_info->tree_root, location->objectid);
1197 if (ret == 0)
1198 ret = -ENOENT;
1199 if (ret < 0)
1200 return ERR_PTR(ret);
1201
1202 root = btrfs_read_fs_root_no_radix(fs_info->tree_root, location); 1198 root = btrfs_read_fs_root_no_radix(fs_info->tree_root, location);
1203 if (IS_ERR(root)) 1199 if (IS_ERR(root))
1204 return root; 1200 return root;
1205 1201
1206 WARN_ON(btrfs_root_refs(&root->root_item) == 0);
1207 set_anon_super(&root->anon_super, NULL); 1202 set_anon_super(&root->anon_super, NULL);
1208 1203
1204 if (btrfs_root_refs(&root->root_item) == 0) {
1205 ret = -ENOENT;
1206 goto fail;
1207 }
1208
1209 ret = btrfs_find_orphan_item(fs_info->tree_root, location->objectid);
1210 if (ret < 0)
1211 goto fail;
1212 if (ret == 0)
1213 root->orphan_item_inserted = 1;
1214
1209 ret = radix_tree_preload(GFP_NOFS & ~__GFP_HIGHMEM); 1215 ret = radix_tree_preload(GFP_NOFS & ~__GFP_HIGHMEM);
1210 if (ret) 1216 if (ret)
1211 goto fail; 1217 goto fail;
@@ -1214,10 +1220,9 @@ again:
1214 ret = radix_tree_insert(&fs_info->fs_roots_radix, 1220 ret = radix_tree_insert(&fs_info->fs_roots_radix,
1215 (unsigned long)root->root_key.objectid, 1221 (unsigned long)root->root_key.objectid,
1216 root); 1222 root);
1217 if (ret == 0) { 1223 if (ret == 0)
1218 root->in_radix = 1; 1224 root->in_radix = 1;
1219 root->clean_orphans = 1; 1225
1220 }
1221 spin_unlock(&fs_info->fs_roots_radix_lock); 1226 spin_unlock(&fs_info->fs_roots_radix_lock);
1222 radix_tree_preload_end(); 1227 radix_tree_preload_end();
1223 if (ret) { 1228 if (ret) {
@@ -1981,6 +1986,9 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1981 BUG_ON(ret); 1986 BUG_ON(ret);
1982 1987
1983 if (!(sb->s_flags & MS_RDONLY)) { 1988 if (!(sb->s_flags & MS_RDONLY)) {
1989 ret = btrfs_cleanup_fs_roots(fs_info);
1990 BUG_ON(ret);
1991
1984 ret = btrfs_recover_relocation(tree_root); 1992 ret = btrfs_recover_relocation(tree_root);
1985 if (ret < 0) { 1993 if (ret < 0) {
1986 printk(KERN_WARNING 1994 printk(KERN_WARNING