From: Christian Brauner <christian@brauner.io>
To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
linux-fsdevel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, ebiederm@xmission.com,
ebiggers@google.com, willy@infradead.org, dhowells@redhat.com,
Christian Brauner <christian@brauner.io>
Subject: [PATCH 1/2] devpts: remove unneeded inode_lock in mknod_ptmx
Date: Mon, 28 Jan 2019 18:11:32 +0100 [thread overview]
Message-ID: <20190128171133.539-1-christian@brauner.io> (raw)
Afaict, the mknod_ptmx() call is a no-op on subsequent calls and the first
call is done before we unlock the suberblock. If I'm not mistaken this is
exactly parallel to what Al pointed out for binderfs 29ef1c8e16a
("binderfs: drop lock in binderfs_binder_ctl_create"). In both filesystems
it should not be necessary to take inode_lock() in there. Let's remove it
and remove the goto.
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Christian Brauner <christian@brauner.io>
---
fs/devpts/inode.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index c53814539070..8fa1492f9712 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -325,7 +325,6 @@ static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts)
static int mknod_ptmx(struct super_block *sb)
{
int mode;
- int rc = -ENOMEM;
struct dentry *dentry;
struct inode *inode;
struct dentry *root = sb->s_root;
@@ -334,18 +333,14 @@ static int mknod_ptmx(struct super_block *sb)
kuid_t ptmx_uid = current_fsuid();
kgid_t ptmx_gid = current_fsgid();
- inode_lock(d_inode(root));
-
/* If we have already created ptmx node, return */
- if (fsi->ptmx_dentry) {
- rc = 0;
- goto out;
- }
+ if (fsi->ptmx_dentry)
+ return 0;
dentry = d_alloc_name(root, "ptmx");
if (!dentry) {
pr_err("Unable to alloc dentry for ptmx node\n");
- goto out;
+ return -ENOMEM;
}
/*
@@ -355,7 +350,7 @@ static int mknod_ptmx(struct super_block *sb)
if (!inode) {
pr_err("Unable to alloc inode for ptmx node\n");
dput(dentry);
- goto out;
+ return -ENOMEM;
}
inode->i_ino = 2;
@@ -369,10 +364,8 @@ static int mknod_ptmx(struct super_block *sb)
d_add(dentry, inode);
fsi->ptmx_dentry = dentry;
- rc = 0;
-out:
- inode_unlock(d_inode(root));
- return rc;
+
+ return 0;
}
static void update_ptmx_mode(struct pts_fs_info *fsi)
--
2.20.1
next reply other threads:[~2019-01-28 17:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 17:11 Christian Brauner [this message]
2019-01-28 17:11 ` [PATCH 2/2] devpts: simplify devpts_fill_super() Christian Brauner
2019-02-19 9:24 ` [PATCH 1/2] devpts: remove unneeded inode_lock in mknod_ptmx 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=20190128171133.539-1-christian@brauner.io \
--to=christian@brauner.io \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=ebiggers@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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
all inboxes | Powered by JetHome®