linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: David Howells <dhowells@redhat.com>, viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, mszeredi@redhat.com,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	jlayton@redhat.com
Subject: Re: [PATCH 03/14] VFS: Implement a filesystem superblock creation/configuration context [ver #6]
Date: Fri, 6 Oct 2017 13:34:19 -0700	[thread overview]
Message-ID: <27530b6a-7290-2171-899e-6c16c14f402e@infradead.org> (raw)
In-Reply-To: <150730496982.6182.10042997820796149075.stgit@warthog.procyon.org.uk>

On 10/06/17 08:49, David Howells wrote:
> 
> diff --git a/fs/fs_context.c b/fs/fs_context.c
> new file mode 100644
> index 000000000000..a3a7ccb4323d
> --- /dev/null
> +++ b/fs/fs_context.c

> +/**
> + * generic_parse_monolithic - Parse key[=val][,key[=val]]* mount data
> + * @mc: The superblock configuration to fill in.

function argument is &struct fs_context *ctx, not @mc

> + * @data: The data to parse
> + *
> + * Parse a blob of data that's in key[=val][,key[=val]]* form.  This can be
> + * called from the ->monolithic_mount_data() fs_context operation.
> + *
> + * Returns 0 on success or the error returned by the ->parse_option() fs_context
> + * operation on failure.
> + */
> +int generic_parse_monolithic(struct fs_context *ctx, void *data)
> +{
> +	char *options = data, *p;
> +	int ret;
> +
> +	if (!options)
> +		return 0;
> +
> +	while ((p = strsep(&options, ",")) != NULL) {
> +		if (*p) {
> +			ret = vfs_parse_mount_option(ctx, p);
> +			if (ret < 0)
> +				return ret;
> +		}
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(generic_parse_monolithic);
> +

> +
> +/**
> + * put_fs_context - Dispose of a superblock configuration context.
> + * @sc: The context to dispose of.

      @fc:

> + */
> +void put_fs_context(struct fs_context *fc)
> +{
> +	struct super_block *sb;
> +
> +	if (fc->root) {
> +		sb = fc->root->d_sb;
> +		dput(fc->root);
> +		fc->root = NULL;
> +		deactivate_super(sb);
> +	}
> +
> +	if (fc->ops && fc->ops->free)
> +		fc->ops->free(fc);
> +
> +	security_fs_context_free(fc);
> +	if (fc->net_ns)
> +		put_net(fc->net_ns);
> +	put_user_ns(fc->user_ns);
> +	if (fc->cred)
> +		put_cred(fc->cred);
> +	kfree(fc->subtype);
> +	put_filesystem(fc->fs_type);
> +	kfree(fc->source);
> +	kfree(fc);
> +}
> +EXPORT_SYMBOL(put_fs_context);


(in fs/namespace.c:)

> +/**
> + * vfs_create_mount - Create a mount for a configured superblock
> + * fc: The configuration context with the superblock attached

      @fc:

> + *
> + * Create a mount to an already configured superblock.  If necessary, the
> + * caller should invoke vfs_get_tree() before calling this.
> + *
> + * Note that this does not attach the mount to anything.
> + */
> +struct vfsmount *vfs_create_mount(struct fs_context *fc)
> +{
> +	struct mount *mnt;
> +
> +	if (!fc->root)
> +		return ERR_PTR(-EINVAL);
> +
> +	mnt = alloc_vfsmnt(fc->source ?: "none");
> +	if (!mnt)
> +		return ERR_PTR(-ENOMEM);
> +
> +	if (fc->purpose == FS_CONTEXT_FOR_KERNEL_MOUNT)
> +		/* It's a longterm mount, don't release mnt until we unmount
> +		 * before file sys is unregistered
> +		 */
> +		mnt->mnt.mnt_flags = MNT_INTERNAL;
> +
> +	atomic_inc(&fc->root->d_sb->s_active);
> +	mnt->mnt.mnt_sb		= fc->root->d_sb;
> +	mnt->mnt.mnt_root	= dget(fc->root);
> +	mnt->mnt_mountpoint	= mnt->mnt.mnt_root;
> +	mnt->mnt_parent		= mnt;
> +
> +	lock_mount_hash();
> +	list_add_tail(&mnt->mnt_instance, &mnt->mnt.mnt_sb->s_mounts);
> +	unlock_mount_hash();
> +	return &mnt->mnt;
> +}
> +EXPORT_SYMBOL(vfs_create_mount);


-- 
~Randy

  reply	other threads:[~2017-10-06 20:34 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-06 15:49 [PATCH 00/14] VFS: Introduce filesystem context [ver #6] David Howells
2017-10-06 15:49 ` [PATCH 01/14] VFS: Introduce the structs and doc for a " David Howells
2017-10-06 15:49 ` [PATCH 02/14] VFS: Add LSM hooks for " David Howells
2017-10-06 20:37   ` Randy Dunlap
2017-10-06 15:49 ` [PATCH 03/14] VFS: Implement a filesystem superblock creation/configuration " David Howells
2017-10-06 20:34   ` Randy Dunlap [this message]
2017-10-06 23:13   ` David Howells
2017-10-07  0:08     ` Randy Dunlap
2017-10-10  7:49   ` Miklos Szeredi
2017-10-10 15:24   ` David Howells
2017-10-26 16:24   ` David Howells
2017-10-27  9:24     ` Miklos Szeredi
2017-10-27 14:35     ` David Howells
2017-10-27 15:33       ` Miklos Szeredi
2017-10-27 16:03       ` David Howells
2017-10-30  8:44         ` Miklos Szeredi
2017-10-06 15:49 ` [PATCH 04/14] VFS: Remove unused code after filesystem context changes " David Howells
2017-10-06 15:49 ` [PATCH 05/14] VFS: Implement fsopen() to prepare for a mount " David Howells
2017-10-26 17:11   ` Jeff Layton
2017-10-26 19:01   ` Jeff Layton
2017-10-06 15:49 ` [PATCH 06/14] VFS: Implement fsmount() to effect a pre-configured " David Howells
2017-10-10  8:00   ` Miklos Szeredi
2017-10-10  9:51     ` Karel Zak
2017-10-10 13:38       ` Miklos Szeredi
2017-10-11  8:54         ` Karel Zak
2017-10-06 15:50 ` [PATCH 07/14] VFS: Add a sample program for fsopen/fsmount " David Howells
2017-10-26 17:21   ` Jeff Layton
2017-10-26 22:40   ` David Howells
2017-10-06 15:50 ` [PATCH 08/14] procfs: Move proc_fill_super() to fs/proc/root.c " David Howells
2017-10-06 15:50 ` [PATCH 09/14] proc: Add fs_context support to procfs " David Howells
2017-10-06 15:50 ` [PATCH 10/14] ipc: Convert mqueue fs to fs_context " David Howells
2017-10-06 15:50 ` [PATCH 11/14] cpuset: Use " David Howells
2017-10-06 15:50 ` [PATCH 12/14] kernfs, sysfs, cgroup, intel_rdt: Support " David Howells
2017-10-06 15:50 ` [PATCH 13/14] hugetlbfs: Convert to " David Howells
2017-10-06 15:50 ` [PATCH 14/14] VFS: Remove kern_mount_data() " David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27530b6a-7290-2171-899e-6c16c14f402e@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=dhowells@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).