linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] Btrfs: fix wrong the mount information in /proc
@ 2012-05-31 10:25 Miao Xie
  2012-05-31 14:36 ` Al Viro
  0 siblings, 1 reply; 4+ messages in thread
From: Miao Xie @ 2012-05-31 10:25 UTC (permalink / raw)
  To: Linux Fsdevel, Linux Btrfs; +Cc: Chris Mason

If we remove the disk that is specified when mounting, the mount information
in /proc can not be updated. It will make us can not add that disk back into
the filesystem. This patch fix this problem by implement the show_devname()
interface and choose the name of the device with minimum device id to show.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/super.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c5f8fca..99e5671 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -41,6 +41,7 @@
 #include <linux/slab.h>
 #include <linux/cleancache.h>
 #include <linux/ratelimit.h>
+#include "../mount.h"
 #include "compat.h"
 #include "delayed-inode.h"
 #include "ctree.h"
@@ -892,6 +893,35 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
 	return 0;
 }
 
+static int btrfs_show_devname(struct seq_file *m, struct vfsmount *mnt)
+{
+	struct btrfs_fs_info *fs_info = btrfs_sb(mnt->mnt_sb);
+	struct mount *r = real_mount(mnt);
+	struct btrfs_fs_devices *cur_devices;
+	struct btrfs_device *dev;
+	struct list_head *head;
+	struct btrfs_device *first_dev = NULL;
+
+	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 (!strcmp(r->mnt_devname, dev->name)) {
+				seq_escape(m, r->mnt_devname, " \t\n\\");
+				goto out;
+			}
+			if (!first_dev || dev->devid < first_dev->devid)
+				first_dev = dev;
+		}
+		cur_devices = cur_devices->seed;
+	}
+	seq_escape(m, first_dev->name, " \t\n\\");
+out:
+	mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+	return 0;
+}
+
 static int btrfs_test_super(struct super_block *s, void *data)
 {
 	struct btrfs_fs_info *p = data;
@@ -1467,6 +1497,7 @@ static const struct super_operations btrfs_super_ops = {
 	.put_super	= btrfs_put_super,
 	.sync_fs	= btrfs_sync_fs,
 	.show_options	= btrfs_show_options,
+	.show_devname	= btrfs_show_devname,
 	.write_inode	= btrfs_write_inode,
 	.dirty_inode	= btrfs_fs_dirty_inode,
 	.alloc_inode	= btrfs_alloc_inode,
-- 
1.7.6.5

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

end of thread, other threads:[~2012-05-31 18:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31 10:25 [PATCH 2/2] Btrfs: fix wrong the mount information in /proc Miao Xie
2012-05-31 14:36 ` Al Viro
2012-05-31 15:53   ` Al Viro
2012-05-31 18:15     ` Josef Bacik

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