Skip to content

Commit e8fe0d4

Browse files
committed
Merge patch series "fs: last of the pseudofs mount api conversions"
Eric Sandeen <[email protected]> says: pstore used mount_single, which used to transparently do a remount operation on a fresh mount of an existing superblock. The new get_tree_single does not do this, but prior discussion on fsdevel seems to indicate that this isn't expected to be a problem. We can watch for issues. devpts is just a forward port from work dhowells did already, and it seems straightforward. I left error messages as they are rather than converting to the mount API message channel for now. devtmpfs was already converted, but left a .mount in place, rather than using .get_tree. The solution to this is ... unique so some scrutiny is probably wise. The last patch removes reconfigure_single, mount_single, and compare_single because no users remain, but we could also wait until all conversions are done, and remove all infrastructure at that time instead, if desired. * patches from https://lore.kernel.org/r/[email protected]: vfs: remove some unused old mount api code devtmpfs: replace ->mount with ->get_tree in public instance vfs: Convert devpts to use the new mount API pstore: convert to the new mount API Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents 2014c95 + bdfa77e commit e8fe0d4

File tree

6 files changed

+248
-253
lines changed

6 files changed

+248
-253
lines changed

drivers/base/devtmpfs.c

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,6 @@ __setup("devtmpfs.mount=", mount_param);
6363

6464
static struct vfsmount *mnt;
6565

66-
static struct dentry *public_dev_mount(struct file_system_type *fs_type, int flags,
67-
const char *dev_name, void *data)
68-
{
69-
struct super_block *s = mnt->mnt_sb;
70-
int err;
71-
72-
atomic_inc(&s->s_active);
73-
down_write(&s->s_umount);
74-
err = reconfigure_single(s, flags, data);
75-
if (err < 0) {
76-
deactivate_locked_super(s);
77-
return ERR_PTR(err);
78-
}
79-
return dget(s->s_root);
80-
}
81-
8266
static struct file_system_type internal_fs_type = {
8367
.name = "devtmpfs",
8468
#ifdef CONFIG_TMPFS
@@ -89,9 +73,40 @@ static struct file_system_type internal_fs_type = {
8973
.kill_sb = kill_litter_super,
9074
};
9175

76+
/* Simply take a ref on the existing mount */
77+
static int devtmpfs_get_tree(struct fs_context *fc)
78+
{
79+
struct super_block *sb = mnt->mnt_sb;
80+
81+
atomic_inc(&sb->s_active);
82+
down_write(&sb->s_umount);
83+
fc->root = dget(sb->s_root);
84+
return 0;
85+
}
86+
87+
/* Ops are filled in during init depending on underlying shmem or ramfs type */
88+
struct fs_context_operations devtmpfs_context_ops = {};
89+
90+
/* Call the underlying initialization and set to our ops */
91+
static int devtmpfs_init_fs_context(struct fs_context *fc)
92+
{
93+
int ret;
94+
#ifdef CONFIG_TMPFS
95+
ret = shmem_init_fs_context(fc);
96+
#else
97+
ret = ramfs_init_fs_context(fc);
98+
#endif
99+
if (ret < 0)
100+
return ret;
101+
102+
fc->ops = &devtmpfs_context_ops;
103+
104+
return 0;
105+
}
106+
92107
static struct file_system_type dev_fs_type = {
93108
.name = "devtmpfs",
94-
.mount = public_dev_mount,
109+
.init_fs_context = devtmpfs_init_fs_context,
95110
};
96111

97112
static int devtmpfs_submit_req(struct req *req, const char *tmp)
@@ -442,6 +457,31 @@ static int __ref devtmpfsd(void *p)
442457
return 0;
443458
}
444459

460+
/*
461+
* Get the underlying (shmem/ramfs) context ops to build ours
462+
*/
463+
static int devtmpfs_configure_context(void)
464+
{
465+
struct fs_context *fc;
466+
467+
fc = fs_context_for_reconfigure(mnt->mnt_root, mnt->mnt_sb->s_flags,
468+
MS_RMT_MASK);
469+
if (IS_ERR(fc))
470+
return PTR_ERR(fc);
471+
472+
/* Set up devtmpfs_context_ops based on underlying type */
473+
devtmpfs_context_ops.free = fc->ops->free;
474+
devtmpfs_context_ops.dup = fc->ops->dup;
475+
devtmpfs_context_ops.parse_param = fc->ops->parse_param;
476+
devtmpfs_context_ops.parse_monolithic = fc->ops->parse_monolithic;
477+
devtmpfs_context_ops.get_tree = &devtmpfs_get_tree;
478+
devtmpfs_context_ops.reconfigure = fc->ops->reconfigure;
479+
480+
put_fs_context(fc);
481+
482+
return 0;
483+
}
484+
445485
/*
446486
* Create devtmpfs instance, driver-core devices will add their device
447487
* nodes here.
@@ -456,6 +496,13 @@ int __init devtmpfs_init(void)
456496
pr_err("unable to create devtmpfs %ld\n", PTR_ERR(mnt));
457497
return PTR_ERR(mnt);
458498
}
499+
500+
err = devtmpfs_configure_context();
501+
if (err) {
502+
pr_err("unable to configure devtmpfs type %d\n", err);
503+
return err;
504+
}
505+
459506
err = register_filesystem(&dev_fs_type);
460507
if (err) {
461508
pr_err("unable to register devtmpfs type %d\n", err);

0 commit comments

Comments
 (0)