Commit 672d5990 authored by Misono Tomohiro's avatar Misono Tomohiro Committed by David Sterba

btrfs: Use wrapper macro for rcu string to remove duplicate code

Cleanup patch and no functional changes.
Signed-off-by: default avatarMisono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f5b3a417
...@@ -3157,10 +3157,8 @@ static long btrfs_ioctl_dev_info(struct btrfs_fs_info *fs_info, ...@@ -3157,10 +3157,8 @@ static long btrfs_ioctl_dev_info(struct btrfs_fs_info *fs_info,
di_args->total_bytes = btrfs_device_get_total_bytes(dev); di_args->total_bytes = btrfs_device_get_total_bytes(dev);
memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
if (dev->name) { if (dev->name) {
struct rcu_string *name; strncpy(di_args->path, rcu_str_deref(dev->name),
sizeof(di_args->path) - 1);
name = rcu_dereference(dev->name);
strncpy(di_args->path, name->str, sizeof(di_args->path) - 1);
di_args->path[sizeof(di_args->path) - 1] = 0; di_args->path[sizeof(di_args->path) - 1] = 0;
} else { } else {
di_args->path[0] = '\0'; di_args->path[0] = '\0';
......
...@@ -3779,7 +3779,6 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start, ...@@ -3779,7 +3779,6 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
struct scrub_ctx *sctx; struct scrub_ctx *sctx;
int ret; int ret;
struct btrfs_device *dev; struct btrfs_device *dev;
struct rcu_string *name;
if (btrfs_fs_closing(fs_info)) if (btrfs_fs_closing(fs_info))
return -EINVAL; return -EINVAL;
...@@ -3833,11 +3832,8 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start, ...@@ -3833,11 +3832,8 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
if (!is_dev_replace && !readonly && if (!is_dev_replace && !readonly &&
!test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) { !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) {
mutex_unlock(&fs_info->fs_devices->device_list_mutex); mutex_unlock(&fs_info->fs_devices->device_list_mutex);
rcu_read_lock(); btrfs_err_in_rcu(fs_info, "scrub: device %s is not writable",
name = rcu_dereference(dev->name); rcu_str_deref(dev->name));
btrfs_err(fs_info, "scrub: device %s is not writable",
name->str);
rcu_read_unlock();
return -EROFS; return -EROFS;
} }
......
...@@ -2303,7 +2303,6 @@ static int btrfs_show_devname(struct seq_file *m, struct dentry *root) ...@@ -2303,7 +2303,6 @@ static int btrfs_show_devname(struct seq_file *m, struct dentry *root)
struct btrfs_fs_devices *cur_devices; struct btrfs_fs_devices *cur_devices;
struct btrfs_device *dev, *first_dev = NULL; struct btrfs_device *dev, *first_dev = NULL;
struct list_head *head; struct list_head *head;
struct rcu_string *name;
/* /*
* Lightweight locking of the devices. We should not need * Lightweight locking of the devices. We should not need
...@@ -2327,12 +2326,10 @@ static int btrfs_show_devname(struct seq_file *m, struct dentry *root) ...@@ -2327,12 +2326,10 @@ static int btrfs_show_devname(struct seq_file *m, struct dentry *root)
cur_devices = cur_devices->seed; cur_devices = cur_devices->seed;
} }
if (first_dev) { if (first_dev)
name = rcu_dereference(first_dev->name); seq_escape(m, rcu_str_deref(first_dev->name), " \t\n\\");
seq_escape(m, name->str, " \t\n\\"); else
} else {
WARN_ON(1); WARN_ON(1);
}
rcu_read_unlock(); rcu_read_unlock();
return 0; return 0;
} }
......
...@@ -6094,21 +6094,11 @@ static void submit_stripe_bio(struct btrfs_bio *bbio, struct bio *bio, ...@@ -6094,21 +6094,11 @@ static void submit_stripe_bio(struct btrfs_bio *bbio, struct bio *bio,
btrfs_io_bio(bio)->stripe_index = dev_nr; btrfs_io_bio(bio)->stripe_index = dev_nr;
bio->bi_end_io = btrfs_end_bio; bio->bi_end_io = btrfs_end_bio;
bio->bi_iter.bi_sector = physical >> 9; bio->bi_iter.bi_sector = physical >> 9;
#ifdef DEBUG btrfs_debug_in_rcu(fs_info,
{
struct rcu_string *name;
rcu_read_lock();
name = rcu_dereference(dev->name);
btrfs_debug(fs_info,
"btrfs_map_bio: rw %d 0x%x, sector=%llu, dev=%lu (%s id %llu), size=%u", "btrfs_map_bio: rw %d 0x%x, sector=%llu, dev=%lu (%s id %llu), size=%u",
bio_op(bio), bio->bi_opf, bio_op(bio), bio->bi_opf, (u64)bio->bi_iter.bi_sector,
(u64)bio->bi_iter.bi_sector, (u_long)dev->bdev->bd_dev, rcu_str_deref(dev->name), dev->devid,
(u_long)dev->bdev->bd_dev, name->str, dev->devid,
bio->bi_iter.bi_size); bio->bi_iter.bi_size);
rcu_read_unlock();
}
#endif
bio_set_dev(bio, dev->bdev); bio_set_dev(bio, dev->bdev);
btrfs_bio_counter_inc_noblocked(fs_info); btrfs_bio_counter_inc_noblocked(fs_info);
......
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