forked from Minki/linux
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>
This commit is contained in:
parent
606686eeac
commit
9c5085c147
@ -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>
|
||||
@ -1482,12 +1483,44 @@ static void btrfs_fs_dirty_inode(struct inode *inode, int flags)
|
||||
"error %d\n", btrfs_ino(inode), ret);
|
||||
}
|
||||
|
||||
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,
|
||||
.dirty_inode = btrfs_fs_dirty_inode,
|
||||
.alloc_inode = btrfs_alloc_inode,
|
||||
|
Loading…
Reference in New Issue
Block a user