Message ID | 7c09f4adb27f4dc9de47ec9a4b8b4b540036534e.1629452691.git.anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrf_show_devname related fixes | expand |
On 20/08/2021 17:54, Anand Jain wrote: > latest_dev is updated according to the changes to the device list. > That means we could use the latest_dev->name to show the device name in > /proc/self/mounts. So this patch makes that change. > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > RFC because, > 1. With this patch, /proc/self/mounts might not show the lowest devid > device as we did before. We show the device that has the greatest > generation and, we used it to build the tree. Are we ok with this change > and, it won't affect the ABI? IMO it should be ok. > > v2 use latest_dev so that device path is also shown > > fs/btrfs/super.c | 24 ++---------------------- > 1 file changed, 2 insertions(+), 22 deletions(-) > > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c > index 64ecbdb50c1a..6da62ebda979 100644 > --- a/fs/btrfs/super.c > +++ b/fs/btrfs/super.c > @@ -2464,30 +2464,10 @@ static int btrfs_unfreeze(struct super_block *sb) > static int btrfs_show_devname(struct seq_file *m, struct dentry *root) > { > struct btrfs_fs_info *fs_info = btrfs_sb(root->d_sb); > - struct btrfs_device *dev, *first_dev = NULL; > > - /* > - * Lightweight locking of the devices. We should not need > - * device_list_mutex here as we only read the device data and the list > - * is protected by RCU. Even if a device is deleted during the list > - * traversals, we'll get valid data, the freeing callback will wait at > - * least until the rcu_read_unlock. > - */ > - rcu_read_lock(); > - list_for_each_entry_rcu(dev, &fs_info->fs_devices->devices, dev_list) { > - if (test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state)) > - continue; > - if (!dev->name) > - continue; > - if (!first_dev || dev->devid < first_dev->devid) > - first_dev = dev; > - } > + seq_escape(m, rcu_str_deref(fs_info->fs_devices->latest_dev->name), > + " \t\n\\"); > I missed rcu_lock here. I am fixing it in v3. Thx. > - if (first_dev) > - seq_escape(m, rcu_str_deref(first_dev->name), " \t\n\\"); > - else > - WARN_ON(1); > - rcu_read_unlock(); > return 0; > } > >
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 64ecbdb50c1a..6da62ebda979 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2464,30 +2464,10 @@ static int btrfs_unfreeze(struct super_block *sb) static int btrfs_show_devname(struct seq_file *m, struct dentry *root) { struct btrfs_fs_info *fs_info = btrfs_sb(root->d_sb); - struct btrfs_device *dev, *first_dev = NULL; - /* - * Lightweight locking of the devices. We should not need - * device_list_mutex here as we only read the device data and the list - * is protected by RCU. Even if a device is deleted during the list - * traversals, we'll get valid data, the freeing callback will wait at - * least until the rcu_read_unlock. - */ - rcu_read_lock(); - list_for_each_entry_rcu(dev, &fs_info->fs_devices->devices, dev_list) { - if (test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state)) - continue; - if (!dev->name) - continue; - if (!first_dev || dev->devid < first_dev->devid) - first_dev = dev; - } + seq_escape(m, rcu_str_deref(fs_info->fs_devices->latest_dev->name), + " \t\n\\"); - if (first_dev) - seq_escape(m, rcu_str_deref(first_dev->name), " \t\n\\"); - else - WARN_ON(1); - rcu_read_unlock(); return 0; }
latest_dev is updated according to the changes to the device list. That means we could use the latest_dev->name to show the device name in /proc/self/mounts. So this patch makes that change. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- RFC because, 1. With this patch, /proc/self/mounts might not show the lowest devid device as we did before. We show the device that has the greatest generation and, we used it to build the tree. Are we ok with this change and, it won't affect the ABI? IMO it should be ok. v2 use latest_dev so that device path is also shown fs/btrfs/super.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)