linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: looping across fs_devices isn't necessary
@ 2014-02-05 12:57 Anand Jain
  2014-02-05 13:02 ` Anand Jain
  0 siblings, 1 reply; 2+ messages in thread
From: Anand Jain @ 2014-02-05 12:57 UTC (permalink / raw)
  To: linux-btrfs

btrfs_show_devname() is trying to know dev name with
lowest devid for a given FSID, so looping across the
FSID isn't necessary

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/super.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 378157c..6ed76d8 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1885,22 +1885,18 @@ 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_fs_devices *cur_devices;
 	struct btrfs_device *dev, *first_dev = NULL;
 	struct list_head *head;
 	struct rcu_string *name;
 
 	mutex_lock(&fs_info->fs_devices->device_list_mutex);
-	cur_devices = fs_info->fs_devices;
-	while (cur_devices) {
-		head = &cur_devices->devices;
-		list_for_each_entry(dev, head, dev_list) {
-			if (dev->missing)
-				continue;
-			if (!first_dev || dev->devid < first_dev->devid)
-				first_dev = dev;
-		}
-		cur_devices = cur_devices->seed;
+
+	head = &fs_info->fs_devices->devices;
+	list_for_each_entry(dev, head, dev_list) {
+		if (dev->missing)
+			continue;
+		if (!first_dev || dev->devid < first_dev->devid)
+			first_dev = dev;
 	}
 
 	if (first_dev) {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: looping across fs_devices isn't necessary
  2014-02-05 12:57 [PATCH] btrfs: looping across fs_devices isn't necessary Anand Jain
@ 2014-02-05 13:02 ` Anand Jain
  0 siblings, 0 replies; 2+ messages in thread
From: Anand Jain @ 2014-02-05 13:02 UTC (permalink / raw)
  To: linux-btrfs



  This patch was incomplete. Kindly ignore.

Thanks, Anand


On 02/05/14 08:57 PM, Anand Jain wrote:
> btrfs_show_devname() is trying to know dev name with
> lowest devid for a given FSID, so looping across the
> FSID isn't necessary
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>   fs/btrfs/super.c |   18 +++++++-----------
>   1 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 378157c..6ed76d8 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1885,22 +1885,18 @@ 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_fs_devices *cur_devices;
>   	struct btrfs_device *dev, *first_dev = NULL;
>   	struct list_head *head;
>   	struct rcu_string *name;
>
>   	mutex_lock(&fs_info->fs_devices->device_list_mutex);
> -	cur_devices = fs_info->fs_devices;
> -	while (cur_devices) {
> -		head = &cur_devices->devices;
> -		list_for_each_entry(dev, head, dev_list) {
> -			if (dev->missing)
> -				continue;
> -			if (!first_dev || dev->devid < first_dev->devid)
> -				first_dev = dev;
> -		}
> -		cur_devices = cur_devices->seed;
> +
> +	head = &fs_info->fs_devices->devices;
> +	list_for_each_entry(dev, head, dev_list) {
> +		if (dev->missing)
> +			continue;
> +		if (!first_dev || dev->devid < first_dev->devid)
> +			first_dev = dev;
>   	}
>
>   	if (first_dev) {
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-05 13:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 12:57 [PATCH] btrfs: looping across fs_devices isn't necessary Anand Jain
2014-02-05 13:02 ` Anand Jain

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).