diff mbox series

[v5,10/17] xfs: mount-api - add xfs_get_tree()

Message ID 157062066316.32346.11258138585168789863.stgit@fedora-28 (mailing list archive)
State New, archived
Headers show
Series xfs: mount API patch series | expand

Commit Message

Ian Kent Oct. 9, 2019, 11:31 a.m. UTC
Add the fs_context_operations method .get_tree that validates
mount options and fills the super block as previously done
by the file_system_type .mount method.

Signed-off-by: Ian Kent <raven@themaw.net>
Reviewed-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_super.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

Comments

Christoph Hellwig Oct. 9, 2019, 3:04 p.m. UTC | #1
> +	/*
> +	 * set up the mount name first so all the errors will refer to the
> +	 * correct device.
> +	 */
> +	mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
> +	if (!mp->m_fsname)
> +		goto out_error;
> +	mp->m_fsname_len = strlen(mp->m_fsname) + 1;

m_fsname_len is entirelt unused.  m_fsname just has a few users, so
maybe in a prep patch just kill both of them and use sb->s_id instead.
Ian Kent Oct. 10, 2019, 1:11 a.m. UTC | #2
On Wed, 2019-10-09 at 08:04 -0700, Christoph Hellwig wrote:
> > +	/*
> > +	 * set up the mount name first so all the errors will refer to
> > the
> > +	 * correct device.
> > +	 */
> > +	mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
> > +	if (!mp->m_fsname)
> > +		goto out_error;
> > +	mp->m_fsname_len = strlen(mp->m_fsname) + 1;
> 
> m_fsname_len is entirelt unused.  m_fsname just has a few users, so
> maybe in a prep patch just kill both of them and use sb->s_id
> instead.

Ok, I'll also have a look at doing that.

Ian
diff mbox series

Patch

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index cc2da9093e34..314acafffd0b 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1925,6 +1925,51 @@  xfs_fs_fill_super(
 	return error;
 }
 
+STATIC int
+xfs_fill_super(
+	struct super_block	*sb,
+	struct fs_context	*fc)
+{
+	struct xfs_fs_context	*ctx = fc->fs_private;
+	struct xfs_mount	*mp = sb->s_fs_info;
+	int			silent = fc->sb_flags & SB_SILENT;
+	int			error = -ENOMEM;
+
+	mp->m_super = sb;
+
+	/*
+	 * set up the mount name first so all the errors will refer to the
+	 * correct device.
+	 */
+	mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
+	if (!mp->m_fsname)
+		goto out_error;
+	mp->m_fsname_len = strlen(mp->m_fsname) + 1;
+
+	error = xfs_validate_params(mp, ctx, false);
+	if (error)
+		goto out_error;
+
+	error = __xfs_fs_fill_super(mp, silent);
+	if (error)
+		goto out_error;
+
+	return 0;
+
+ out_error:
+	sb->s_fs_info = NULL;
+	xfs_free_fsname(mp);
+	kfree(mp);
+	return error;
+}
+
+STATIC int
+xfs_get_tree(
+	struct fs_context	*fc)
+{
+	return get_tree_bdev(fc, xfs_fill_super);
+}
+
 STATIC void
 xfs_fs_put_super(
 	struct super_block	*sb)
@@ -1995,6 +2040,11 @@  static const struct super_operations xfs_super_operations = {
 	.free_cached_objects	= xfs_fs_free_cached_objects,
 };
 
+static const struct fs_context_operations xfs_context_ops = {
+	.parse_param = xfs_parse_param,
+	.get_tree    = xfs_get_tree,
+};
+
 static struct file_system_type xfs_fs_type = {
 	.owner			= THIS_MODULE,
 	.name			= "xfs",