Commit fb456252 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba

btrfs: root->fs_info cleanup, use fs_info->dev_root everywhere

Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent c28f158e
...@@ -832,7 +832,7 @@ static int btrfsic_process_superblock_dev_mirror( ...@@ -832,7 +832,7 @@ static int btrfsic_process_superblock_dev_mirror(
superblock_tmp->never_written = 0; superblock_tmp->never_written = 0;
superblock_tmp->mirror_num = 1 + superblock_mirror_num; superblock_tmp->mirror_num = 1 + superblock_mirror_num;
if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE)
btrfs_info_in_rcu(device->dev_root->fs_info, btrfs_info_in_rcu(device->fs_info,
"new initial S-block (bdev %p, %s) @%llu (%s/%llu/%d)", "new initial S-block (bdev %p, %s) @%llu (%s/%llu/%d)",
superblock_bdev, superblock_bdev,
rcu_str_deref(device->name), dev_bytenr, rcu_str_deref(device->name), dev_bytenr,
......
...@@ -3308,7 +3308,7 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate) ...@@ -3308,7 +3308,7 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
struct btrfs_device *device = (struct btrfs_device *) struct btrfs_device *device = (struct btrfs_device *)
bh->b_private; bh->b_private;
btrfs_warn_rl_in_rcu(device->dev_root->fs_info, btrfs_warn_rl_in_rcu(device->fs_info,
"lost page write due to IO error on %s", "lost page write due to IO error on %s",
rcu_str_deref(device->name)); rcu_str_deref(device->name));
/* note, we don't set_buffer_write_io_error because we have /* note, we don't set_buffer_write_io_error because we have
...@@ -3453,7 +3453,7 @@ static int write_dev_supers(struct btrfs_device *device, ...@@ -3453,7 +3453,7 @@ static int write_dev_supers(struct btrfs_device *device,
bh = __getblk(device->bdev, bytenr / 4096, bh = __getblk(device->bdev, bytenr / 4096,
BTRFS_SUPER_INFO_SIZE); BTRFS_SUPER_INFO_SIZE);
if (!bh) { if (!bh) {
btrfs_err(device->dev_root->fs_info, btrfs_err(device->fs_info,
"couldn't get super buffer head for bytenr %llu", "couldn't get super buffer head for bytenr %llu",
bytenr); bytenr);
errors++; errors++;
......
...@@ -10853,7 +10853,7 @@ static int btrfs_trim_free_extents(struct btrfs_device *device, ...@@ -10853,7 +10853,7 @@ static int btrfs_trim_free_extents(struct btrfs_device *device,
ret = 0; ret = 0;
while (1) { while (1) {
struct btrfs_fs_info *fs_info = device->dev_root->fs_info; struct btrfs_fs_info *fs_info = device->fs_info;
struct btrfs_transaction *trans; struct btrfs_transaction *trans;
u64 bytes; u64 bytes;
......
This diff is collapsed.
...@@ -367,7 +367,7 @@ static noinline void run_scheduled_bios(struct btrfs_device *device) ...@@ -367,7 +367,7 @@ static noinline void run_scheduled_bios(struct btrfs_device *device)
blk_start_plug(&plug); blk_start_plug(&plug);
bdi = blk_get_backing_dev_info(device->bdev); bdi = blk_get_backing_dev_info(device->bdev);
fs_info = device->dev_root->fs_info; fs_info = device->fs_info;
limit = btrfs_async_submit_limit(fs_info); limit = btrfs_async_submit_limit(fs_info);
limit = limit * 2 / 3; limit = limit * 2 / 3;
...@@ -1179,7 +1179,7 @@ int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start, ...@@ -1179,7 +1179,7 @@ int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,
u64 end, u64 *length) u64 end, u64 *length)
{ {
struct btrfs_key key; struct btrfs_key key;
struct btrfs_root *root = device->dev_root; struct btrfs_root *root = device->fs_info->dev_root;
struct btrfs_dev_extent *dev_extent; struct btrfs_dev_extent *dev_extent;
struct btrfs_path *path; struct btrfs_path *path;
u64 extent_end; u64 extent_end;
...@@ -1262,7 +1262,7 @@ static int contains_pending_extent(struct btrfs_transaction *transaction, ...@@ -1262,7 +1262,7 @@ static int contains_pending_extent(struct btrfs_transaction *transaction,
struct btrfs_device *device, struct btrfs_device *device,
u64 *start, u64 len) u64 *start, u64 len)
{ {
struct btrfs_fs_info *fs_info = device->dev_root->fs_info; struct btrfs_fs_info *fs_info = device->fs_info;
struct extent_map *em; struct extent_map *em;
struct list_head *search_list = &fs_info->pinned_chunks; struct list_head *search_list = &fs_info->pinned_chunks;
int ret = 0; int ret = 0;
...@@ -1338,8 +1338,8 @@ int find_free_dev_extent_start(struct btrfs_transaction *transaction, ...@@ -1338,8 +1338,8 @@ int find_free_dev_extent_start(struct btrfs_transaction *transaction,
struct btrfs_device *device, u64 num_bytes, struct btrfs_device *device, u64 num_bytes,
u64 search_start, u64 *start, u64 *len) u64 search_start, u64 *start, u64 *len)
{ {
struct btrfs_root *root = device->fs_info->dev_root;
struct btrfs_key key; struct btrfs_key key;
struct btrfs_root *root = device->dev_root;
struct btrfs_dev_extent *dev_extent; struct btrfs_dev_extent *dev_extent;
struct btrfs_path *path; struct btrfs_path *path;
u64 hole_size; u64 hole_size;
...@@ -1508,9 +1508,9 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans, ...@@ -1508,9 +1508,9 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
struct btrfs_device *device, struct btrfs_device *device,
u64 start, u64 *dev_extent_len) u64 start, u64 *dev_extent_len)
{ {
struct btrfs_root *root = device->fs_info->dev_root;
int ret; int ret;
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_root *root = device->dev_root;
struct btrfs_key key; struct btrfs_key key;
struct btrfs_key found_key; struct btrfs_key found_key;
struct extent_buffer *leaf = NULL; struct extent_buffer *leaf = NULL;
...@@ -1569,7 +1569,7 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans, ...@@ -1569,7 +1569,7 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
{ {
int ret; int ret;
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_root *root = device->dev_root; struct btrfs_root *root = device->fs_info->dev_root;
struct btrfs_dev_extent *extent; struct btrfs_dev_extent *extent;
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct btrfs_key key; struct btrfs_key key;
...@@ -2387,7 +2387,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, char *device_path) ...@@ -2387,7 +2387,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, char *device_path)
device->total_bytes = i_size_read(bdev->bd_inode); device->total_bytes = i_size_read(bdev->bd_inode);
device->disk_total_bytes = device->total_bytes; device->disk_total_bytes = device->total_bytes;
device->commit_total_bytes = device->total_bytes; device->commit_total_bytes = device->total_bytes;
device->dev_root = root->fs_info->dev_root; device->fs_info = fs_info;
device->bdev = bdev; device->bdev = bdev;
device->in_fs_metadata = 1; device->in_fs_metadata = 1;
device->is_tgtdev_for_dev_replace = 0; device->is_tgtdev_for_dev_replace = 0;
...@@ -2596,7 +2596,7 @@ int btrfs_init_dev_replace_tgtdev(struct btrfs_root *root, char *device_path, ...@@ -2596,7 +2596,7 @@ int btrfs_init_dev_replace_tgtdev(struct btrfs_root *root, char *device_path,
ASSERT(list_empty(&srcdev->resized_list)); ASSERT(list_empty(&srcdev->resized_list));
device->commit_total_bytes = srcdev->commit_total_bytes; device->commit_total_bytes = srcdev->commit_total_bytes;
device->commit_bytes_used = device->bytes_used; device->commit_bytes_used = device->bytes_used;
device->dev_root = fs_info->dev_root; device->fs_info = fs_info;
device->bdev = bdev; device->bdev = bdev;
device->in_fs_metadata = 1; device->in_fs_metadata = 1;
device->is_tgtdev_for_dev_replace = 1; device->is_tgtdev_for_dev_replace = 1;
...@@ -2624,7 +2624,7 @@ void btrfs_init_dev_replace_tgtdev_for_resume(struct btrfs_fs_info *fs_info, ...@@ -2624,7 +2624,7 @@ void btrfs_init_dev_replace_tgtdev_for_resume(struct btrfs_fs_info *fs_info,
tgtdev->io_width = fs_info->dev_root->sectorsize; tgtdev->io_width = fs_info->dev_root->sectorsize;
tgtdev->io_align = fs_info->dev_root->sectorsize; tgtdev->io_align = fs_info->dev_root->sectorsize;
tgtdev->sector_size = fs_info->dev_root->sectorsize; tgtdev->sector_size = fs_info->dev_root->sectorsize;
tgtdev->dev_root = fs_info->dev_root; tgtdev->fs_info = fs_info;
tgtdev->in_fs_metadata = 1; tgtdev->in_fs_metadata = 1;
} }
...@@ -2638,7 +2638,7 @@ static noinline int btrfs_update_device(struct btrfs_trans_handle *trans, ...@@ -2638,7 +2638,7 @@ static noinline int btrfs_update_device(struct btrfs_trans_handle *trans,
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct btrfs_key key; struct btrfs_key key;
root = device->dev_root->fs_info->chunk_root; root = device->fs_info->chunk_root;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
...@@ -2679,8 +2679,7 @@ static noinline int btrfs_update_device(struct btrfs_trans_handle *trans, ...@@ -2679,8 +2679,7 @@ static noinline int btrfs_update_device(struct btrfs_trans_handle *trans,
int btrfs_grow_device(struct btrfs_trans_handle *trans, int btrfs_grow_device(struct btrfs_trans_handle *trans,
struct btrfs_device *device, u64 new_size) struct btrfs_device *device, u64 new_size)
{ {
struct btrfs_super_block *super_copy = struct btrfs_super_block *super_copy = device->fs_info->super_copy;
device->dev_root->fs_info->super_copy;
struct btrfs_fs_devices *fs_devices; struct btrfs_fs_devices *fs_devices;
u64 old_total; u64 old_total;
u64 diff; u64 diff;
...@@ -2688,28 +2687,28 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans, ...@@ -2688,28 +2687,28 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans,
if (!device->writeable) if (!device->writeable)
return -EACCES; return -EACCES;
lock_chunks(device->dev_root); lock_chunks(device->fs_info->dev_root);
old_total = btrfs_super_total_bytes(super_copy); old_total = btrfs_super_total_bytes(super_copy);
diff = new_size - device->total_bytes; diff = new_size - device->total_bytes;
if (new_size <= device->total_bytes || if (new_size <= device->total_bytes ||
device->is_tgtdev_for_dev_replace) { device->is_tgtdev_for_dev_replace) {
unlock_chunks(device->dev_root); unlock_chunks(device->fs_info->dev_root);
return -EINVAL; return -EINVAL;
} }
fs_devices = device->dev_root->fs_info->fs_devices; fs_devices = device->fs_info->fs_devices;
btrfs_set_super_total_bytes(super_copy, old_total + diff); btrfs_set_super_total_bytes(super_copy, old_total + diff);
device->fs_devices->total_rw_bytes += diff; device->fs_devices->total_rw_bytes += diff;
btrfs_device_set_total_bytes(device, new_size); btrfs_device_set_total_bytes(device, new_size);
btrfs_device_set_disk_total_bytes(device, new_size); btrfs_device_set_disk_total_bytes(device, new_size);
btrfs_clear_space_info_full(device->dev_root->fs_info); btrfs_clear_space_info_full(device->fs_info);
if (list_empty(&device->resized_list)) if (list_empty(&device->resized_list))
list_add_tail(&device->resized_list, list_add_tail(&device->resized_list,
&fs_devices->resized_devices); &fs_devices->resized_devices);
unlock_chunks(device->dev_root); unlock_chunks(device->fs_info->dev_root);
return btrfs_update_device(trans, device); return btrfs_update_device(trans, device);
} }
...@@ -4356,7 +4355,7 @@ int btrfs_check_uuid_tree(struct btrfs_fs_info *fs_info) ...@@ -4356,7 +4355,7 @@ int btrfs_check_uuid_tree(struct btrfs_fs_info *fs_info)
int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
{ {
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
struct btrfs_root *root = device->dev_root; struct btrfs_root *root = device->fs_info->dev_root;
struct btrfs_dev_extent *dev_extent = NULL; struct btrfs_dev_extent *dev_extent = NULL;
struct btrfs_path *path; struct btrfs_path *path;
u64 length; u64 length;
...@@ -6884,7 +6883,7 @@ void btrfs_init_devices_late(struct btrfs_fs_info *fs_info) ...@@ -6884,7 +6883,7 @@ void btrfs_init_devices_late(struct btrfs_fs_info *fs_info)
while (fs_devices) { while (fs_devices) {
mutex_lock(&fs_devices->device_list_mutex); mutex_lock(&fs_devices->device_list_mutex);
list_for_each_entry(device, &fs_devices->devices, dev_list) list_for_each_entry(device, &fs_devices->devices, dev_list)
device->dev_root = fs_info->dev_root; device->fs_info = fs_info;
mutex_unlock(&fs_devices->device_list_mutex); mutex_unlock(&fs_devices->device_list_mutex);
fs_devices = fs_devices->seed; fs_devices = fs_devices->seed;
...@@ -7060,7 +7059,7 @@ static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev) ...@@ -7060,7 +7059,7 @@ static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev)
{ {
if (!dev->dev_stats_valid) if (!dev->dev_stats_valid)
return; return;
btrfs_err_rl_in_rcu(dev->dev_root->fs_info, btrfs_err_rl_in_rcu(dev->fs_info,
"bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u", "bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u",
rcu_str_deref(dev->name), rcu_str_deref(dev->name),
btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS), btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS),
...@@ -7080,7 +7079,7 @@ static void btrfs_dev_stat_print_on_load(struct btrfs_device *dev) ...@@ -7080,7 +7079,7 @@ static void btrfs_dev_stat_print_on_load(struct btrfs_device *dev)
if (i == BTRFS_DEV_STAT_VALUES_MAX) if (i == BTRFS_DEV_STAT_VALUES_MAX)
return; /* all values == 0, suppress message */ return; /* all values == 0, suppress message */
btrfs_info_in_rcu(dev->dev_root->fs_info, btrfs_info_in_rcu(dev->fs_info,
"bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u", "bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u",
rcu_str_deref(dev->name), rcu_str_deref(dev->name),
btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS), btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS),
......
...@@ -51,8 +51,7 @@ struct btrfs_device { ...@@ -51,8 +51,7 @@ struct btrfs_device {
struct list_head dev_list; struct list_head dev_list;
struct list_head dev_alloc_list; struct list_head dev_alloc_list;
struct btrfs_fs_devices *fs_devices; struct btrfs_fs_devices *fs_devices;
struct btrfs_fs_info *fs_info;
struct btrfs_root *dev_root;
struct rcu_string *name; struct rcu_string *name;
......
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