gfs2: Switch to the new mount API
Subsystems (2)
v2 cover gfs2: Switch to the new mount API
These patches convert gfs2 and gfs2meta to use fs_context.
Tested with xfstests -g quick, a bunch of targeted mount commands to exercise individual options, and gfs2_grow to test the gfs2meta mount.
v2: Use sget_fc() instead of sget()
Andrew Price (2):
gfs2: Convert gfs2 to fs_context
gfs2: Convert gfs2meta to fs_context
fs/gfs2/incore.h | 11 +- fs/gfs2/ops_fstype.c | 443 +++++++++++++++++++++++++++++++++++++------ fs/gfs2/super.c | 335 +------------------------------- fs/gfs2/super.h | 3 +- 4 files changed, 394 insertions(+), 398 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/2 gfs2: Convert gfs2 to fs_context
Switch to using fs_context ops for mount/remount.
--- fs/gfs2/incore.h | 11 +- fs/gfs2/ops_fstype.c | 405 ++++++++++++++++++++++++++++++++++++++----- fs/gfs2/super.c | 335 +---------------------------------- fs/gfs2/super.h | 3 +- 4 files changed, 370 insertions(+), 384 deletions(-)
fs/gfs2/incore.h +7 -4
@@ -587,10 +587,13 @@ struct gfs2_args { unsigned int ar_rgrplvb:1; /* use lvbs for rgrp info */ unsigned int ar_loccookie:1; /* use location based readdircookies */ -int ar_commit;/* Commit interval */ -int ar_statfs_quantum;/* The fast statfs interval */ -int ar_quota_quantum;/* The quota interval */ -int ar_statfs_percent;/* The % change to force sync */ +s32 ar_commit;/* Commit interval */ +s32 ar_statfs_quantum;/* The fast statfs interval */ +s32 ar_quota_quantum;/* The quota interval */ +s32 ar_statfs_percent;/* The % change to force sync */ + +/* This is just for propagating the bdev through sget_fc() */ +struct block_device *ar_bdev; };struct gfs2_tune {
fs/gfs2/ops_fstype.c +361 -44
489 lines not on this page · raw message
fs/gfs2/super.c +1 -334
359 lines not on this page · raw message
fs/gfs2/super.h +1 -2
@@ -27,8 +27,6 @@ static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp)extern void gfs2_jindex_free (struct gfs2_sbd *sdp); -extern int gfs2_mount_args (struct gfs2_args *args,char *data); -extern struct gfs2_jdesc *gfs2_jdesc_find (struct gfs2_sbd *sdp,unsigned int jid);extern int gfs2_jdesc_check (struct gfs2_jdesc *jd);
@@ -36,6 +34,7 @@ extern int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename, struct gfs2_inode **ipp);extern int gfs2_make_fs_rw (struct gfs2_sbd *sdp); +extern int gfs2_make_fs_ro (struct gfs2_sbd *sdp);extern void gfs2_online_uevent (struct gfs2_sbd *sdp);extern int gfs2_statfs_init (struct gfs2_sbd *sdp); extern void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
Signature · 1 line
2.20.1
Re: [PATCH v2 1/2] gfs2: Convert gfs2 to fs_context
Review
Quoted 2 lines · Andrew Price
(quoted diff) +2
-0+ pr_warn("-o debug and -o errors=panic are mutually exclusive\n"); + return -EINVAL;
return invalf(fc, "gfs2: -o debug and -o errors=panic are mutually exclusive");
(Note: no "\n")
fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, · line 1468
Quoted 6 lines
fs/gfs2/ops_fstype.c +6
-0+if (result.int_32 >0 ) + args->ar_quota = opt_quota_values[result.int_32]; +else if (result.negated) + args->ar_quota =GFS2_QUOTA_OFF ; +else + args->ar_quota =GFS2_QUOTA_ON ;
I recommend checking result.negated first.
fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, · line 1558
Quoted 5 lines
fs/gfs2/ops_fstype.c +5
-0+/* Not allowed to change locking details */ +if (strcmp (newargs->ar_lockproto, oldargs->ar_lockproto) || +strcmp (newargs->ar_locktable, oldargs->ar_locktable) || +strcmp (newargs->ar_hostdata, oldargs->ar_hostdata)) +return -EINVAL ;
Use errorf(). (Not invalf - the parameter isn't exactly invalid, it's just that you're not allowed to do this operation).
fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, · line 1575
Quoted 5 lines
fs/gfs2/ops_fstype.c +5
-0+ error =gfs2_make_fs_ro (sdp); + else + error =gfs2_make_fs_rw (sdp); +if (error) +return error;
Might want to call errorf() here too.
fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount_meta(struct file_system_type *fs_type, · line 1661
Quoted 2 lines
fs/gfs2/ops_fstype.c +1
-1- s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags, + s = sget(&gfs2_fs_type, test_meta_super, set_meta_super, flags,
Try and use sget_fc() please. If you look at the fuse patchset I cc'd you on, there's a commit there that adds a ->bdev and ->bdev_mode to fs_context that may be of use to you.
Can you use vfs_get_block_super()? Would it be of use to export test_bdev_super_fc() and set_bdev_super_fc()?
David
Re: [PATCH v2 1/2] gfs2: Convert gfs2 to fs_context
Quoted 6 lines · David Howells
Review
Quoted 2 lines · Andrew Price
(quoted diff) +2
-0+ pr_warn("-o debug and -o errors=panic are mutually exclusive\n"); + return -EINVAL;return
invalf(fc, "gfs2: -o debug and -o errors=panic are mutually exclusive");
Thanks.
Quoted 11 lines
(Note: no "\n")
fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, · line 1468
Quoted 6 lines
fs/gfs2/ops_fstype.c +6
-0+if (result.int_32 >0 ) + args->ar_quota = opt_quota_values[result.int_32]; +else if (result.negated) + args->ar_quota =GFS2_QUOTA_OFF ; +else + args->ar_quota =GFS2_QUOTA_ON ;I recommend checking result.negated first.
OK
Quoted 9 lines
fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, · line 1558
Quoted 6 lines
fs/gfs2/ops_fstype.c +5
-0+/* Not allowed to change locking details */ +if (strcmp (newargs->ar_lockproto, oldargs->ar_lockproto) || +strcmp (newargs->ar_locktable, oldargs->ar_locktable) || +strcmp (newargs->ar_hostdata, oldargs->ar_hostdata)) +return -EINVAL ;Use
errorf(). (Not invalf - the parameter isn't exactly invalid, it's just that you're not allowed to do this operation).
Yes, that makes more sense.
Quoted 8 lines
fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, · line 1575
Quoted 5 lines
fs/gfs2/ops_fstype.c +5
-0+ error =gfs2_make_fs_ro (sdp); + else + error =gfs2_make_fs_rw (sdp); +if (error) +return error;Might want to call
errorf()here too.
Quoted 4 lines
fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount_meta(struct file_system_type *fs_type, · line 1661
Quoted 2 lines
fs/gfs2/ops_fstype.c +1
-1- s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags, + s = sget(&gfs2_fs_type, test_meta_super, set_meta_super, flags,Try and use
sget_fc()please.
That happens in patch 2/2 for gfs2meta. I might just roll both patches together in v3 so there's no intermediate churn.
Quoted 3 lines
If you look at the fuse patchset I cc'd you on,
there's a commit there that adds a ->bdev and ->bdev_mode tofs_contextthat may be of use to you.
Yes, that looks useful - thanks.
Quoted 1 line
Can you use
vfs_get_block_super()?
It might be possible if we can rearrange things so that this can be done outside of the function:
if (args->ar_meta)
fc->root = dget(sdp->sd_master_dir);
else
fc->root = dget(sdp->sd_root_dir);but we can't do that in our fill_super() because it needs to be selected whether we have an existing mount or not.
Quoted 2 lines
Would it be of use to export
test_bdev_super_fc()andset_bdev_super_fc()?
There's only a little maintenance value in it, I think, but we could certainly use them in gfs2 if we can't solve the fc->root selection issue.
Andy
Re: [PATCH v2 1/2] gfs2: Convert gfs2 to fs_context
Quoted 7 lines · Andrew Price
Quoted 1 line · David Howells
Can you use
vfs_get_block_super()?It might be possible if we can rearrange things so that this can be done outside of the function:
Quoted 7 lines
??????? if (
args->ar_meta)
???????????????fc->root=dget(sdp->sd_master_dir); ??????? else
???????????????fc->root=dget(sdp->sd_root_dir);but we can't do that in our
fill_super()because it needs to be selected whether we have an existing mount or not.
Would this fly?
fs/super.c +0 -0
@@ -1232,11 +1232,12 @@ static int test_bdev_super_fc(struct super_block
*s, struct fs_context *fc)
* @fill_super: Helper to initialise a new superblock */
int vfs_get_block_super(struct fs_context *fc,
- int (*fill_super)(struct super_block *,
- struct fs_context *))
+ int (*fill_super)(struct super_block *, struct fs_context *),
+ struct dentry* (*select_root)(struct fs_context *, structsuper_block *))
{
struct block_device *bdev;
struct super_block *s;
+ struct dentry *root;
int error = 0;
fc->bdev_mode = FMODE_READ | FMODE_EXCL;
@@ -1302,7 +1303,11 @@ int vfs_get_block_super(struct fs_context *fc,
}
BUG_ON(fc->root);- fc->root = dget(s->s_root);
+ if (select_root)
+ root = select_root(fc, s);
+ else
+ root = s->s_root;
+ fc->root = dget(root);
return 0; error_sb:
include/linux/fs_context.h +2 -2
@@ -145,8 +145,8 @@ extern int vfs_get_super(struct fs_context *fc, struct fs_context *fc)); extern int vfs_get_block_super(struct fs_context *fc, -int (*fill_super)(struct super_block *sb, -struct fs_context *fc)); + int (*fill_super)(struct super_block *, struct fs_context *), + struct dentry* (*select_root)(struct fs_context *, struct
super_block *));
extern const struct file_operations fscontext_fops;
Re: [PATCH v2 1/2] gfs2: Convert gfs2 to fs_context
Quoted 1 line · Andrew Price
Would this fly?
Can you update the comment to document what it's for?
David
PATCH 1/1 vfs: Allow selection of fs root independent of sb
Take a function pointer 'select_root' in vfs_get_block_super() to allow callers to select the root dentry based on the context.
This is intended for gfs2 to select between the normal root and the 'meta' root, which must be done whether a root already exists for a superblock or not, i.e. it cannot be decided in fill_super().
This will allow gfs2 to avoid duplicating a function from the vfs just to special-case the root dentry selection.
---
Depends on "vfs: Create fs_context-aware mount_bdev() replacement"
fs/super.c | 11 ++++++++--- include/linux/fs_context.h | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-)
fs/super.c +8 -3
@@ -1232,11 +1232,12 @@ static int test_bdev_super_fc(struct super_block *s, struct fs_context *fc)* @fill_super: Helper to initialise a new superblock */ int vfs_get_block_super (struct fs_context *fc, -int (*fill_super)(struct super_block *, -struct fs_context *)) +int (*fill_super)(struct super_block *,struct fs_context *), +struct dentry * (*select_root)(struct fs_context *,struct super_block *)) {struct block_device *bdev;struct super_block *s; +struct dentry *root;int error =0 ; fc->bdev_mode =FMODE_READ |FMODE_EXCL ;
@@ -1302,7 +1303,11 @@ int vfs_get_block_super(struct fs_context *fc, }BUG_ON (fc->root); - fc->root =dget (s->s_root); +if (select_root) + root =select_root (fc, s); +else + root = s->s_root; + fc->root =dget (root);return 0 ; error_sb:
include/linux/fs_context.h +2 -2
@@ -145,8 +145,8 @@ extern int vfs_get_super(struct fs_context *fc, struct fs_context *fc));extern int vfs_get_block_super (struct fs_context *fc, -int (*fill_super)(struct super_block *sb, -struct fs_context *fc)); +int (*fill_super)(struct super_block *,struct fs_context *), +struct dentry * (*select_root)(struct fs_context *,struct super_block *));extern const struct file_operations fscontext_fops;
Signature · 1 line
2.20.1
Re: [PATCH] vfs: Allow selection of fs root independent of sb
That's not what I meant. There's a kerneldoc comment on vfs_get_block_super() that you need to modify. I would in any case roll your patch into mine.
Quoted 3 lines
This is intended for gfs2 to select between the normal root and the 'meta' root, which must be done whether a root already exists for a superblock or not, i.e. it cannot be decided in
fill_super().
Can this be done in gfs2_get_tree, where it sets fc->root?
David
Re: [PATCH] vfs: Allow selection of fs root independent of sb
In reply to Andrew PriceQuoted 2 lines · Andrew Price
Take a function pointer '
select_root' invfs_get_block_super()to allow callers to select the root dentry based on the context.
Can't this be a fs_context_operations pointer?
PATCH v2 2/2 gfs2: Convert gfs2meta to fs_context
In reply to Andrew Price--- fs/gfs2/ops_fstype.c | 54 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-)
fs/gfs2/ops_fstype.c +32 -22
@@ -1629,48 +1629,58 @@ static int gfs2_init_fs_context(struct fs_context *fc)return 0 ; } -static int set_meta_super (struct super_block *s,void *ptr) +static int set_meta_super (struct super_block *s,struct fs_context *fc) {return -EINVAL ; } -static int test_meta_super (struct super_block *s,void *ptr) -{ -struct block_device *bdev = ptr; -return (bdev == s->s_bdev); -} - - -static struct dentry *gfs2_mount_meta (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data) +static int gfs2_meta_get_tree (struct fs_context *fc) { +struct gfs2_args *args = fc->fs_private;struct super_block *s;struct gfs2_sbd *sdp;struct path path;int error; -if (!dev_name || !*dev_name) -return ERR_PTR (-EINVAL ); +if (!fc->source || !*fc->source) +return -EINVAL ; - error =kern_path (dev_name,LOOKUP_FOLLOW , &path); + error =kern_path (fc->source,LOOKUP_FOLLOW , &path);if (error) {pr_warn ("path_lookup on %s returned error %d\n" , - dev_name, error); -return ERR_PTR (error); + fc->source, error); +return error; } - s =sget (&gfs2_fs_type, test_meta_super, set_meta_super, flags, - path.dentry->d_sb->s_bdev); + fc->fs_type = &gfs2_fs_type; + args->ar_bdev = path.dentry->d_sb->s_bdev; + s =sget_fc (fc, test_gfs2_super, set_meta_super);path_put (&path);if (IS_ERR (s)) {pr_warn ("gfs2 mount does not exist\n" ); -return ERR_CAST (s); +return PTR_ERR (s); } -if ((flags ^ s->s_flags) &SB_RDONLY ) { +if ((fc->sb_flags ^ s->s_flags) &SB_RDONLY ) {deactivate_locked_super (s); -return ERR_PTR (-EBUSY ); +return -EBUSY ; } sdp = s->s_fs_info; -return dget (sdp->sd_master_dir); + fc->root =dget (sdp->sd_master_dir); +return 0 ; +} + +static const struct fs_context_operations gfs2_meta_context_ops = { + .get_tree = gfs2_meta_get_tree, +}; + +static int gfs2_meta_init_fs_context (struct fs_context *fc) +{ +int ret =gfs2_init_fs_context (fc); + +if (ret) +return ret; + + fc->ops = &gfs2_meta_context_ops; +return 0 ; }static void gfs2_kill_sb (struct super_block *sb)
@@ -1705,7 +1715,7 @@ MODULE_ALIAS_FS("gfs2");struct file_system_type gfs2meta_fs_type = { .name ="gfs2meta" , .fs_flags =FS_REQUIRES_DEV , - .mount = gfs2_mount_meta, + .init_fs_context = gfs2_meta_init_fs_context, .owner =THIS_MODULE , };MODULE_ALIAS_FS ("gfs2meta" );
Signature · 1 line
2.20.1