From: Miao Xie <miaox@cn.fujitsu.com>
To: Josef Bacik <josef@redhat.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] Btrfs: implement ->show_devname V2
Date: Thu, 14 Jun 2012 11:10:54 +0800 [thread overview]
Message-ID: <4FD9563E.5020906@cn.fujitsu.com> (raw)
In-Reply-To: <1339530642-13862-2-git-send-email-josef@redhat.com>
On tue, 12 Jun 2012 15:50:42 -0400, Josef Bacik wrote:
> Because btrfs can remove the device that was mounted we need to have a
> ->show_devname so that in this case we can print out some other device in
> the file system to /proc/mount. So if there are multiple devices in a btrfs
> file system we will just print the device with the lowest devid that we can
> find. This will make everything consistent and deal with device removal
> properly. The drawback is if you mount with a device that is higher than
> the lowest devicd it won't show up as the mounted device in /proc/mounts,
> but this is a small price to pay. This was inspired by Miao Xie's patch.
> Thanks,
>
> Signed-off-by: Josef Bacik <josef@redhat.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
> V1->V2: Dropped the mounted tracking stuff since it doesn't work right if you
> mount the same thing twice
> fs/btrfs/super.c | 33 +++++++++++++++++++++++++++++++++
> 1 files changed, 33 insertions(+), 0 deletions(-)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 85cef50..0874dba 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -54,6 +54,7 @@
> #include "version.h"
> #include "export.h"
> #include "compression.h"
> +#include "rcu-string.h"
>
> #define CREATE_TRACE_POINTS
> #include <trace/events/btrfs.h>
> @@ -1472,12 +1473,44 @@ static int btrfs_unfreeze(struct super_block *sb)
> return 0;
> }
>
> +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 (!first_dev || dev->devid < first_dev->devid)
> + first_dev = dev;
> + }
> + cur_devices = cur_devices->seed;
> + }
> +
> + if (first_dev) {
> + rcu_read_lock();
> + name = rcu_dereference(first_dev->name);
> + seq_escape(m, name->str, " \t\n\\");
> + rcu_read_unlock();
> + } else {
> + WARN_ON(1);
> + }
> + mutex_unlock(&fs_info->fs_devices->device_list_mutex);
> + return 0;
> +}
> +
> static const struct super_operations btrfs_super_ops = {
> .drop_inode = btrfs_drop_inode,
> .evict_inode = btrfs_evict_inode,
> .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,
> .alloc_inode = btrfs_alloc_inode,
> .destroy_inode = btrfs_destroy_inode,
next prev parent reply other threads:[~2012-06-14 3:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-12 19:50 [PATCH 1/2] Btrfs: use rcu to protect device->name V2 Josef Bacik
2012-06-12 19:50 ` [PATCH 2/2] Btrfs: implement ->show_devname V2 Josef Bacik
2012-06-14 3:10 ` Miao Xie [this message]
2012-06-12 22:35 ` [PATCH 1/2] Btrfs: use rcu to protect device->name V2 David Sterba
2012-06-13 10:47 ` Stefan Behrens
2012-06-13 13:14 ` Josef Bacik
2012-06-13 13:49 ` Stefan Behrens
2012-06-13 13:51 ` Josef Bacik
2012-06-14 10:42 ` 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=4FD9563E.5020906@cn.fujitsu.com \
--to=miaox@cn.fujitsu.com \
--cc=josef@redhat.com \
--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).