* [PATCH 1/1] btrfs: simplify fs_devices member access in btrfs_init_dev_replace_tgtdev
@ 2022-01-17 15:50 Anand Jain
2022-01-17 17:17 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Anand Jain @ 2022-01-17 15:50 UTC (permalink / raw)
To: linux-btrfs
In btrfs_init_dev_replace_tgtdev() we dereference fs_info to get
fs_devices many times, instead save a point to the fs_devices.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/dev-replace.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 289d6cc1f5db..71fd99b48283 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -243,6 +243,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
struct btrfs_device *srcdev,
struct btrfs_device **device_out)
{
+ struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
struct btrfs_device *device;
struct block_device *bdev;
struct rcu_string *name;
@@ -271,7 +272,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
sync_blockdev(bdev);
- list_for_each_entry(device, &fs_info->fs_devices->devices, dev_list) {
+ list_for_each_entry(device, &fs_devices->devices, dev_list) {
if (device->bdev == bdev) {
btrfs_err(fs_info,
"target device is in the filesystem!");
@@ -323,17 +324,17 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
device->mode = FMODE_EXCL;
device->dev_stats_valid = 1;
set_blocksize(device->bdev, BTRFS_BDEV_BLOCKSIZE);
- device->fs_devices = fs_info->fs_devices;
+ device->fs_devices = fs_devices;
ret = btrfs_get_dev_zone_info(device, false);
if (ret)
goto error;
- mutex_lock(&fs_info->fs_devices->device_list_mutex);
- list_add(&device->dev_list, &fs_info->fs_devices->devices);
- fs_info->fs_devices->num_devices++;
- fs_info->fs_devices->open_devices++;
- mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+ mutex_lock(&fs_devices->device_list_mutex);
+ list_add(&device->dev_list, &fs_devices->devices);
+ fs_devices->num_devices++;
+ fs_devices->open_devices++;
+ mutex_unlock(&fs_devices->device_list_mutex);
*device_out = device;
return 0;
--
2.33.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] btrfs: simplify fs_devices member access in btrfs_init_dev_replace_tgtdev
2022-01-17 15:50 [PATCH 1/1] btrfs: simplify fs_devices member access in btrfs_init_dev_replace_tgtdev Anand Jain
@ 2022-01-17 17:17 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2022-01-17 17:17 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Mon, Jan 17, 2022 at 11:50:39PM +0800, Anand Jain wrote:
> In btrfs_init_dev_replace_tgtdev() we dereference fs_info to get
> fs_devices many times, instead save a point to the fs_devices.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-17 17:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17 15:50 [PATCH 1/1] btrfs: simplify fs_devices member access in btrfs_init_dev_replace_tgtdev Anand Jain
2022-01-17 17:17 ` 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).