From patchwork Mon Jan 28 17:11:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 10784133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C58114E1 for ; Mon, 28 Jan 2019 17:11:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 137822BD2D for ; Mon, 28 Jan 2019 17:11:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1180B2BD37; Mon, 28 Jan 2019 17:11:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89AB72BD3A for ; Mon, 28 Jan 2019 17:11:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732782AbfA1RLn (ORCPT ); Mon, 28 Jan 2019 12:11:43 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:47035 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732248AbfA1RLm (ORCPT ); Mon, 28 Jan 2019 12:11:42 -0500 Received: by mail-ed1-f68.google.com with SMTP id o10so13600886edt.13 for ; Mon, 28 Jan 2019 09:11:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dBfZXAU4d+bQna5+CfH1nfF9ZKEuBVSmCnVCcMfv/ac=; b=NtipgHkrU1iJVU+sPCrun9ThT6/TYAt2u6X/2xVmtYU9txThMc1MhhCFYYlOag/sZx 6w2NzjEyaJg1HlJeYKCo78UFtx6nE6Cn5h5ZKhRAmm4o8Z/KniHzqdvr4KK/iu0dEJ4p TQH0eXLpuhCBaahjXt8X6wcU4NbWTyFF2AUFTb9D6k6eiBTL4JFPAf6zbhOVharFglso 1S9Q6IQMNd05Rlczu0Diuuas0zQyCASeTMM8ONs9QaoCHfqUFWoHTfI5kz/06B827tub EPuuxoReLvTOBsL5iiwFHPAilPVQ1jtyAd5q2vK7SIumzy11+suqql6bgJcbk6M4Awz0 qP0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dBfZXAU4d+bQna5+CfH1nfF9ZKEuBVSmCnVCcMfv/ac=; b=K1ryikFoth6biekF2JJMCOwX6WW+vqmNX1QCG96alb89ruYmFn315xZJBtYbmp4v1k manTQtpdaJMsKO9ovKmOumFYYw6zXSAUpiYk0mkIfWgbr1hx6x/3454O9urPVPo8JboQ Qs4N6lVBigIBWMb6Z2Ow86O9upqbs8XY+FG+et/ZPgZROE2Rk2TzcTLgxGbmn85WyqIa iuRuxD+OsmbyogGjBZEQYGV5hwQ6v6P+DCt4M7QobjmiPFc+oSLc3ATAg3KqkALIaJQW hRE1ojAW9h11k3ShHBOlKDMZRyYktn5VjHHIzJM0E6BuqCDww1eFgHWaPByrt1RnMmfI Mn2Q== X-Gm-Message-State: AJcUukdsgsa2El80i+JQ00PyZj/w+IDkHfShaQVaaQKW3jime63rWHCu bYeXQPCz70mpVa2inGBLYbyVPw== X-Google-Smtp-Source: ALg8bN4Y6sBEfjTNkzS4Rj/U1vtIpB0hmIgfDv7AUYPk5Q0odh2WJqTXxNocpT2ZrEMRZ8vtfZOX9g== X-Received: by 2002:a05:6402:8d2:: with SMTP id d18mr22802354edz.119.1548695500372; Mon, 28 Jan 2019 09:11:40 -0800 (PST) Received: from localhost.localdomain ([2a02:8109:b6bf:f9e4:2130:3a9e:3894:d6a6]) by smtp.gmail.com with ESMTPSA id l51sm13989804edb.36.2019.01.28.09.11.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 09:11:39 -0800 (PST) From: Christian Brauner 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 Subject: [PATCH 1/2] devpts: remove unneeded inode_lock in mknod_ptmx Date: Mon, 28 Jan 2019 18:11:32 +0100 Message-Id: <20190128171133.539-1-christian@brauner.io> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Christian Brauner --- 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)