Skip to contentSkip to conversation

gfs2: Switch to the new mount API

PATCH Superseded Andrew Price 3 participants 8 messages Mar 17, 2019 – Mar 19, 2019

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover gfs2: Switch to the new mount API

These patches convert gfs2 and gfs2meta to use fs_context.

In both cases we still use sget() instead of sget_fc() as there doesn't seem to be a clear idiomatic way to propagate the bdev currently.

Tested with xfstests -g quick, a bunch of targeted mount commands to exercise individual options, and gfs2_grow to test the gfs2meta mount.

I'm aiming this at 5.2 so it'll have plenty of soak time.

Thanks to David Howells for providing the method for parsing the complicated 'quota' option.

Andrew Price (2):
gfs2: Convert gfs2 to fs_context
gfs2: Convert gfs2meta to fs_context

 fs/gfs2/incore.h     |   8 +-
 fs/gfs2/ops_fstype.c | 418 +++++++++++++++++++++++++++++++++++++------
 fs/gfs2/super.c      | 335 +---------------------------------
 fs/gfs2/super.h      |   3 +-
 4 files changed, 373 insertions(+), 391 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 gfs2: Convert gfs2 to fs_context

Switch to using fs_context ops for mount/remount.

sget() is still used instead of sget_fc() as there doesn't seem to be an obvious replacement for the bdev pointer propagation to the test/set functions (yet?)

---
 fs/gfs2/incore.h     |   8 +-
 fs/gfs2/ops_fstype.c | 382 ++++++++++++++++++++++++++++++++++++++-----
 fs/gfs2/super.c      | 335 +------------------------------------
 fs/gfs2/super.h      |   3 +-
 4 files changed, 350 insertions(+), 378 deletions(-)
