[AV - unfuck kern_mount_data(); we want non-NULL ->mnt_ns on long-living mounts] [AV - reordering fs/namespace.c is badly overdue, but let's keep it separate from that series] [AV - drop simple_pin_fs() change] [AV - clean vfs_kern_mount() failure exits up] Implement a filesystem context concept to be used during superblock creation for mount and superblock reconfiguration for remount. The mounting procedure then becomes: (1) Allocate new fs_context context. (2) Configure the context. (3) Create superblock. (4) Query the superblock. (5) Create a mount for the superblock. (6) Destroy the context. Rather than calling fs_type->mount(), an fs_context struct is created and fs_type->init_fs_context() is called to set it up. Pointers exist for the filesystem and LSM to hang their private data off. A set of operations has to be set by ->init_fs_context() to provide freeing, duplication, option parsing, binary data parsing, validation, mounting and superblock filling. Legacy filesystems are supported by the provision of a set of legacy fs_context operations that build up a list of mount options and then invoke fs_type->mount() from within the fs_context ->get_tree() operation. This allows all filesystems to be accessed using fs_context. It should be noted that, whilst this patch adds a lot of lines of code, there is quite a bit of duplication with existing code that can be eliminated should all filesystems be converted over.
Showing the changes to include/linux (2 of 5 files). Show all
Unified · Split
| @@ -62,6 +62,7 @@ struct iov_iter; · 61 unmodified lines | ||
| 62 | 62 | struct fscrypt_info; |
| 63 | 63 | struct fscrypt_operations; |
| 64 | 64 | struct fs_context; |
| 65 | +struct fs_parameter_description; | |
| 65 | 66 | |
| 66 | 67 | extern void __init inode_init(void); |
| 67 | 68 | extern void __init inode_init_early(void); |
| @@ -2175,6 +2176,7 @@ struct file_system_type { · 2107 unmodified lines | ||
| 2175 | 2176 | #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ |
| 2176 | 2177 | #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ |
| 2177 | 2178 | int (*init_fs_context)(struct fs_context *); |
| 2179 | + const struct fs_parameter_description *parameters; | |
| 2178 | 2180 | struct dentry *(*mount) (struct file_system_type *, int, |
| 2179 | 2181 | const char *, void *); |
| 2180 | 2182 | void (*kill_sb) (struct super_block *); |
| @@ -92,6 +92,7 @@ struct fs_context { · 91 unmodified lines | ||
| 92 | 92 | |
| 93 | 93 | struct fs_context_operations { |
| 94 | 94 | void (*free)(struct fs_context *fc); |
| 95 | + int (*parse_param)(struct fs_context *fc, struct fs_parameter *param); | |
| 95 | 96 | int (*parse_monolithic)(struct fs_context *fc, void *data); |
| 96 | 97 | int (*get_tree)(struct fs_context *fc); |
| 97 | 98 | int (*reconfigure)(struct fs_context *fc); |
| @@ -108,6 +109,10 @@ extern struct fs_context *fs_context_for_reconfigure(struct dentry *dentry, · 10 unmodified lines | ||
| 108 | 109 | extern struct fs_context *fs_context_for_submount(struct file_system_type *fs_type, |
| 109 | 110 | struct dentry *reference); |
| 110 | 111 | |
| 112 | +extern int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param); | |
| 113 | +extern int vfs_parse_fs_string(struct fs_context *fc, const char *key, | |
| 114 | + const char *value, size_t v_size); | |
| 115 | +extern int generic_parse_monolithic(struct fs_context *fc, void *data); | |
| 111 | 116 | extern int vfs_get_tree(struct fs_context *fc); |
| 112 | 117 | extern void put_fs_context(struct fs_context *fc); |
| 113 | 118 | |