diff options
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index c46d7eafcf62..8dcf600e39ef 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -1840,7 +1840,9 @@ static int add_disk(struct btrfs_root *root, char *name, int namelen) | |||
1840 | u16 item_size; | 1840 | u16 item_size; |
1841 | u64 num_blocks; | 1841 | u64 num_blocks; |
1842 | u64 new_blocks; | 1842 | u64 new_blocks; |
1843 | u64 device_id; | ||
1843 | int ret; | 1844 | int ret; |
1845 | |||
1844 | printk("adding disk %s\n", name); | 1846 | printk("adding disk %s\n", name); |
1845 | path = btrfs_alloc_path(); | 1847 | path = btrfs_alloc_path(); |
1846 | if (!path) | 1848 | if (!path) |
@@ -1875,9 +1877,14 @@ printk("insert failed %d\n", ret); | |||
1875 | path->slots[0], struct btrfs_device_item); | 1877 | path->slots[0], struct btrfs_device_item); |
1876 | btrfs_set_device_pathlen(dev_item, namelen); | 1878 | btrfs_set_device_pathlen(dev_item, namelen); |
1877 | memcpy(dev_item + 1, name, namelen); | 1879 | memcpy(dev_item + 1, name, namelen); |
1880 | |||
1881 | device_id = btrfs_super_last_device_id(root->fs_info->disk_super) + 1; | ||
1882 | btrfs_set_super_last_device_id(root->fs_info->disk_super, device_id); | ||
1883 | btrfs_set_device_id(dev_item, device_id); | ||
1878 | mark_buffer_dirty(path->nodes[0]); | 1884 | mark_buffer_dirty(path->nodes[0]); |
1879 | 1885 | ||
1880 | ret = btrfs_insert_dev_radix(root, bdev, num_blocks, new_blocks); | 1886 | ret = btrfs_insert_dev_radix(root, bdev, device_id, num_blocks, |
1887 | new_blocks); | ||
1881 | 1888 | ||
1882 | if (!ret) { | 1889 | if (!ret) { |
1883 | btrfs_set_super_total_blocks(root->fs_info->disk_super, | 1890 | btrfs_set_super_total_blocks(root->fs_info->disk_super, |