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) From patchwork Mon Jan 28 17:11:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 10784135 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 E7651922 for ; Mon, 28 Jan 2019 17:11:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEC092BD33 for ; Mon, 28 Jan 2019 17:11:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCEB32BC68; Mon, 28 Jan 2019 17:11:56 +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 64B7B2BD17 for ; Mon, 28 Jan 2019 17:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732788AbfA1RLu (ORCPT ); Mon, 28 Jan 2019 12:11:50 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:43049 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731722AbfA1RLn (ORCPT ); Mon, 28 Jan 2019 12:11:43 -0500 Received: by mail-ed1-f67.google.com with SMTP id f9so13624496eds.10 for ; Mon, 28 Jan 2019 09:11:42 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=dqkRLJwycOZaBeHT2bTXLK850dqnbWqpyFavVlWZuKE=; b=DcsLqm07CZbcVI1hVmgbMfjvoa8E48Uv22C85WcucmXu+dy5r0a0BBBfZrpHC07bSy aYUtGoZG6Jv5VfmGTI96kcwSCErmpynwEFYY6y7XVorZaObZuqwVYD7+XOZWDkRjh30c jzRItwHjsWdIsN1ElsxMks52JJBRxFDuxJy4i0VYOjmrdrL8o5oToaSPoGH8ukYXEaGj SaxkQ+gnHBiGvliLv53wzAe57cpqOyCRqksUoO1ZUECZsOaB941adlGCjukOapOa96fi iPrdMrZS9Jbn6eLNKCaK7Cmdl7gGJcorQOVa4MZRyLKQM9D+88axQfusR6UjW/8PyHBR 2L3g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=dqkRLJwycOZaBeHT2bTXLK850dqnbWqpyFavVlWZuKE=; b=mijVcGrg9KbGROMjMEqUec08aF3yh2WMLgp0bYmVncxy3WGIri5jUNyqz8UtKCLhTj WQNwFBWA3uvUMbXcQHEmprjp3cfA/6BMQTk/R48xKsrmmgUJJhGNTrz1CZXLCjmMvchs bnoTemORgnmlKnUVf9MyGpGOM2N01i9KDZ1IQOs3nAPRXaLW2B5x7lpHNEIJ3qe5UlP/ bU/qg7e8nyd6awv09VaOCZLiBHZuZyIxeehKgKHUzEDjzFd/AIbpODHARzRIExOJixcG 6jYzOFIXgpkfqqCYIBGdrFlU/0dl/GJRPihmzQ84V6vU201GQ6qFJFEqtMcqGjqkcXL1 /mtQ== X-Gm-Message-State: AJcUukdybC7H/Hmtu3mwIbR6zIdn2bciwo/f4GbJ0lnsb8aYt/erKxDb ++OhGIgtg/bqQCeVLSXg+n5I5g== X-Google-Smtp-Source: ALg8bN58AXRgoam3UUpDoX6Q4zLHNt4RErbLiGABDIqi0h3Xxhx/D43XHhaMtUput7cJXkWTMfTILg== X-Received: by 2002:a17:906:6d46:: with SMTP id a6mr18631038ejt.203.1548695501432; Mon, 28 Jan 2019 09:11:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 09:11:40 -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 2/2] devpts: simplify devpts_fill_super() Date: Mon, 28 Jan 2019 18:11:33 +0100 Message-Id: <20190128171133.539-2-christian@brauner.io> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190128171133.539-1-christian@brauner.io> References: <20190128171133.539-1-christian@brauner.io> 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 When devpts_fill_super() fails deactivate_locked_super() will cleanup dentries for us so there's no need to do that work in devpts_fill_super() itself. This allows us to simplify that function quite a bit. Cc: Al Viro Signed-off-by: Christian Brauner --- fs/devpts/inode.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 8fa1492f9712..59b7625a2110 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -450,19 +450,18 @@ devpts_fill_super(struct super_block *s, void *data, int silent) s->s_op = &devpts_sops; s->s_time_gran = 1; - error = -ENOMEM; s->s_fs_info = new_pts_fs_info(s); if (!s->s_fs_info) - goto fail; + return -ENOMEM; error = parse_mount_options(data, PARSE_MOUNT, &DEVPTS_SB(s)->mount_opts); if (error) - goto fail; + return error; - error = -ENOMEM; inode = new_inode(s); if (!inode) - goto fail; + return -ENOMEM; + inode->i_ino = 1; inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; @@ -473,19 +472,10 @@ devpts_fill_super(struct super_block *s, void *data, int silent) s->s_root = d_make_root(inode); if (!s->s_root) { pr_err("get root dentry failed\n"); - goto fail; + return -ENOMEM; } - error = mknod_ptmx(s); - if (error) - goto fail_dput; - - return 0; -fail_dput: - dput(s->s_root); - s->s_root = NULL; -fail: - return error; + return mknod_ptmx(s); } /*