linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.com, l@damenly.su
Subject: [PATCH RFC v4 3/4] btrfs: use latest_dev in btrfs_show_devname
Date: Mon, 23 Aug 2021 19:31:40 +0800	[thread overview]
Message-ID: <1ffa15f29c6913e51a60c48b1040d8306daa6e67.1629458519.git.anand.jain@oracle.com> (raw)
Message-ID: <20210823113140.eEfFBnRXvMHfbVZf1oicrUjNF6ySBWIjnkJgGS2CcnM@z> (raw)
In-Reply-To: <cover.1629458519.git.anand.jain@oracle.com>

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,
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
v3 add missing rcu_lock in show_devname
v4 -

 fs/btrfs/super.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 64ecbdb50c1a..61682a143bf3 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2464,30 +2464,12 @@ 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;
-	}
-
-	if (first_dev)
-		seq_escape(m, rcu_str_deref(first_dev->name), " \t\n\\");
-	else
-		WARN_ON(1);
+	seq_escape(m, rcu_str_deref(fs_info->fs_devices->latest_dev->name),
+		   " \t\n\\");
 	rcu_read_unlock();
+
 	return 0;
 }
 
-- 
2.31.1


  parent reply	other threads:[~2021-08-23 11:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210823113138.jOljK3KLS8c1v1kFdbAV_tpEHFy5LjD3UB6FOO8_EtI@z>
2021-08-23 11:31 ` [PATCH v4 0/4] btrf_show_devname related fixes Anand Jain
2021-08-20 11:28   ` [PATCH v3 2/4] btrfs: save latest btrfs_device instead of its block_device in fs_devices Anand Jain
2021-08-21 14:46     ` Su Yue
2021-08-23  3:03       ` Anand Jain
2021-08-20 11:32   ` [PATCH v3 0/4] btrf_show_devname related fixes Anand Jain
     [not found]   ` <20210823113139.43q6FCDq3tjx-V8qI6siPYNNaZMOHzbIqHie5SvqOMw@z>
2021-08-23 11:31     ` [PATCH RFC v4 1/4] btrfs: consolidate device_list_mutex in prepare_sprout to its parent Anand Jain
     [not found]   ` <20210823113140.eEfFBnRXvMHfbVZf1oicrUjNF6ySBWIjnkJgGS2CcnM@z>
2021-08-23 11:31     ` Anand Jain [this message]
     [not found]   ` <20210823113141.Y4D53vkx_Zbqje2755YC8T5gXoihAWYX9bIUegUFgTQ@z>
2021-08-23 11:31     ` [PATCH v4 4/4] btrfs: update latest_dev when we sprout Anand Jain
2021-08-23 11:31   ` [PATCH v4 2/4] btrfs: save latest btrfs_device instead of its block_device in fs_devices Anand Jain
2021-08-23 11:45   ` [PATCH v3 0/4] btrf_show_devname related fixes David Sterba
2021-08-23 19:46   ` [PATCH v4 " David Sterba
2021-08-24  0:28     ` Anand Jain
2021-08-24 16:11       ` David Sterba
2021-08-25  2:13         ` Anand Jain
2021-08-31 15:40           ` David Sterba
2021-09-01  8:18             ` Anand Jain
2021-09-01 16:16               ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ffa15f29c6913e51a60c48b1040d8306daa6e67.1629458519.git.anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=l@damenly.su \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).