diff options
author | Yan, Zheng <zheng.yan@oracle.com> | 2009-09-21 15:56:00 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-09-21 15:56:00 -0400 |
commit | 13a8a7c8c47e542b3cdb45bec3f431f96af79361 (patch) | |
tree | 473f3cc94b4a93a0a5f6f19b1832ef2e6b7ecf62 /fs/btrfs/disk-io.c | |
parent | 1c4850e21df8b441164d910bc611ef46a01d5d75 (diff) |
Btrfs: do not reuse objectid of deleted snapshot/subvol
The new back reference format does not allow reusing objectid of
deleted snapshot/subvol. So we use ++highest_objectid to allocate
objectid for new snapshot/subvol.
Now we use ++highest_objectid to allocate objectid for both new inode
and new snapshot/subvolume, so this patch removes 'find hole' code in
btrfs_find_free_objectid.
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.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 16dae122dda4..790f4b61a3d7 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -895,8 +895,7 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, | |||
895 | root->fs_info = fs_info; | 895 | root->fs_info = fs_info; |
896 | root->objectid = objectid; | 896 | root->objectid = objectid; |
897 | root->last_trans = 0; | 897 | root->last_trans = 0; |
898 | root->highest_inode = 0; | 898 | root->highest_objectid = 0; |
899 | root->last_inode_alloc = 0; | ||
900 | root->name = NULL; | 899 | root->name = NULL; |
901 | root->in_sysfs = 0; | 900 | root->in_sysfs = 0; |
902 | root->inode_tree.rb_node = NULL; | 901 | root->inode_tree.rb_node = NULL; |
@@ -1095,7 +1094,6 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root, | |||
1095 | struct btrfs_fs_info *fs_info = tree_root->fs_info; | 1094 | struct btrfs_fs_info *fs_info = tree_root->fs_info; |
1096 | struct btrfs_path *path; | 1095 | struct btrfs_path *path; |
1097 | struct extent_buffer *l; | 1096 | struct extent_buffer *l; |
1098 | u64 highest_inode; | ||
1099 | u64 generation; | 1097 | u64 generation; |
1100 | u32 blocksize; | 1098 | u32 blocksize; |
1101 | int ret = 0; | 1099 | int ret = 0; |
@@ -1110,7 +1108,7 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root, | |||
1110 | kfree(root); | 1108 | kfree(root); |
1111 | return ERR_PTR(ret); | 1109 | return ERR_PTR(ret); |
1112 | } | 1110 | } |
1113 | goto insert; | 1111 | goto out; |
1114 | } | 1112 | } |
1115 | 1113 | ||
1116 | __setup_root(tree_root->nodesize, tree_root->leafsize, | 1114 | __setup_root(tree_root->nodesize, tree_root->leafsize, |
@@ -1120,39 +1118,30 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root, | |||
1120 | path = btrfs_alloc_path(); | 1118 | path = btrfs_alloc_path(); |
1121 | BUG_ON(!path); | 1119 | BUG_ON(!path); |
1122 | ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0); | 1120 | ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0); |
1123 | if (ret != 0) { | 1121 | if (ret == 0) { |
1124 | if (ret > 0) | 1122 | l = path->nodes[0]; |
1125 | ret = -ENOENT; | 1123 | read_extent_buffer(l, &root->root_item, |
1126 | goto out; | 1124 | btrfs_item_ptr_offset(l, path->slots[0]), |
1125 | sizeof(root->root_item)); | ||
1126 | memcpy(&root->root_key, location, sizeof(*location)); | ||
1127 | } | 1127 | } |
1128 | l = path->nodes[0]; | ||
1129 | read_extent_buffer(l, &root->root_item, | ||
1130 | btrfs_item_ptr_offset(l, path->slots[0]), | ||
1131 | sizeof(root->root_item)); | ||
1132 | memcpy(&root->root_key, location, sizeof(*location)); | ||
1133 | ret = 0; | ||
1134 | out: | ||
1135 | btrfs_release_path(root, path); | ||
1136 | btrfs_free_path(path); | 1128 | btrfs_free_path(path); |
1137 | if (ret) { | 1129 | if (ret) { |
1138 | kfree(root); | 1130 | if (ret > 0) |
1131 | ret = -ENOENT; | ||
1139 | return ERR_PTR(ret); | 1132 | return ERR_PTR(ret); |
1140 | } | 1133 | } |
1134 | |||
1141 | generation = btrfs_root_generation(&root->root_item); | 1135 | generation = btrfs_root_generation(&root->root_item); |
1142 | blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); | 1136 | blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); |
1143 | root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), | 1137 | root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), |
1144 | blocksize, generation); | 1138 | blocksize, generation); |
1145 | root->commit_root = btrfs_root_node(root); | 1139 | root->commit_root = btrfs_root_node(root); |
1146 | BUG_ON(!root->node); | 1140 | BUG_ON(!root->node); |
1147 | insert: | 1141 | out: |
1148 | if (location->objectid != BTRFS_TREE_LOG_OBJECTID) { | 1142 | if (location->objectid != BTRFS_TREE_LOG_OBJECTID) |
1149 | root->ref_cows = 1; | 1143 | root->ref_cows = 1; |
1150 | ret = btrfs_find_highest_inode(root, &highest_inode); | 1144 | |
1151 | if (ret == 0) { | ||
1152 | root->highest_inode = highest_inode; | ||
1153 | root->last_inode_alloc = highest_inode; | ||
1154 | } | ||
1155 | } | ||
1156 | return root; | 1145 | return root; |
1157 | } | 1146 | } |
1158 | 1147 | ||