aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2012-06-05 14:13:12 -0400
committerChris Mason <chris.mason@oracle.com>2012-06-14 21:30:37 -0400
commit9c5085c147989d48dfe74194b48affc23f376650 (patch)
treee0031a23f284d13b6adc3d14f299b2c9aa9f191f
parent606686eeac4550d2212bf3d621a810407ef5e9bf (diff)
Btrfs: implement ->show_devname
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, Reviewed-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <josef@redhat.com>
-rw-r--r--fs/btrfs/super.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 96eb9fef7bd..0eb9a4da069 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -54,6 +54,7 @@
54#include "version.h" 54#include "version.h"
55#include "export.h" 55#include "export.h"
56#include "compression.h" 56#include "compression.h"
57#include "rcu-string.h"
57 58
58#define CREATE_TRACE_POINTS 59#define CREATE_TRACE_POINTS
59#include <trace/events/btrfs.h> 60#include <trace/events/btrfs.h>
@@ -1482,12 +1483,44 @@ static void btrfs_fs_dirty_inode(struct inode *inode, int flags)
1482 "error %d\n", btrfs_ino(inode), ret); 1483 "error %d\n", btrfs_ino(inode), ret);
1483} 1484}
1484 1485
1486static int btrfs_show_devname(struct seq_file *m, struct dentry *root)
1487{
1488 struct btrfs_fs_info *fs_info = btrfs_sb(root->d_sb);
1489 struct btrfs_fs_devices *cur_devices;
1490 struct btrfs_device *dev, *first_dev = NULL;
1491 struct list_head *head;
1492 struct rcu_string *name;
1493
1494 mutex_lock(&fs_info->fs_devices->device_list_mutex);
1495 cur_devices = fs_info->fs_devices;
1496 while (cur_devices) {
1497 head = &cur_devices->devices;
1498 list_for_each_entry(dev, head, dev_list) {
1499 if (!first_dev || dev->devid < first_dev->devid)
1500 first_dev = dev;
1501 }
1502 cur_devices = cur_devices->seed;
1503 }
1504
1505 if (first_dev) {
1506 rcu_read_lock();
1507 name = rcu_dereference(first_dev->name);
1508 seq_escape(m, name->str, " \t\n\\");
1509 rcu_read_unlock();
1510 } else {
1511 WARN_ON(1);
1512 }
1513 mutex_unlock(&fs_info->fs_devices->device_list_mutex);
1514 return 0;
1515}
1516
1485static const struct super_operations btrfs_super_ops = { 1517static const struct super_operations btrfs_super_ops = {
1486 .drop_inode = btrfs_drop_inode, 1518 .drop_inode = btrfs_drop_inode,
1487 .evict_inode = btrfs_evict_inode, 1519 .evict_inode = btrfs_evict_inode,
1488 .put_super = btrfs_put_super, 1520 .put_super = btrfs_put_super,
1489 .sync_fs = btrfs_sync_fs, 1521 .sync_fs = btrfs_sync_fs,
1490 .show_options = btrfs_show_options, 1522 .show_options = btrfs_show_options,
1523 .show_devname = btrfs_show_devname,
1491 .write_inode = btrfs_write_inode, 1524 .write_inode = btrfs_write_inode,
1492 .dirty_inode = btrfs_fs_dirty_inode, 1525 .dirty_inode = btrfs_fs_dirty_inode,
1493 .alloc_inode = btrfs_alloc_inode, 1526 .alloc_inode = btrfs_alloc_inode,