Skip to content

Commit 39a6c66

Browse files
Bill O'Donnellbrauner
authored andcommitted
efs: convert efs to use the new mount api
Convert the efs filesystem to use the new mount API. Signed-off-by: Bill O'Donnell <bodonnel@redhat.com> Link: https://lore.kernel.org/r/20240220003318.166143-1-bodonnel@redhat.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent ddb9fd7 commit 39a6c66

1 file changed

Lines changed: 84 additions & 30 deletions

File tree

fs/efs/super.c

Lines changed: 84 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,14 @@
1414
#include <linux/buffer_head.h>
1515
#include <linux/vfs.h>
1616
#include <linux/blkdev.h>
17-
17+
#include <linux/fs_context.h>
18+
#include <linux/fs_parser.h>
1819
#include "efs.h"
1920
#include <linux/efs_vh.h>
2021
#include <linux/efs_fs_sb.h>
2122

2223
static int efs_statfs(struct dentry *dentry, struct kstatfs *buf);
23-
static int efs_fill_super(struct super_block *s, void *d, int silent);
24-
25-
static struct dentry *efs_mount(struct file_system_type *fs_type,
26-
int flags, const char *dev_name, void *data)
27-
{
28-
return mount_bdev(fs_type, flags, dev_name, data, efs_fill_super);
29-
}
24+
static int efs_init_fs_context(struct fs_context *fc);
3025

3126
static void efs_kill_sb(struct super_block *s)
3227
{
@@ -35,15 +30,6 @@ static void efs_kill_sb(struct super_block *s)
3530
kfree(sbi);
3631
}
3732

38-
static struct file_system_type efs_fs_type = {
39-
.owner = THIS_MODULE,
40-
.name = "efs",
41-
.mount = efs_mount,
42-
.kill_sb = efs_kill_sb,
43-
.fs_flags = FS_REQUIRES_DEV,
44-
};
45-
MODULE_ALIAS_FS("efs");
46-
4733
static struct pt_types sgi_pt_types[] = {
4834
{0x00, "SGI vh"},
4935
{0x01, "SGI trkrepl"},
@@ -63,6 +49,27 @@ static struct pt_types sgi_pt_types[] = {
6349
{0, NULL}
6450
};
6551

52+
enum {
53+
Opt_explicit_open,
54+
};
55+
56+
static const struct fs_parameter_spec efs_param_spec[] = {
57+
fsparam_flag ("explicit-open", Opt_explicit_open),
58+
{}
59+
};
60+
61+
/*
62+
* File system definition and registration.
63+
*/
64+
static struct file_system_type efs_fs_type = {
65+
.owner = THIS_MODULE,
66+
.name = "efs",
67+
.kill_sb = efs_kill_sb,
68+
.fs_flags = FS_REQUIRES_DEV,
69+
.init_fs_context = efs_init_fs_context,
70+
.parameters = efs_param_spec,
71+
};
72+
MODULE_ALIAS_FS("efs");
6673

6774
static struct kmem_cache * efs_inode_cachep;
6875

@@ -108,18 +115,10 @@ static void destroy_inodecache(void)
108115
kmem_cache_destroy(efs_inode_cachep);
109116
}
110117

111-
static int efs_remount(struct super_block *sb, int *flags, char *data)
112-
{
113-
sync_filesystem(sb);
114-
*flags |= SB_RDONLY;
115-
return 0;
116-
}
117-
118118
static const struct super_operations efs_superblock_operations = {
119119
.alloc_inode = efs_alloc_inode,
120120
.free_inode = efs_free_inode,
121121
.statfs = efs_statfs,
122-
.remount_fs = efs_remount,
123122
};
124123

125124
static const struct export_operations efs_export_ops = {
@@ -249,26 +248,26 @@ static int efs_validate_super(struct efs_sb_info *sb, struct efs_super *super) {
249248
return 0;
250249
}
251250

252-
static int efs_fill_super(struct super_block *s, void *d, int silent)
251+
static int efs_fill_super(struct super_block *s, struct fs_context *fc)
253252
{
254253
struct efs_sb_info *sb;
255254
struct buffer_head *bh;
256255
struct inode *root;
257256

258-
sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
257+
sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
259258
if (!sb)
260259
return -ENOMEM;
261260
s->s_fs_info = sb;
262261
s->s_time_min = 0;
263262
s->s_time_max = U32_MAX;
264-
263+
265264
s->s_magic = EFS_SUPER_MAGIC;
266265
if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
267266
pr_err("device does not support %d byte blocks\n",
268267
EFS_BLOCKSIZE);
269268
return -EINVAL;
270269
}
271-
270+
272271
/* read the vh (volume header) block */
273272
bh = sb_bread(s, 0);
274273

@@ -294,7 +293,7 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
294293
pr_err("cannot read superblock\n");
295294
return -EIO;
296295
}
297-
296+
298297
if (efs_validate_super(sb, (struct efs_super *) bh->b_data)) {
299298
#ifdef DEBUG
300299
pr_warn("invalid superblock at block %u\n",
@@ -328,6 +327,61 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
328327
return 0;
329328
}
330329

330+
static void efs_free_fc(struct fs_context *fc)
331+
{
332+
kfree(fc->fs_private);
333+
}
334+
335+
static int efs_get_tree(struct fs_context *fc)
336+
{
337+
return get_tree_bdev(fc, efs_fill_super);
338+
}
339+
340+
static int efs_parse_param(struct fs_context *fc, struct fs_parameter *param)
341+
{
342+
int token;
343+
struct fs_parse_result result;
344+
345+
token = fs_parse(fc, efs_param_spec, param, &result);
346+
if (token < 0)
347+
return token;
348+
return 0;
349+
}
350+
351+
static int efs_reconfigure(struct fs_context *fc)
352+
{
353+
sync_filesystem(fc->root->d_sb);
354+
355+
return 0;
356+
}
357+
358+
struct efs_context {
359+
unsigned long s_mount_opts;
360+
};
361+
362+
static const struct fs_context_operations efs_context_opts = {
363+
.parse_param = efs_parse_param,
364+
.get_tree = efs_get_tree,
365+
.reconfigure = efs_reconfigure,
366+
.free = efs_free_fc,
367+
};
368+
369+
/*
370+
* Set up the filesystem mount context.
371+
*/
372+
static int efs_init_fs_context(struct fs_context *fc)
373+
{
374+
struct efs_context *ctx;
375+
376+
ctx = kzalloc(sizeof(struct efs_context), GFP_KERNEL);
377+
if (!ctx)
378+
return -ENOMEM;
379+
fc->fs_private = ctx;
380+
fc->ops = &efs_context_opts;
381+
382+
return 0;
383+
}
384+
331385
static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) {
332386
struct super_block *sb = dentry->d_sb;
333387
struct efs_sb_info *sbi = SUPER_INFO(sb);

0 commit comments

Comments
 (0)