From: Waiman Long <longman@redhat.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Waiman Long <longman@redhat.com>
Subject: [PATCH] vfs: Pre-allocate superblock in sget_fc() if !test
Date: Fri, 21 Jan 2022 13:52:55 -0500 [thread overview]
Message-ID: <20220121185255.27601-1-longman@redhat.com> (raw)
When the test function is not defined in sget_fc(), we always need
to allocate a new superblock. So there is no point in acquiring the
sb_lock twice in this case. Optimize the !test case by pre-allocating
the superblock first before acquring the lock.
Signed-off-by: Waiman Long <longman@redhat.com>
---
fs/super.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/super.c b/fs/super.c
index a6405d44d4ca..c2bd5c34a826 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -520,6 +520,8 @@ struct super_block *sget_fc(struct fs_context *fc,
struct user_namespace *user_ns = fc->global ? &init_user_ns : fc->user_ns;
int err;
+ if (!test)
+ s = alloc_super(fc->fs_type, fc->sb_flags, user_ns);
retry:
spin_lock(&sb_lock);
if (test) {
--
2.27.0
next reply other threads:[~2022-01-21 18:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 18:52 Waiman Long [this message]
2022-01-24 11:37 ` [PATCH] vfs: Pre-allocate superblock in sget_fc() if !test Christian Brauner
2022-01-24 14:58 ` Waiman Long
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=20220121185255.27601-1-longman@redhat.com \
--to=longman@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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).