History

vfs: Implement a filesystem superblock creation/configuration context

[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.

David Howells committed 8 years ago

Commit 3e1aeb01 parent 846e5665 files · +319 −17Browse files

Showing the changes to include/linux (2 of 5 files). Show all

Unified · Split

2 files
  1. include/linux/fs.h +2 −0
  2. include/linux/fs_context.h +5 −0
include/linux/fs.h+2−0
@@ -62,6 +62,7 @@ struct iov_iter; · 61 unmodified lines
62struct fscrypt_info;62struct fscrypt_info;
63struct fscrypt_operations;63struct fscrypt_operations;
64struct fs_context;64struct fs_context;
65struct fs_parameter_description;
65 66
66extern void __init inode_init(void);67extern void __init inode_init(void);
67extern void __init inode_init_early(void);68extern void __init inode_init_early(void);
@@ -2175,6 +2176,7 @@ struct file_system_type { · 2107 unmodified lines
2175#define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */2176#define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */
2176#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */2177#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
2177 int (*init_fs_context)(struct fs_context *);2178 int (*init_fs_context)(struct fs_context *);
2179 const struct fs_parameter_description *parameters;
2178 struct dentry *(*mount) (struct file_system_type *, int,2180 struct dentry *(*mount) (struct file_system_type *, int,
2179 const char *, void *);2181 const char *, void *);
2180 void (*kill_sb) (struct super_block *);2182 void (*kill_sb) (struct super_block *);
include/linux/fs_context.h+5−0
@@ -92,6 +92,7 @@ struct fs_context { · 91 unmodified lines
92 92
93struct fs_context_operations {93struct fs_context_operations {
94 void (*free)(struct fs_context *fc);94 void (*free)(struct fs_context *fc);
95 int (*parse_param)(struct fs_context *fc, struct fs_parameter *param);
95 int (*parse_monolithic)(struct fs_context *fc, void *data);96 int (*parse_monolithic)(struct fs_context *fc, void *data);
96 int (*get_tree)(struct fs_context *fc);97 int (*get_tree)(struct fs_context *fc);
97 int (*reconfigure)(struct fs_context *fc);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
108extern struct fs_context *fs_context_for_submount(struct file_system_type *fs_type,109extern struct fs_context *fs_context_for_submount(struct file_system_type *fs_type,
109 struct dentry *reference);110 struct dentry *reference);
110 111
112extern int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param);
113extern int vfs_parse_fs_string(struct fs_context *fc, const char *key,
114 const char *value, size_t v_size);
115extern int generic_parse_monolithic(struct fs_context *fc, void *data);
111extern int vfs_get_tree(struct fs_context *fc);116extern int vfs_get_tree(struct fs_context *fc);
112extern void put_fs_context(struct fs_context *fc);117extern void put_fs_context(struct fs_context *fc);
113 118

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t