fs/gfs2/incore.h +4 -4
index cdf07b408f54..10febb298da5 100644
@@ -587,10 +587,10 @@ struct gfs2_args {
 	unsigned int ar_rgrplvb:1;		/* use lvbs for rgrp info */
 	unsigned int ar_loccookie:1;		/* use location based readdir
 						   cookies */
-	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 */
 };
 
 struct gfs2_tune {
fs/gfs2/ops_fstype.c +344 -38

444 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
index 73c97dccae21..b9dc2065dd72 100644
@@ -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
#2 lore raw

Re: [PATCH 1/2] gfs2: Convert gfs2 to fs_context

Quoted 3 lines · Andrew Price

sget() is still used instead of sget_fc() as there doesn't seem to be an obvious replacement for the bdev pointer propagation to the test/set functions (yet?)

Umm... What about the fs_context struct? Why can't that be used to propagate the bdev pointer? That's kind of what it's for...

struct super_block *sget_fc(
struct fs_context *fc,
int (*test)(struct super_block *, struct fs_context *), int (*set)(struct super_block *, struct fs_context *))

It looks like you should be able to stash the bdev pointer in the gfs2_args struct.

fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, · line 1381

Quoted 3 lines
fs/gfs2/ops_fstype.c +3 -0
+	fsparam_s32    ("commit",             Opt_commit),
+	fsparam_s32    ("statfs_quantum",     Opt_statfs_quantum),
+	fsparam_s32    ("statfs_percent",     Opt_statfs_percent),

Why s32? Why not u32?

David

#3 lore raw

Re: [PATCH 1/2] gfs2: Convert gfs2 to fs_context

Quoted 8 lines · David Howells
Quoted 3 lines · Andrew Price

sget() is still used instead of sget_fc() as there doesn't seem to be an obvious replacement for the bdev pointer propagation to the test/set functions (yet?)

Umm... What about the fs_context struct? Why can't that be used to propagate the bdev pointer? That's kind of what it's for...

It would be useful to have the block device pointer in the fs_context since so many of the filesystems use them and it makes for an obvious API migration.

Quoted 7 lines

struct super_block *sget_fc(
struct fs_context *fc,
int (*test)(struct super_block *, struct fs_context *), int (*set)(struct super_block *, struct fs_context *))

It looks like you should be able to stash the bdev pointer in the gfs2_args struct.

Sure, but since the new API is young I figured I'd hold off until we had this conversation because adding it to the fs_context might be agreeable :)

Quoted 5 lines

fs/gfs2/ops_fstype.c static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, · line 1381

Quoted 3 lines
fs/gfs2/ops_fstype.c +3 -0
+	fsparam_s32    ("commit",             Opt_commit),
+	fsparam_s32    ("statfs_quantum",     Opt_statfs_quantum),
+	fsparam_s32    ("statfs_percent",     Opt_statfs_percent),

Why s32? Why not u32?

They were signed before, I guess because if the user passes a negative number it allows us to range check properly and provide a sensible error message. Is there an issue with them being s32 that I hadn't considered?

Thanks,
Andy

#4 lore raw

Re: [PATCH 1/2] gfs2: Convert gfs2 to fs_context

Quoted 5 lines · Andrew Price
Quoted 2 lines

Umm... What about the fs_context struct? Why can't that be used to propagate the bdev pointer? That's kind of what it's for...

It would be useful to have the block device pointer in the fs_context since so many of the filesystems use them and it makes for an obvious API migration.

That may be so. I've argued also that we should put a net-namespace pointer in there, but Al disagreed.

However, I think most bdev-based filesystems use mount_bdev() which gfs2 does not.

Quoted 5 lines
Quoted 2 lines

It looks like you should be able to stash the bdev pointer in the gfs2_args struct.

Sure, but since the new API is young I figured I'd hold off until we had this conversation because adding it to the fs_context might be agreeable :)

Note that I have patches to kill of sget_userns() and sget() will hopefully soon follow. Have a look at:

https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=mount-api-viro

David

#5 lore raw

Re: [PATCH 1/2] gfs2: Convert gfs2 to fs_context

Quoted 17 lines · David Howells
Quoted 5 lines · Andrew Price
Quoted 2 lines

Umm... What about the fs_context struct? Why can't that be used to propagate the bdev pointer? That's kind of what it's for...

It would be useful to have the block device pointer in the fs_context since so many of the filesystems use them and it makes for an obvious API migration.

That may be so. I've argued also that we should put a net-namespace pointer in there, but Al disagreed.

However, I think most bdev-based filesystems use mount_bdev() which gfs2 does not.

Quoted 3 lines
Quoted 2 lines

It looks like you should be able to stash the bdev pointer in the gfs2_args struct.

Quoted 7 lines
Quoted 2 lines

Sure, but since the new API is young I figured I'd hold off until we had this conversation because adding it to the fs_context might be agreeable :)

Note that I have patches to kill of sget_userns() and sget() will hopefully soon follow. Have a look at:

https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=mount-api-viro

That's fair enough. I'll update the patch to put the bdev in the gfs2_args struct and use sget_fc().

Thanks,
Andy

#6 lore raw

PATCH 2/2 gfs2: Convert gfs2meta to fs_context

In reply to Andrew Price
---
 fs/gfs2/ops_fstype.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)
fs/gfs2/ops_fstype.c +23 -13
index 451a49036ffb..cdee96b5b81f 100644
@@ -1630,36 +1630,46 @@ static int set_meta_super(struct super_block *s, void *ptr)
 	return -EINVAL;
 }
 
-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 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_gfs2_super, set_meta_super, flags,
+	s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, fc->sb_flags,
 		 path.dentry->d_sb->s_bdev);
 	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)
+{
+	fc->ops = &gfs2_meta_context_ops;
+	return 0;
 }
 
 static void gfs2_kill_sb(struct super_block *sb)
@@ -1694,7 +1704,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
#7 lore raw
In reply to Andrew Price

Thanks for sorting this out so quickly,

Steve.

Quoted 23 lines · Andrew Price

These patches convert gfs2 and gfs2meta to use fs_context.

In both cases we still use sget() instead of sget_fc() as there doesn't seem to be a clear idiomatic way to propagate the bdev currently.

Tested with xfstests -g quick, a bunch of targeted mount commands to exercise individual options, and gfs2_grow to test the gfs2meta mount.

I'm aiming this at 5.2 so it'll have plenty of soak time.

Thanks to David Howells for providing the method for parsing the complicated 'quota' option.

Andrew Price (2):
gfs2: Convert gfs2 to fs_context
gfs2: Convert gfs2meta to fs_context

  fs/gfs2/incore.h     |   8 +-
  fs/gfs2/ops_fstype.c | 418 +++++++++++++++++++++++++++++++++++++------
  fs/gfs2/super.c      | 335 +---------------------------------
  fs/gfs2/super.h      |   3 +-
  4 files changed, 373 insertions(+), 391 deletions(-)