* [PATCH 1/2] btrfs: declare fs_devices in btrfs_init_new_device()
@ 2018-07-03 5:14 Anand Jain
2018-07-03 5:14 ` [PATCH 2/2] btrfs: drop devices declare " Anand Jain
2018-07-04 14:57 ` [PATCH 1/2] btrfs: declare fs_devices " David Sterba
0 siblings, 2 replies; 4+ messages in thread
From: Anand Jain @ 2018-07-03 5:14 UTC (permalink / raw)
To: linux-btrfs
There are many instances of the %fs_info->fs_devices pointer
de-reference, so declare a %fs_devices pointer instead.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/volumes.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 18cd73703951..f7fa0ea26e9c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2409,12 +2409,13 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
struct list_head *devices;
struct super_block *sb = fs_info->sb;
struct rcu_string *name;
+ struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
u64 tmp;
int seeding_dev = 0;
int ret = 0;
bool unlocked = false;
- if (sb_rdonly(sb) && !fs_info->fs_devices->seeding)
+ if (sb_rdonly(sb) && !fs_devices->seeding)
return -EROFS;
bdev = blkdev_get_by_path(device_path, FMODE_WRITE | FMODE_EXCL,
@@ -2422,7 +2423,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
if (IS_ERR(bdev))
return PTR_ERR(bdev);
- if (fs_info->fs_devices->seeding) {
+ if (fs_devices->seeding) {
seeding_dev = 1;
down_write(&sb->s_umount);
mutex_lock(&uuid_mutex);
@@ -2430,18 +2431,18 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
filemap_write_and_wait(bdev->bd_inode->i_mapping);
- devices = &fs_info->fs_devices->devices;
+ devices = &fs_devices->devices;
- mutex_lock(&fs_info->fs_devices->device_list_mutex);
+ mutex_lock(&fs_devices->device_list_mutex);
list_for_each_entry(device, devices, dev_list) {
if (device->bdev == bdev) {
ret = -EEXIST;
mutex_unlock(
- &fs_info->fs_devices->device_list_mutex);
+ &fs_devices->device_list_mutex);
goto error;
}
}
- mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+ mutex_unlock(&fs_devices->device_list_mutex);
device = btrfs_alloc_device(fs_info, NULL, NULL);
if (IS_ERR(device)) {
@@ -2490,23 +2491,22 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
}
}
- device->fs_devices = fs_info->fs_devices;
+ device->fs_devices = fs_devices;
- mutex_lock(&fs_info->fs_devices->device_list_mutex);
+ mutex_lock(&fs_devices->device_list_mutex);
mutex_lock(&fs_info->chunk_mutex);
- list_add_rcu(&device->dev_list, &fs_info->fs_devices->devices);
- list_add(&device->dev_alloc_list,
- &fs_info->fs_devices->alloc_list);
- fs_info->fs_devices->num_devices++;
- fs_info->fs_devices->open_devices++;
- fs_info->fs_devices->rw_devices++;
- fs_info->fs_devices->total_devices++;
- fs_info->fs_devices->total_rw_bytes += device->total_bytes;
+ list_add_rcu(&device->dev_list, &fs_devices->devices);
+ list_add(&device->dev_alloc_list, &fs_devices->alloc_list);
+ fs_devices->num_devices++;
+ fs_devices->open_devices++;
+ fs_devices->rw_devices++;
+ fs_devices->total_devices++;
+ fs_devices->total_rw_bytes += device->total_bytes;
atomic64_add(device->total_bytes, &fs_info->free_chunk_space);
if (!blk_queue_nonrot(q))
- fs_info->fs_devices->rotating = 1;
+ fs_devices->rotating = 1;
tmp = btrfs_super_total_bytes(fs_info->super_copy);
btrfs_set_super_total_bytes(fs_info->super_copy,
@@ -2516,7 +2516,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
btrfs_set_super_num_devices(fs_info->super_copy, tmp + 1);
/* add sysfs device entry */
- btrfs_sysfs_add_device_link(fs_info->fs_devices, device);
+ btrfs_sysfs_add_device_link(fs_devices, device);
/*
* we've got more storage, clear any full flags on the space
@@ -2525,7 +2525,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
btrfs_clear_space_info_full(fs_info);
mutex_unlock(&fs_info->chunk_mutex);
- mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+ mutex_unlock(&fs_devices->device_list_mutex);
if (seeding_dev) {
mutex_lock(&fs_info->chunk_mutex);
@@ -2557,7 +2557,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
*/
snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU",
fs_info->fsid);
- if (kobject_rename(&fs_info->fs_devices->fsid_kobj, fsid_buf))
+ if (kobject_rename(&fs_devices->fsid_kobj, fsid_buf))
btrfs_warn(fs_info,
"sysfs: failed to create fsid for sprout");
}
@@ -2592,7 +2592,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
return ret;
error_sysfs:
- btrfs_sysfs_rm_device_link(fs_info->fs_devices, device);
+ btrfs_sysfs_rm_device_link(fs_devices, device);
error_trans:
if (seeding_dev)
sb->s_flags |= SB_RDONLY;
--
2.15.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] btrfs: drop devices declare in btrfs_init_new_device()
2018-07-03 5:14 [PATCH 1/2] btrfs: declare fs_devices in btrfs_init_new_device() Anand Jain
@ 2018-07-03 5:14 ` Anand Jain
2018-07-03 5:58 ` Nikolay Borisov
2018-07-04 14:57 ` [PATCH 1/2] btrfs: declare fs_devices " David Sterba
1 sibling, 1 reply; 4+ messages in thread
From: Anand Jain @ 2018-07-03 5:14 UTC (permalink / raw)
To: linux-btrfs
There is only one usage of the declared devices variable, instead
use its value directly.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/volumes.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index f7fa0ea26e9c..124bd8728c37 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2406,7 +2406,6 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
struct btrfs_trans_handle *trans;
struct btrfs_device *device;
struct block_device *bdev;
- struct list_head *devices;
struct super_block *sb = fs_info->sb;
struct rcu_string *name;
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
@@ -2431,10 +2430,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
filemap_write_and_wait(bdev->bd_inode->i_mapping);
- devices = &fs_devices->devices;
-
mutex_lock(&fs_devices->device_list_mutex);
- list_for_each_entry(device, devices, dev_list) {
+ list_for_each_entry(device, &fs_devices->devices, dev_list) {
if (device->bdev == bdev) {
ret = -EEXIST;
mutex_unlock(
--
2.15.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] btrfs: drop devices declare in btrfs_init_new_device()
2018-07-03 5:14 ` [PATCH 2/2] btrfs: drop devices declare " Anand Jain
@ 2018-07-03 5:58 ` Nikolay Borisov
0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2018-07-03 5:58 UTC (permalink / raw)
To: Anand Jain, linux-btrfs
On 3.07.2018 08:14, Anand Jain wrote:
> There is only one usage of the declared devices variable, instead
> use its value directly.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/volumes.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index f7fa0ea26e9c..124bd8728c37 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -2406,7 +2406,6 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
> struct btrfs_trans_handle *trans;
> struct btrfs_device *device;
> struct block_device *bdev;
> - struct list_head *devices;
> struct super_block *sb = fs_info->sb;
> struct rcu_string *name;
> struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
> @@ -2431,10 +2430,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
>
> filemap_write_and_wait(bdev->bd_inode->i_mapping);
>
> - devices = &fs_devices->devices;
> -
> mutex_lock(&fs_devices->device_list_mutex);
> - list_for_each_entry(device, devices, dev_list) {
> + list_for_each_entry(device, &fs_devices->devices, dev_list) {
> if (device->bdev == bdev) {
> ret = -EEXIST;
> mutex_unlock(
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] btrfs: declare fs_devices in btrfs_init_new_device()
2018-07-03 5:14 [PATCH 1/2] btrfs: declare fs_devices in btrfs_init_new_device() Anand Jain
2018-07-03 5:14 ` [PATCH 2/2] btrfs: drop devices declare " Anand Jain
@ 2018-07-04 14:57 ` David Sterba
1 sibling, 0 replies; 4+ messages in thread
From: David Sterba @ 2018-07-04 14:57 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Tue, Jul 03, 2018 at 01:14:50PM +0800, Anand Jain wrote:
> There are many instances of the %fs_info->fs_devices pointer
> de-reference, so declare a %fs_devices pointer instead.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
1-2 added to misc-next, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-04 14:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-03 5:14 [PATCH 1/2] btrfs: declare fs_devices in btrfs_init_new_device() Anand Jain
2018-07-03 5:14 ` [PATCH 2/2] btrfs: drop devices declare " Anand Jain
2018-07-03 5:58 ` Nikolay Borisov
2018-07-04 14:57 ` [PATCH 1/2] btrfs: declare fs_devices " David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).