aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2008-12-12 10:03:26 -0500
committerChris Mason <chris.mason@oracle.com>2008-12-12 10:03:26 -0500
commite4404d6e8da678d852b7f767f665f8edf76c9e9f (patch)
treeaf6b52e5251d8e939f91e1feab760c1f06021410 /fs/btrfs/extent-tree.c
parentd2fb3437e4d8d12c73c587615ad187d5288547ec (diff)
Btrfs: shared seed device
This patch makes seed device possible to be shared by multiple mounted file systems. The sharing is achieved by cloning seed device's btrfs_fs_devices structure. Thanks you, Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1cc89246ee2f..171057a32679 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -218,7 +218,7 @@ static int cache_block_group(struct btrfs_root *root,
218 struct btrfs_key key; 218 struct btrfs_key key;
219 struct extent_buffer *leaf; 219 struct extent_buffer *leaf;
220 int slot; 220 int slot;
221 u64 last = block_group->key.objectid; 221 u64 last;
222 222
223 if (!block_group) 223 if (!block_group)
224 return 0; 224 return 0;
@@ -239,7 +239,8 @@ static int cache_block_group(struct btrfs_root *root,
239 * skip the locking here 239 * skip the locking here
240 */ 240 */
241 path->skip_locking = 1; 241 path->skip_locking = 1;
242 key.objectid = max_t(u64, last, BTRFS_SUPER_INFO_OFFSET); 242 last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET);
243 key.objectid = last;
243 key.offset = 0; 244 key.offset = 0;
244 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); 245 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
245 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 246 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
@@ -5335,8 +5336,20 @@ static int noinline relocate_one_extent(struct btrfs_root *extent_root,
5335 prev_block = block_start; 5336 prev_block = block_start;
5336 } 5337 }
5337 5338
5338 if (ref_path->owner_objectid >= BTRFS_FIRST_FREE_OBJECTID && 5339 btrfs_record_root_in_trans(found_root);
5339 pass >= 2) { 5340 if (ref_path->owner_objectid >= BTRFS_FIRST_FREE_OBJECTID) {
5341 /*
5342 * try to update data extent references while
5343 * keeping metadata shared between snapshots.
5344 */
5345 if (pass == 1) {
5346 ret = relocate_one_path(trans, found_root,
5347 path, &first_key, ref_path,
5348 group, reloc_inode);
5349 if (ret < 0)
5350 goto out;
5351 continue;
5352 }
5340 /* 5353 /*
5341 * use fallback method to process the remaining 5354 * use fallback method to process the remaining
5342 * references. 5355 * references.
@@ -5359,23 +5372,9 @@ static int noinline relocate_one_extent(struct btrfs_root *extent_root,
5359 path, extent_key, 5372 path, extent_key,
5360 &first_key, ref_path, 5373 &first_key, ref_path,
5361 new_extents, nr_extents); 5374 new_extents, nr_extents);
5362 if (ret < 0) 5375 } else {
5363 goto out;
5364 continue;
5365 }
5366
5367 btrfs_record_root_in_trans(found_root);
5368 if (ref_path->owner_objectid < BTRFS_FIRST_FREE_OBJECTID) {
5369 ret = relocate_tree_block(trans, found_root, path, 5376 ret = relocate_tree_block(trans, found_root, path,
5370 &first_key, ref_path); 5377 &first_key, ref_path);
5371 } else {
5372 /*
5373 * try to update data extent references while
5374 * keeping metadata shared between snapshots.
5375 */
5376 ret = relocate_one_path(trans, found_root, path,
5377 &first_key, ref_path,
5378 group, reloc_inode);
5379 } 5378 }
5380 if (ret < 0) 5379 if (ret < 0)
5381 goto out; 5380 goto out;