fs/fsconfig: handle FSCONFIG_CMD_RECONFIGURE
Subsystems (12)
PATCH 1/2 fs/fsconfig: handle FSCONFIG_CMD_RECONFIGURE
From: Andrei Vagin <[email protected]>
It looks like everything is already prepared for that and we only need to call do_remount_sb() to apply changes from fs_context.
--- fs/fsopen.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
fs/fsopen.c +18 -0
@@ -273,7 +273,25 @@ static int vfs_fsconfig_action(struct fs_context *fc, enum fsconfig_command cmd)else fc->phase =FS_CONTEXT_FAILED ;return ret; +case FSCONFIG_CMD_RECONFIGURE : + { +struct super_block *sb; + +if (fc->phase !=FS_CONTEXT_RECONF_PARAMS ) +return -EBUSY ; + fc->phase =FS_CONTEXT_RECONFIGURING ; + sb = fc->root->d_sb; +down_write (&sb->s_umount); + ret =do_remount_sb (sb,0 ,NULL ,0 ,0 , fc); +up_write (&sb->s_umount); + +if (ret ==0 ) + fc->phase =FS_CONTEXT_CREATE_PARAMS ; +else + fc->phase =FS_CONTEXT_FAILED ; +return ret; + }default :return -EOPNOTSUPP ; }
Signature · 1 line
2.17.1
David Howells
maintainerQuoted 2 lines · Andrei Vagin
It looks like everything is already prepared for that and we only need to call
do_remount_sb()to apply changes fromfs_context.
It's not as simple as that, and your patch is incorrect in the phase transition and doesn't parameterise legacy reconfiguration correctly.
I've attached the patch I posted yesterday. Note there are a couple of bugs in here that I haven't rolled the fixes back into yet as I'm in the middle of building some other patches on top of it.
But thanks for having a go!
David
---
vfs: Use fs_context for reconfig and implement FSCONFIG_CMD_RECONFIGURE
Implement fs_context-based reconfiguration by the following means:
(1) Provide two more internal fs_context purposes: umount that actually reconfigures to R/O and emergency reconfiguration to R/O. This tells the filesystem if it the context hasn't been fully initialised.
(2) Track which bits in sb_mask have been changed in addition to what they've been changed to.
(3) Move ->reconfigure() from the superblock ops to the fs_context ops.
This makes (4) possible. The ->remount_fs() superblock op is
obsolete.(4) Provide a legacy wrapper for ->reconfigure().
(5) Make a do_umount() that's unmounting a root allocate an fs_context on the stack and use that to reconfigure to R/O.
(6) Make do_emergency_remount_callback() allocate an fs_context on the stack and use that to reconfigurate to R/O.
(6) Make do_remount() unconditionally use an fs_context to invoke
do_remount_sb().
(7) Only pass in a filesystem context to do_remount_sb(). This, along with (4), allows the function to be simplified.
(8) Pass errors back from mount_single() if reconfiguration fails. We might want this behaviour to be conditional, depending on which mount API was used.
(9) Delete security_sb_remount().
(10) Rename do_remount_sb() to reconfigure_super().
Notes:
(1) do_remount() can't make use of vfs_reconfigure_sb() if the former changes the mount attributes atomically or if the latter doesn't do so at all.
However, since I think Al wants us to move towards separating superblock reconfiguration from mountpoint reconfiguration, there may not be a need to do this atomically.
(2) mount_single() probably shouldn't reconfigure an already existing superblock if it's supposed to be creating a new one, but rather it (or, rather, the filesystem) should compare the parameters and either return the live superblock if the params are the same or return an error if not.
However, this probably needs to be contingent on the mount API or something so as not to break userspace.
(3) I should add something like an FSOPEN_EXCL flag to tell sget_fc() to fail if the superblock already exists at all and an FSOPEN_FAIL_ON_MISMATCH flag to explicitly say that we *don't* want a superblock with different parameters. The implication of providing neither flag is that we are happy to accept a superblock from the same source but with different parameters.
--- Documentation/filesystems/mount_api.txt | 56 +++++++------- fs/afs/mntpt.c | 2 fs/afs/super.c | 2 fs/fs_context.c | 46 ++++++----- fs/fsopen.c | 84 +++++++++++++++++++-- fs/hugetlbfs/inode.c | 2 fs/internal.h | 9 +- fs/kernfs/mount.c | 5 - fs/libfs.c | 3 fs/namespace.c | 87 +++++++++------------- fs/nfs/super.c | 2 fs/proc/inode.c | 1 fs/proc/internal.h | 1 fs/proc/root.c | 6 + fs/super.c | 125 ++++++++++++++++++++------------ include/linux/fs.h | 1 include/linux/fs_context.h | 8 +- include/linux/kernfs.h | 1 include/linux/lsm_hooks.h | 9 -- include/linux/security.h | 6 - ipc/mqueue.c | 2 kernel/cgroup/cgroup.c | 2 kernel/cgroup/cpuset.c | 3 security/security.c | 5 - security/selinux/hooks.c | 1 25 files changed, 283 insertions(+), 186 deletions(-)
Documentation/filesystems/mount_api.txt +30 -26
@@ -55,16 +55,6 @@ purposes - otherwise it will be NULL. Note that security initialisation is done *after* the filesystem is called so that the namespaces may be adjusted first. -And the super_operations struct gains one field: - - int (*reconfigure)(struct super_block *, struct fs_context *); - -This shadows the ->reconfigure() operation and takes a prepared filesystem -context instead of the mount flags and data page. It may modify the sb_flags -in the context for the caller to pick up. - -[NOTE] reconfigure is intended as a replacement for remount_fs. - ====================== THE FILESYSTEM CONTEXT
@@ -86,6 +76,7 @@ context. This is represented by the fs_context structure: void *security; void *s_fs_info; unsigned int sb_flags; + unsigned int sb_flags_mask; enum fs_context_purpose purpose:8; bool sloppy:1; bool silent:1;
@@ -150,8 +141,9 @@ The fs_context fields are as follows: sget_fc(). This can be used to distinguish superblocks. (*) unsigned int sb_flags + (*) unsigned int sb_flags_mask - This holds the SB_* flags to be set in super_block::s_flags. + Which bits SB_* flags are to be set/cleared in super_block::s_flags. (*) enum fs_context_purpose
@@ -162,6 +154,10 @@ The fs_context fields are as follows: FS_CONTEXT_FOR_KERNEL_MOUNT, -- New superblock for kernel-internal mount FS_CONTEXT_FOR_SUBMOUNT -- New automatic submount of extant mount FS_CONTEXT_FOR_RECONFIGURE -- Change an existing mount + FS_CONTEXT_FOR_UMOUNT -- Reconfigure to R/O for umount() + FS_CONTEXT_FOR_EMERGENCY_RO -- Emergency reconfigure to R/O + + In the last two cases, ->init_fs_context() will not have been called. (*) bool sloppy (*) bool silent
@@ -174,8 +170,8 @@ The fs_context fields are as follows: [NOTE] silent is probably redundant with sb_flags & SB_SILENT. -The mount context is created by calling vfs_new_fs_context(), vfs_sb_reconfig() -or vfs_dup_fs_context() and is destroyed with put_fs_context(). Note that the +The mount context is created by calling vfs_new_fs_context() or +vfs_dup_fs_context() and is destroyed with put_fs_context(). Note that the structure is not refcounted. VFS, security and filesystem mount options are set individually with
@@ -206,6 +202,7 @@ The filesystem context points to a table of operations: size_t data_size); int (*validate)(struct fs_context *fc); int (*get_tree)(struct fs_context *fc); + int (*reconfigure)(struct fs_context *fc); }; These operations are invoked by the various stages of the mount procedure to
@@ -278,6 +275,18 @@ manage the filesystem context. They are as follows: The phase on a userspace-driven context will be set to only allow this to be called once on any particular context. + (*) int (*reconfigure)(struct fs_context *fc); + + Called to effect reconfiguration of a superblock using information stored + in the filesystem context. It may detach any resources it desires from + the filesystem context and transfer them to the superblock. The + superblock can be found from fc->root->d_sb. + + On success it should return 0. In the case of an error, it should return + a negative error code. + + [NOTE] reconfigure is intended as a replacement for remount_fs. + =========================== FILESYSTEM CONTEXT SECURITY
@@ -358,24 +367,19 @@ one for destroying a context: (*) struct fs_context *vfs_new_fs_context(struct file_system_type *fs_type, struct dentry *reference, unsigned int sb_flags, + unsigned int sb_flags_mask, enum fs_context_purpose purpose); Create a filesystem context for a given filesystem type and purpose. This - allocates the filesystem context, sets the flags, initialises the security - and calls fs_type->init_fs_context() to initialise the filesystem private - data. + allocates the filesystem context, sets the superblock flags, initialises + the security and calls fs_type->init_fs_context() to initialise the + filesystem private data. reference can be NULL or it may indicate the root dentry of a superblock - that is going to be reconfigured (FS_CONTEXT_FOR_RECONFIGURE) or the - automount point that triggered a submount (FS_CONTEXT_FOR_SUBMOUNT). This - is provided as a source of namespace information. - - (*) struct fs_context *vfs_sb_reconfig(struct vfsmount *mnt, - unsigned int sb_flags); - - Create a filesystem context from the same filesystem as an extant mount - and initialise the mount parameters from the superblock underlying that - mount. This is for use by superblock parameter reconfiguration. + that is going to be reconfigured (FS_CONTEXT_FOR_RECONFIGURE, + FS_CONTEXT_FOR_UMOUNT or FS_CONTEXT_FOR_EMERGENCY_RO) or the automount + point that triggered a submount (FS_CONTEXT_FOR_SUBMOUNT). This is + provided as a source of namespace information. (*) struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc);
fs/afs/mntpt.c +1 -1
@@ -147,7 +147,7 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)BUG_ON (!d_inode (mntpt)); - fc =vfs_new_fs_context (&afs_fs_type, mntpt,0 , + fc =vfs_new_fs_context (&afs_fs_type, mntpt,0 ,0 ,FS_CONTEXT_FOR_SUBMOUNT );if (IS_ERR (fc))return ERR_CAST (fc);
fs/afs/super.c +1 -1
@@ -634,7 +634,7 @@ static int afs_init_fs_context(struct fs_context *fc, struct dentry *reference) }break ; -case FS_CONTEXT_FOR_RECONFIGURE : +default :break ; }
fs/fs_context.c +24 -22
100 lines not on this page · raw message
fs/fsopen.c +78 -6
109 lines not on this page · raw message
fs/hugetlbfs/inode.c +1 -1
@@ -1510,7 +1510,7 @@ static struct vfsmount *__init mount_one_hugetlbfs(struct hstate *h)struct vfsmount *mnt;int ret; - fc =vfs_new_fs_context (&hugetlbfs_fs_type,NULL ,0 , + fc =vfs_new_fs_context (&hugetlbfs_fs_type,NULL ,0 ,0 ,FS_CONTEXT_FOR_KERNEL_MOUNT );if (IS_ERR (fc)) { ret =PTR_ERR (fc);
fs/internal.h +7 -2
@@ -54,6 +54,11 @@ extern void __init chrdev_init(void);*/ extern const struct fs_context_operations legacy_fs_context_ops; +/* +* fsopen.c +*/ +extern void vfs_clean_context (struct fs_context *fc); +/* * namei.c */
@@ -77,6 +82,7 @@ int do_linkat(int olddfd, const char __user *oldname, int newdfd,*/ extern void *copy_mount_options (const void __user *);extern char *copy_mount_string (const void __user *); +extern int parse_monolithic_mount_data (struct fs_context *,void *,size_t );extern struct vfsmount *lookup_mnt (const struct path *);extern int finish_automount (struct vfsmount *,struct path *);
@@ -106,8 +112,7 @@ extern struct file *get_empty_filp(void);/* * super.c */ -extern int do_remount_sb (struct super_block *,int ,void *,size_t ,int , -struct fs_context *); +extern int reconfigure_super (struct fs_context *);extern bool trylock_super (struct super_block *sb);extern struct super_block *user_get_super (dev_t );
fs/kernfs/mount.c +2 -3
@@ -23,9 +23,9 @@struct kmem_cache *kernfs_node_cache; -static int kernfs_sop_reconfigure (struct super_block *sb,struct fs_context *fc) +int kernfs_reconfigure (struct fs_context *fc) { -struct kernfs_root *root =kernfs_info (sb)->root; +struct kernfs_root *root =kernfs_info (fc->root->d_sb)->root;struct kernfs_syscall_ops *scops = root->syscall_ops;if (scops && scops->reconfigure)
@@ -75,7 +75,6 @@ const struct super_operations kernfs_sops = { .drop_inode = generic_delete_inode, .evict_inode = kernfs_evict_inode, - .reconfigure = kernfs_sop_reconfigure, .show_options = kernfs_sop_show_options, .show_path = kernfs_sop_show_path, .get_fsinfo = kernfs_sop_get_fsinfo,
fs/libfs.c +2 -1
@@ -583,7 +583,8 @@ int simple_pin_fs(struct file_system_type *type, struct vfsmount **mount, int *cif (unlikely (!*mount)) {spin_unlock (&pin_fs_lock); - fc =vfs_new_fs_context (type,NULL ,0 ,FS_CONTEXT_FOR_KERNEL_MOUNT ); + fc =vfs_new_fs_context (type,NULL ,0 ,0 , +FS_CONTEXT_FOR_KERNEL_MOUNT );if (IS_ERR (fc))return PTR_ERR (fc);
fs/namespace.c +39 -48
148 lines not on this page · raw message
fs/nfs/super.c +1 -1
@@ -2296,7 +2296,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data, size_t data_size/* * noac is a special case. It implies -o sync, but that's not -* necessarily reflected in the mtab options. do_remount_sb +* necessarily reflected in the mtab options. reconfigure_super * will clear SB_SYNCHRONOUS if -o sync wasn't specified in the * remount options, so we have to explicitly reset it. */
fs/proc/inode.c +0 -1
@@ -127,7 +127,6 @@ const struct super_operations proc_sops = { .drop_inode = generic_delete_inode, .evict_inode = proc_evict_inode, .statfs = simple_statfs, - .reconfigure = proc_reconfigure, .show_options = proc_show_options, };
fs/proc/internal.h +0 -1
@@ -273,7 +273,6 @@ static inline void proc_tty_init(void) {}extern struct proc_dir_entry proc_root;extern void proc_self_init (void ); -extern int proc_reconfigure (struct super_block *,struct fs_context *);/* * task_[no]mmu.c
fs/proc/root.c +4 -2
@@ -148,8 +148,9 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc)return proc_setup_thread_self (s); } -int proc_reconfigure (struct super_block *sb,struct fs_context *fc) +static int proc_reconfigure (struct fs_context *fc) { +struct super_block *sb = fc->root->d_sb;struct pid_namespace *pid = sb->s_fs_info;sync_filesystem (sb);
@@ -180,6 +181,7 @@ static const struct fs_context_operations proc_fs_context_ops = { .free = proc_fs_context_free, .parse_param = proc_parse_param, .get_tree = proc_get_tree, + .reconfigure = proc_reconfigure, };static int proc_init_fs_context (struct fs_context *fc,struct dentry *reference)
@@ -310,7 +312,7 @@ int pid_ns_prepare_proc(struct pid_namespace *ns)struct vfsmount *mnt;int ret; - fc =vfs_new_fs_context (&proc_fs_type,NULL ,0 , + fc =vfs_new_fs_context (&proc_fs_type,NULL ,0 ,0 ,FS_CONTEXT_FOR_KERNEL_MOUNT );if (IS_ERR (fc))return PTR_ERR (fc);
fs/super.c +82 -43
193 lines not on this page · raw message
include/linux/fs.h +0 -1
@@ -1853,7 +1853,6 @@ struct super_operations {int (*statfs) (struct dentry *,struct kstatfs *);int (*get_fsinfo) (struct dentry *,struct fsinfo_kparams *);int (*remount_fs) (struct super_block *,int *,char *,size_t ); -int (*reconfigure) (struct super_block *,struct fs_context *);void (*umount_begin) (struct super_block *);int (*show_options)(struct seq_file *,struct dentry *);
include/linux/fs_context.h +6 -2
@@ -34,6 +34,8 @@ enum fs_context_purpose {FS_CONTEXT_FOR_KERNEL_MOUNT ,/* New superblock for kernel-internal mount */ FS_CONTEXT_FOR_SUBMOUNT ,/* New superblock for automatic submount */ FS_CONTEXT_FOR_RECONFIGURE ,/* Superblock reconfiguration (remount) */ +FS_CONTEXT_FOR_UMOUNT ,/* Reconfiguration to R/O for unmount */ + FS_CONTEXT_FOR_EMERGENCY_RO, /* Emergency reconfiguration to R/O */ };/*
@@ -102,6 +104,7 @@ struct fs_context {void *security;/* The LSM context */ void *s_fs_info;/* Proposed s_fs_info */ unsigned int sb_flags;/* Proposed superblock flags (SB_*) */ +unsigned int sb_flags_mask;/* Superblock flags that were changed */ enum fs_context_purpose purpose:8; enum fs_context_phase phase:8; /* The phase the context is in */ bool sloppy:1; /* T if unrecognised options are okay */
@@ -116,6 +119,7 @@ struct fs_context_operations {int (*parse_monolithic)(struct fs_context *fc,void *data,size_t data_size);int (*validate)(struct fs_context *fc);int (*get_tree)(struct fs_context *fc); +int (*reconfigure)(struct fs_context *fc); };/*
@@ -123,9 +127,9 @@ struct fs_context_operations {*/ extern struct fs_context *vfs_new_fs_context (struct file_system_type *fs_type,struct dentry *reference, -unsigned int ms_flags, +unsigned int sb_flags, +unsigned int sb_flags_mask,enum fs_context_purpose purpose); -extern struct fs_context *vfs_sb_reconfig (struct path *path,unsigned int ms_flags);extern struct fs_context *vfs_dup_fs_context (struct fs_context *src);extern int vfs_parse_fs_param (struct fs_context *fc,struct fs_parameter *param); extern int vfs_parse_fs_string(struct fs_context *fc, const char *key,
include/linux/kernfs.h +1 -0
@@ -370,6 +370,7 @@ int kernfs_get_tree(struct fs_context *fc);void kernfs_free_fs_context (struct fs_context *fc);void kernfs_kill_sb (struct super_block *sb);struct super_block *kernfs_pin_sb (struct kernfs_root *root,const void *ns); +int kernfs_reconfigure (struct fs_context *fc);void kernfs_init (void );
include/linux/lsm_hooks.h +0 -9
@@ -160,13 +160,6 @@* @orig_data is the size of the original data * @copy copied data which will be passed to the security module. * Returns 0 if the copy was successful. -* @sb_remount: -* Extracts security system specific mount options and verifies no changes -* are being made to those options. -* @sb superblock being remounted -* @data contains the filesystem-specific data. -* @data_size contains the size of the data. -* Return 0 if permission is granted. * @sb_umount: * Check permission before the @mnt file system is unmounted. * @mnt contains the mounted file system.
@@ -1518,7 +1511,6 @@ union security_list_options {int (*sb_alloc_security)(struct super_block *sb);void (*sb_free_security)(struct super_block *sb);int (*sb_copy_data)(char *orig,size_t orig_size,char *copy); -int (*sb_remount)(struct super_block *sb,void *data,size_t data_size);int (*sb_show_options)(struct seq_file *m,struct super_block *sb);int (*sb_statfs)(struct dentry *dentry); int (*sb_mount)(const char *dev_name, const struct path *path,
@@ -1865,7 +1857,6 @@ struct security_hook_heads {struct hlist_head sb_alloc_security;struct hlist_head sb_free_security;struct hlist_head sb_copy_data; -struct hlist_head sb_remount;struct hlist_head sb_show_options;struct hlist_head sb_statfs;struct hlist_head sb_mount;
include/linux/security.h +0 -6
@@ -240,7 +240,6 @@ int security_sb_mountpoint(struct fs_context *fc, struct path *mountpoint,int security_sb_alloc (struct super_block *sb);void security_sb_free (struct super_block *sb);int security_sb_copy_data (char *orig,size_t orig_size,char *copy); -int security_sb_remount (struct super_block *sb,void *data,size_t data_size);int security_sb_show_options (struct seq_file *m,struct super_block *sb);int security_sb_statfs (struct dentry *dentry); int security_sb_mount(const char *dev_name, const struct path *path,
@@ -585,11 +584,6 @@ static inline int security_sb_copy_data(char *orig, size_t orig_size, char *copyreturn 0 ; } -static inline int security_sb_remount (struct super_block *sb,void *data,size_t data_size) -{ -return 0 ; -} -static inline int security_sb_show_options (struct seq_file *m,struct super_block *sb) {
ipc/mqueue.c +1 -1
@@ -403,7 +403,7 @@ static struct vfsmount *mq_create_mount(struct ipc_namespace *ns)struct vfsmount *mnt;int ret; - fc =vfs_new_fs_context (&mqueue_fs_type,NULL ,0 , + fc =vfs_new_fs_context (&mqueue_fs_type,NULL ,0 ,0 ,FS_CONTEXT_FOR_KERNEL_MOUNT );if (IS_ERR (fc))return ERR_CAST (fc);
kernel/cgroup/cgroup.c +1 -1
@@ -2150,6 +2150,7 @@ static const struct fs_context_operations cgroup_fs_context_ops = { .parse_param = cgroup_parse_param, .validate = cgroup_validate, .get_tree = cgroup_get_tree, + .reconfigure = kernfs_reconfigure, };/*
@@ -5281,7 +5282,6 @@ int cgroup_rmdir(struct kernfs_node *kn)static struct kernfs_syscall_ops cgroup_kf_syscall_ops = { .show_options = cgroup_show_options, .fsinfo = cgroup_fsinfo, - .reconfigure = cgroup_reconfigure, .mkdir = cgroup_mkdir, .rmdir = cgroup_rmdir, .show_path = cgroup_show_path,
kernel/cgroup/cpuset.c +2 -1
@@ -327,7 +327,8 @@ static int cpuset_get_tree(struct fs_context *fc)if (!cgroup_fs) goto out; - cg_fc =vfs_new_fs_context (cgroup_fs,NULL , fc->sb_flags, fc->purpose); + cg_fc =vfs_new_fs_context (cgroup_fs,NULL , fc->sb_flags, fc->sb_flags, + fc->purpose);put_filesystem (cgroup_fs);if (IS_ERR (cg_fc)) { ret =PTR_ERR (cg_fc);
security/security.c +0 -5
@@ -415,11 +415,6 @@ int security_sb_copy_data(char *orig, size_t data_size, char *copy) }EXPORT_SYMBOL (security_sb_copy_data); -int security_sb_remount (struct super_block *sb,void *data,size_t data_size) -{ -return call_int_hook (sb_remount,0 , sb, data, data_size); -} -int security_sb_show_options (struct seq_file *m,struct super_block *sb) {return call_int_hook (sb_show_options,0 , m, sb);
security/selinux/hooks.c +0 -1
@@ -7180,7 +7180,6 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {LSM_HOOK_INIT (sb_alloc_security, selinux_sb_alloc_security),LSM_HOOK_INIT (sb_free_security, selinux_sb_free_security),LSM_HOOK_INIT (sb_copy_data, selinux_sb_copy_data), -LSM_HOOK_INIT (sb_remount, selinux_sb_remount),LSM_HOOK_INIT (sb_show_options, selinux_sb_show_options),LSM_HOOK_INIT (sb_statfs, selinux_sb_statfs), LSM_HOOK_INIT(sb_mount, selinux_mount),
PATCH 2/2 selftests: implement a test for a new mount API
From: Andrei Vagin <[email protected]>
Currently, a reconfigure call-back is implemented only for the proc file system. This test creates a new mount and pid namespace and then we can create a new proc mount instance and be sure that a host configuration will not be affected.
--- tools/testing/selftests/fsopen/Makefile | 5 + tools/testing/selftests/fsopen/config | 2 + tools/testing/selftests/fsopen/fsopen.c | 120 ++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 tools/testing/selftests/fsopen/Makefile create mode 100644 tools/testing/selftests/fsopen/config create mode 100644 tools/testing/selftests/fsopen/fsopen.c
tools/testing/selftests/fsopen/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) + +TEST_GEN_PROGS := fsopen + +include ../lib.mk
tools/testing/selftests/fsopen/config new file +2 -0
@@ -0,0 +1,2 @@ +CONFIG_PROC_FS=y +CONFIG_PID_NS=y
tools/testing/selftests/fsopen/fsopen.c new file +120 -0
120 lines not on this page · raw message
Signature · 1 line
2.17.1
David Howells
maintainerRe: [PATCH dhowells/mount-api 2/2] selftests: implement a test for a new mount API
Quoted 1 line · Andrei Vagin
+static const char dev[] = "s
test_fsopen_123";
Did you mean to prefix that with "s "?
tools/testing/selftests/fsopen/fsopen.c line 67
Quoted 2 lines
tools/testing/selftests/fsopen/fsopen.c new file +2
-0+if (sys_fsconfig (fsfd,FSCONFIG_SET_STRING ,"source" , dev,0 ) <0 ) +return pr_err ("fsconfig_set_string sets source = %s" , dev);
Note that it's not necessary to provide a source for /proc since it will just ignore it.
Anyway, thanks for doing this!
David
Re: [PATCH dhowells/mount-api 2/2] selftests: implement a test for a new mount API
In reply to Andrei VaginQuoted 8 lines · Andrei Vagin
From: Andrei Vagin <[email protected]>
Currently, a reconfigure call-back is implemented only for the proc file system. This test creates a new mount and pid namespace and then we can create a new proc mount instance and be sure that a host configuration will not be affected.
Signed-off-by Andrei Vagin <[email protected]>
Quoted 8 lines
--- tools/testing/selftests/fsopen/Makefile | 5 + tools/testing/selftests/fsopen/config | 2 + tools/testing/selftests/fsopen/fsopen.c | 120 ++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 tools/testing/selftests/fsopen/Makefile create mode 100644 tools/testing/selftests/fsopen/config create mode 100644 tools/testing/selftests/fsopen/fsopen.c
can we get all this test stuff put into fstests?
And then add a config option to the fstests mount commands so that they use the internal mount command to exercise the new API rather than use the existing mount binary?
That way every filesystem developer /will/ exercise the new mount API in lots of interesting and unusual ways that are expected to work (or not work, as fstests exercises failure cases, too) in their day-to-day testing and development. This will flush out the bugs and problems much, much faster than a small selftest in the kernel tree that doesn't really interact with the bulk of the code that runs when filesystems are mounted/remounted.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH dhowells/mount-api 2/2] selftests: implement a test for a new mount API
Quoted 5 lines · David Howells
Quoted 1 line · Andrei Vagin
+static const char dev[] = "s
test_fsopen_123";Did you mean to prefix that with "s "?
"s " means "source" here, it is an effect of a previous version of this interface
https://lwn.net/Articles/753473/
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ if (sys_fsconfig(fsfd, FSCONFIG_SET_STRING, "source", dev, 0) < 0) + return pr_err("fsconfig_set_string sets source = %s", dev);Note that it's not necessary to provide a source for /proc since it will just ignore it.
I haven't known this. Thanks. A sligtly updated patch is attached to this message.
Quoted 6 lines
Anyway, thanks for doing this!
David
From
0fb778c4189bc739c253d0a76830307ed6d3e1d4Mon Sep 17 00:00:00 2001
From: Andrei Vagin <[email protected]>
Date: Mon, 6 Aug 2018 19:33:16 -0700
Subject: [PATCH] selftests: implement a test for a new mount API
Currently, a reconfigure call-back is implemented only for the proc file system. This test creates a new mount and pid namespace and then we can create a new proc mount instance and be sure that a host configuration will not be affected.
--- tools/testing/selftests/fsopen/Makefile | 5 + tools/testing/selftests/fsopen/config | 2 + tools/testing/selftests/fsopen/fsopen.c | 132 ++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 tools/testing/selftests/fsopen/Makefile create mode 100644 tools/testing/selftests/fsopen/config create mode 100644 tools/testing/selftests/fsopen/fsopen.c
tools/testing/selftests/fsopen/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) + +TEST_GEN_PROGS := fsopen + +include ../lib.mk
tools/testing/selftests/fsopen/config new file +2 -0
@@ -0,0 +1,2 @@ +CONFIG_PROC_FS=y +CONFIG_PID_NS=y
tools/testing/selftests/fsopen/fsopen.c new file +132 -0
132 lines not on this page · raw message
Signature · 1 line
2.17.1
David Howells
maintainerRe: [PATCH dhowells/mount-api 2/2] selftests: implement a test for a new mount API
Quoted 8 lines · Andrei Vagin
Quoted 3 lines
Quoted 1 line
+static const char dev[] = "s
test_fsopen_123";Did you mean to prefix that with "s "?
"s " means "source" here, it is an effect of a previous version of this interface
Yeah, well Linus objected, so we're not using write() now. So the key string given to fsconfig() now indicates this information (ie. "source").
David