Commit 0cf6c620 authored by Chris Mason's avatar Chris Mason Committed by David Woodhouse

Btrfs: remove device tree

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent ad693af6
...@@ -16,11 +16,10 @@ extern struct kmem_cache *btrfs_path_cachep; ...@@ -16,11 +16,10 @@ extern struct kmem_cache *btrfs_path_cachep;
#define BTRFS_MAGIC "_BtRfS_M" #define BTRFS_MAGIC "_BtRfS_M"
#define BTRFS_ROOT_TREE_OBJECTID 1ULL #define BTRFS_ROOT_TREE_OBJECTID 1ULL
#define BTRFS_DEV_TREE_OBJECTID 2ULL #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
#define BTRFS_EXTENT_TREE_OBJECTID 3ULL #define BTRFS_FS_TREE_OBJECTID 3ULL
#define BTRFS_FS_TREE_OBJECTID 4ULL #define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL
#define BTRFS_ROOT_TREE_DIR_OBJECTID 5ULL #define BTRFS_FIRST_FREE_OBJECTID 5ULL
#define BTRFS_FIRST_FREE_OBJECTID 6ULL
/* /*
* we can actually store much bigger names, but lets not confuse the rest * we can actually store much bigger names, but lets not confuse the rest
...@@ -111,12 +110,6 @@ struct btrfs_super_block { ...@@ -111,12 +110,6 @@ struct btrfs_super_block {
__le64 total_blocks; __le64 total_blocks;
__le64 blocks_used; __le64 blocks_used;
__le64 root_dir_objectid; __le64 root_dir_objectid;
__le64 last_device_id;
/* fields below here vary with the underlying disk */
__le64 device_block_start;
__le64 device_num_blocks;
__le64 device_root;
__le64 device_id;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
/* /*
...@@ -251,11 +244,6 @@ struct btrfs_csum_item { ...@@ -251,11 +244,6 @@ struct btrfs_csum_item {
u8 csum; u8 csum;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
struct btrfs_device_item {
__le16 pathlen;
__le64 device_id;
} __attribute__ ((__packed__));
/* tag for the radix tree of block groups in ram */ /* tag for the radix tree of block groups in ram */
#define BTRFS_BLOCK_GROUP_DIRTY 0 #define BTRFS_BLOCK_GROUP_DIRTY 0
#define BTRFS_BLOCK_GROUP_AVAIL 1 #define BTRFS_BLOCK_GROUP_AVAIL 1
...@@ -286,11 +274,9 @@ struct btrfs_fs_info { ...@@ -286,11 +274,9 @@ struct btrfs_fs_info {
spinlock_t hash_lock; spinlock_t hash_lock;
struct btrfs_root *extent_root; struct btrfs_root *extent_root;
struct btrfs_root *tree_root; struct btrfs_root *tree_root;
struct btrfs_root *dev_root;
struct radix_tree_root fs_roots_radix; struct radix_tree_root fs_roots_radix;
struct radix_tree_root pending_del_radix; struct radix_tree_root pending_del_radix;
struct radix_tree_root pinned_radix; struct radix_tree_root pinned_radix;
struct radix_tree_root dev_radix;
struct radix_tree_root block_group_radix; struct radix_tree_root block_group_radix;
struct radix_tree_root block_group_data_radix; struct radix_tree_root block_group_data_radix;
struct radix_tree_root extent_map_radix; struct radix_tree_root extent_map_radix;
...@@ -385,11 +371,6 @@ struct btrfs_root { ...@@ -385,11 +371,6 @@ struct btrfs_root {
*/ */
#define BTRFS_BLOCK_GROUP_ITEM_KEY 34 #define BTRFS_BLOCK_GROUP_ITEM_KEY 34
/*
* dev items list the devices that make up the FS
*/
#define BTRFS_DEV_ITEM_KEY 35
/* /*
* string items are for debugging. They just store a short string of * string items are for debugging. They just store a short string of
* data in the FS * data in the FS
...@@ -880,62 +861,6 @@ static inline void btrfs_set_super_root_dir(struct btrfs_super_block *s, u64 ...@@ -880,62 +861,6 @@ static inline void btrfs_set_super_root_dir(struct btrfs_super_block *s, u64
s->root_dir_objectid = cpu_to_le64(val); s->root_dir_objectid = cpu_to_le64(val);
} }
static inline u64 btrfs_super_last_device_id(struct btrfs_super_block *s)
{
return le64_to_cpu(s->last_device_id);
}
static inline void btrfs_set_super_last_device_id(struct btrfs_super_block *s,
u64 val)
{
s->last_device_id = cpu_to_le64(val);
}
static inline u64 btrfs_super_device_id(struct btrfs_super_block *s)
{
return le64_to_cpu(s->device_id);
}
static inline void btrfs_set_super_device_id(struct btrfs_super_block *s,
u64 val)
{
s->device_id = cpu_to_le64(val);
}
static inline u64 btrfs_super_device_block_start(struct btrfs_super_block *s)
{
return le64_to_cpu(s->device_block_start);
}
static inline void btrfs_set_super_device_block_start(struct btrfs_super_block
*s, u64 val)
{
s->device_block_start = cpu_to_le64(val);
}
static inline u64 btrfs_super_device_num_blocks(struct btrfs_super_block *s)
{
return le64_to_cpu(s->device_num_blocks);
}
static inline void btrfs_set_super_device_num_blocks(struct btrfs_super_block
*s, u64 val)
{
s->device_num_blocks = cpu_to_le64(val);
}
static inline u64 btrfs_super_device_root(struct btrfs_super_block *s)
{
return le64_to_cpu(s->device_root);
}
static inline void btrfs_set_super_device_root(struct btrfs_super_block
*s, u64 val)
{
s->device_root = cpu_to_le64(val);
}
static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l) static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l)
{ {
return (u8 *)l->items; return (u8 *)l->items;
...@@ -1031,28 +956,6 @@ static inline void btrfs_set_file_extent_num_blocks(struct ...@@ -1031,28 +956,6 @@ static inline void btrfs_set_file_extent_num_blocks(struct
e->num_blocks = cpu_to_le64(val); e->num_blocks = cpu_to_le64(val);
} }
static inline u16 btrfs_device_pathlen(struct btrfs_device_item *d)
{
return le16_to_cpu(d->pathlen);
}
static inline void btrfs_set_device_pathlen(struct btrfs_device_item *d,
u16 val)
{
d->pathlen = cpu_to_le16(val);
}
static inline u64 btrfs_device_id(struct btrfs_device_item *d)
{
return le64_to_cpu(d->device_id);
}
static inline void btrfs_set_device_id(struct btrfs_device_item *d,
u64 val)
{
d->device_id = cpu_to_le64(val);
}
static inline struct btrfs_root *btrfs_sb(struct super_block *sb) static inline struct btrfs_root *btrfs_sb(struct super_block *sb)
{ {
return sb->s_fs_info; return sb->s_fs_info;
......
This diff is collapsed.
...@@ -2566,83 +2566,6 @@ static int create_snapshot(struct btrfs_root *root, char *name, int namelen) ...@@ -2566,83 +2566,6 @@ static int create_snapshot(struct btrfs_root *root, char *name, int namelen)
return 0; return 0;
} }
static int add_disk(struct btrfs_root *root, char *name, int namelen)
{
struct block_device *bdev;
struct btrfs_path *path;
struct super_block *sb = root->fs_info->sb;
struct btrfs_root *dev_root = root->fs_info->dev_root;
struct btrfs_trans_handle *trans;
struct btrfs_device_item *dev_item;
struct btrfs_key key;
u16 item_size;
u64 num_blocks;
u64 new_blocks;
u64 device_id;
int ret;
printk("adding disk %s\n", name);
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
num_blocks = btrfs_super_total_blocks(root->fs_info->disk_super);
bdev = open_bdev_excl(name, O_RDWR, sb);
if (IS_ERR(bdev)) {
ret = PTR_ERR(bdev);
printk("open bdev excl failed ret %d\n", ret);
goto out_nolock;
}
set_blocksize(bdev, sb->s_blocksize);
new_blocks = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
key.objectid = num_blocks;
key.offset = new_blocks;
key.flags = 0;
btrfs_set_key_type(&key, BTRFS_DEV_ITEM_KEY);
mutex_lock(&dev_root->fs_info->fs_mutex);
trans = btrfs_start_transaction(dev_root, 1);
item_size = sizeof(*dev_item) + namelen;
printk("insert empty on %Lu %Lu %u size %d\n", num_blocks, new_blocks, key.flags, item_size);
ret = btrfs_insert_empty_item(trans, dev_root, path, &key, item_size);
if (ret) {
printk("insert failed %d\n", ret);
close_bdev_excl(bdev);
if (ret > 0)
ret = -EEXIST;
goto out;
}
dev_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
path->slots[0], struct btrfs_device_item);
btrfs_set_device_pathlen(dev_item, namelen);
memcpy(dev_item + 1, name, namelen);
device_id = btrfs_super_last_device_id(root->fs_info->disk_super) + 1;
btrfs_set_super_last_device_id(root->fs_info->disk_super, device_id);
btrfs_set_device_id(dev_item, device_id);
mark_buffer_dirty(path->nodes[0]);
ret = btrfs_insert_dev_radix(root, bdev, device_id, num_blocks,
new_blocks);
if (!ret) {
btrfs_set_super_total_blocks(root->fs_info->disk_super,
num_blocks + new_blocks);
i_size_write(root->fs_info->btree_inode,
(num_blocks + new_blocks) <<
root->fs_info->btree_inode->i_blkbits);
}
out:
ret = btrfs_commit_transaction(trans, dev_root);
BUG_ON(ret);
mutex_unlock(&root->fs_info->fs_mutex);
out_nolock:
btrfs_free_path(path);
btrfs_btree_balance_dirty(root);
return ret;
}
static int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int static int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int
cmd, unsigned long arg) cmd, unsigned long arg)
{ {
...@@ -2682,17 +2605,6 @@ static int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int ...@@ -2682,17 +2605,6 @@ static int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int
ret = create_snapshot(root, vol_args.name, namelen); ret = create_snapshot(root, vol_args.name, namelen);
WARN_ON(ret); WARN_ON(ret);
break; break;
case BTRFS_IOC_ADD_DISK:
if (copy_from_user(&vol_args,
(struct btrfs_ioctl_vol_args __user *)arg,
sizeof(vol_args)))
return -EFAULT;
namelen = strlen(vol_args.name);
if (namelen > BTRFS_VOL_NAME_MAX)
return -EINVAL;
vol_args.name[namelen] = '\0';
ret = add_disk(root, vol_args.name, namelen);
break;
default: default:
return -ENOTTY; return -ENOTTY;
} }
......
...@@ -150,13 +150,7 @@ int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, ...@@ -150,13 +150,7 @@ int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_root *tree_root = fs_info->tree_root; struct btrfs_root *tree_root = fs_info->tree_root;
struct btrfs_root *extent_root = fs_info->extent_root; struct btrfs_root *extent_root = fs_info->extent_root;
struct btrfs_root *dev_root = fs_info->dev_root;
if (btrfs_super_device_root(fs_info->disk_super) !=
bh_blocknr(dev_root->node)) {
btrfs_set_super_device_root(fs_info->disk_super,
bh_blocknr(dev_root->node));
}
btrfs_write_dirty_block_groups(trans, extent_root); btrfs_write_dirty_block_groups(trans, extent_root);
while(1) { while(1) {
old_extent_block = btrfs_root_blocknr(&extent_root->root_item); old_extent_block = btrfs_root_blocknr(&extent_root->root_item);
......
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