linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miao Xie <miaox@cn.fujitsu.com>
To: Linux Fsdevel <linux-fsdevel@vger.kernel.org>,
	Linux Btrfs <linux-btrfs@vger.kernel.org>
Cc: Chris Mason <chris.mason@oracle.com>
Subject: [PATCH 2/2] Btrfs: fix wrong the mount information in /proc
Date: Thu, 31 May 2012 18:25:14 +0800	[thread overview]
Message-ID: <4FC7470A.7020005@cn.fujitsu.com> (raw)

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

             reply	other threads:[~2012-05-31 10:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-31 10:25 Miao Xie [this message]
2012-05-31 14:36 ` [PATCH 2/2] Btrfs: fix wrong the mount information in /proc Al Viro
2012-05-31 15:53   ` Al Viro
2012-05-31 18:15     ` Josef Bacik

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=4FC7470A.7020005@cn.fujitsu.com \
    --to=miaox@cn.fujitsu.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@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).