Commit e4404d6e authored by Yan Zheng's avatar Yan Zheng Committed by Chris Mason

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: default avatarYan Zheng <zheng.yan@oracle.com>
parent d2fb3437
......@@ -1711,7 +1711,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
}
mutex_lock(&fs_info->chunk_mutex);
ret = btrfs_read_sys_array(tree_root, btrfs_super_bytenr(disk_super));
ret = btrfs_read_sys_array(tree_root);
mutex_unlock(&fs_info->chunk_mutex);
if (ret) {
printk("btrfs: failed to read the system array on %s\n",
......
......@@ -218,7 +218,7 @@ static int cache_block_group(struct btrfs_root *root,
struct btrfs_key key;
struct extent_buffer *leaf;
int slot;
u64 last = block_group->key.objectid;
u64 last;
if (!block_group)
return 0;
......@@ -239,7 +239,8 @@ static int cache_block_group(struct btrfs_root *root,
* skip the locking here
*/
path->skip_locking = 1;
key.objectid = max_t(u64, last, BTRFS_SUPER_INFO_OFFSET);
last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET);
key.objectid = last;
key.offset = 0;
btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
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,
prev_block = block_start;
}
if (ref_path->owner_objectid >= BTRFS_FIRST_FREE_OBJECTID &&
pass >= 2) {
btrfs_record_root_in_trans(found_root);
if (ref_path->owner_objectid >= BTRFS_FIRST_FREE_OBJECTID) {
/*
* try to update data extent references while
* keeping metadata shared between snapshots.
*/
if (pass == 1) {
ret = relocate_one_path(trans, found_root,
path, &first_key, ref_path,
group, reloc_inode);
if (ret < 0)
goto out;
continue;
}
/*
* use fallback method to process the remaining
* references.
......@@ -5359,23 +5372,9 @@ static int noinline relocate_one_extent(struct btrfs_root *extent_root,
path, extent_key,
&first_key, ref_path,
new_extents, nr_extents);
if (ret < 0)
goto out;
continue;
}
btrfs_record_root_in_trans(found_root);
if (ref_path->owner_objectid < BTRFS_FIRST_FREE_OBJECTID) {
} else {
ret = relocate_tree_block(trans, found_root, path,
&first_key, ref_path);
} else {
/*
* try to update data extent references while
* keeping metadata shared between snapshots.
*/
ret = relocate_one_path(trans, found_root, path,
&first_key, ref_path,
group, reloc_inode);
}
if (ret < 0)
goto out;
......
......@@ -58,14 +58,15 @@ static struct super_operations btrfs_super_ops;
static void btrfs_put_super (struct super_block * sb)
{
struct btrfs_root *root = btrfs_sb(sb);
struct btrfs_fs_info *fs = root->fs_info;
int ret;
ret = close_ctree(root);
if (ret) {
printk("close ctree returns %d\n", ret);
}
btrfs_sysfs_del_super(fs);
#if 0
btrfs_sysfs_del_super(root->fs_info);
#endif
sb->s_fs_info = NULL;
}
......@@ -349,11 +350,12 @@ static int btrfs_fill_super(struct super_block * sb,
err = -ENOMEM;
goto fail_close;
}
#if 0
/* this does the super kobj at the same time */
err = btrfs_sysfs_add_super(tree_root->fs_info);
if (err)
goto fail_close;
#endif
sb->s_root = root_dentry;
......
This diff is collapsed.
......@@ -93,7 +93,6 @@ struct btrfs_fs_devices {
struct btrfs_fs_devices *seed;
int seeding;
int sprouted;
int opened;
};
......@@ -127,7 +126,7 @@ int btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree,
u64 chunk_start, u64 physical, u64 devid,
u64 **logical, int *naddrs, int *stripe_len);
int btrfs_read_sys_array(struct btrfs_root *root, u64 sb_bytenr);
int btrfs_read_sys_array(struct btrfs_root *root);
int btrfs_read_chunk_tree(struct btrfs_root *root);
int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
struct btrfs_root *extent_root, u64 type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment