From: Christian Brauner <brauner@kernel.org>
To: Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
David Howells <dhowells@redhat.com>,
Aleksa Sarai <cyphar@cyphar.com>, Karel Zak <kzak@redhat.com>,
linux-fsdevel@vger.kernel.org, Josef Bacik <josef@toxicpanda.com>,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH v2 2/4] fs: add vfs_cmd_create()
Date: Wed, 02 Aug 2023 13:57:04 +0200 [thread overview]
Message-ID: <20230802-vfs-super-exclusive-v2-2-95dc4e41b870@kernel.org> (raw)
In-Reply-To: <20230802-vfs-super-exclusive-v2-0-95dc4e41b870@kernel.org>
Split the steps to create a superblock into a tiny helper. This will
make the next patch easier to follow.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/fsopen.c | 51 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 17 deletions(-)
diff --git a/fs/fsopen.c b/fs/fsopen.c
index fc9d2d9fd234..1de2b3576958 100644
--- a/fs/fsopen.c
+++ b/fs/fsopen.c
@@ -209,6 +209,39 @@ SYSCALL_DEFINE3(fspick, int, dfd, const char __user *, path, unsigned int, flags
return ret;
}
+static int vfs_cmd_create(struct fs_context *fc)
+{
+ struct super_block *sb;
+ int ret;
+
+ if (fc->phase != FS_CONTEXT_CREATE_PARAMS)
+ return -EBUSY;
+
+ if (!mount_capable(fc))
+ return -EPERM;
+
+ fc->phase = FS_CONTEXT_CREATING;
+
+ ret = vfs_get_tree(fc);
+ if (ret) {
+ fc->phase = FS_CONTEXT_FAILED;
+ return ret;
+ }
+
+ sb = fc->root->d_sb;
+ ret = security_sb_kern_mount(sb);
+ if (unlikely(ret)) {
+ fc_drop_locked(fc);
+ fc->phase = FS_CONTEXT_FAILED;
+ return ret;
+ }
+
+ /* vfs_get_tree() callchains will have grabbed @s_umount */
+ up_write(&sb->s_umount);
+ fc->phase = FS_CONTEXT_AWAITING_MOUNT;
+ return 0;
+}
+
/*
* Check the state and apply the configuration. Note that this function is
* allowed to 'steal' the value by setting param->xxx to NULL before returning.
@@ -224,23 +257,7 @@ static int vfs_fsconfig_locked(struct fs_context *fc, int cmd,
return ret;
switch (cmd) {
case FSCONFIG_CMD_CREATE:
- if (fc->phase != FS_CONTEXT_CREATE_PARAMS)
- return -EBUSY;
- if (!mount_capable(fc))
- return -EPERM;
- fc->phase = FS_CONTEXT_CREATING;
- ret = vfs_get_tree(fc);
- if (ret)
- break;
- sb = fc->root->d_sb;
- ret = security_sb_kern_mount(sb);
- if (unlikely(ret)) {
- fc_drop_locked(fc);
- break;
- }
- up_write(&sb->s_umount);
- fc->phase = FS_CONTEXT_AWAITING_MOUNT;
- return 0;
+ return vfs_cmd_create(fc);
case FSCONFIG_CMD_RECONFIGURE:
if (fc->phase != FS_CONTEXT_RECONF_PARAMS)
return -EBUSY;
--
2.34.1
next prev parent reply other threads:[~2023-08-02 11:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 11:57 [PATCH v2 0/4] fs: add FSCONFIG_CMD_CREATE_EXCL Christian Brauner
2023-08-02 11:57 ` [PATCH v2 1/4] super: remove get_tree_single_reconf() Christian Brauner
2023-08-02 12:34 ` Christoph Hellwig
2023-08-02 17:13 ` Jan Kara
2023-08-02 11:57 ` Christian Brauner [this message]
2023-08-02 12:34 ` [PATCH v2 2/4] fs: add vfs_cmd_create() Christoph Hellwig
2023-08-02 17:13 ` Jan Kara
2023-08-02 11:57 ` [PATCH v2 3/4] fs: add vfs_cmd_reconfigure() Christian Brauner
2023-08-02 12:34 ` Christoph Hellwig
2023-08-02 17:15 ` Jan Kara
2023-08-02 11:57 ` [PATCH v2 4/4] fs: add FSCONFIG_CMD_CREATE_EXCL Christian Brauner
2023-08-02 12:36 ` Christoph Hellwig
2023-08-02 17:18 ` Jan Kara
2023-08-02 13:13 ` [PATCH v2 0/4] " Aleksa Sarai
2023-08-03 13:58 ` Christian Brauner
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=20230802-vfs-super-exclusive-v2-2-95dc4e41b870@kernel.org \
--to=brauner@kernel.org \
--cc=cyphar@cyphar.com \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=josef@toxicpanda.com \
--cc=kzak@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--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).