Received: by 10.213.65.68 with SMTP id h4csp466875imn; Tue, 13 Mar 2018 09:58:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELsCrCdnuFRtYa7WCAP1zLvcPC5pJxHH1KXQf3xgiho3JGLIk/tC/rQDi6QR5pzUBJSqo3UJ X-Received: by 10.101.93.135 with SMTP id f7mr1031019pgt.82.1520960319236; Tue, 13 Mar 2018 09:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520960319; cv=none; d=google.com; s=arc-20160816; b=mNQzC5tCAp3+HrkvuDYYfmVlD7Mc4R/KDTkfZGvZbD5YK/oHca6AUGhf4eeiR1h1n2 jNYvMvYg4jcF7SvitN0IEGSHx5l83T+G4i8tpGY3SSAcEpon59x9vlU9mEDFk3b2lCT8 Xi5r5wbiuSjJ7bS3EZ9VoQNDejE96COrCslZstU7N/BsT/GZ1GMzjYmmOgJuh24YBIVj 6gSveaQND40xyhnCp2YOPq+pAkoBfkkBlav/MJ3SbvfiuhSgAz9Ixr5fNlocgc7exJrc 0H5lP7N8ypAbjOzW0S/tBTYxCr/eJPDUR1Q0esSjq07UtsJTJGe+PxgcShHo816o75bJ IajA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=bv+oQvsOje9d6G3OSc9VuGO1o+H11KuvSeNs2NTn+mw=; b=ig59+UEKQdw5FnyzWuvWCji/KIc1FAJlTO8eeIa3suPKbtwg/ADY98yMJF9GpBygVO mvkDRn3SQ1FBgcDNpcmHsi4f/He7hc+Lr6DzQandjPMT6wLFI5If73WFJ/zB/3kPBgpI 2xeW822ZveURwDS9hJViZ59QP7YgVC02vF30zATu9BaQRHMTePmelxjSfso/aWKrSSUg +y0opwpOKBvQLIv8c0X9cDGb+Rqmvf4B75rqkkjgK4ClSWwpifIkPNTp0/f5nD0XgorQ G4qAke6WvPD1GEfhA369P5nOhz0nrB/8oV4jONSZwEGKcaXVM/N1ajvDaxXZ0yd4/ASG qowg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t63si262967pgt.745.2018.03.13.09.58.25; Tue, 13 Mar 2018 09:58:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933621AbeCMQ5F (ORCPT + 99 others); Tue, 13 Mar 2018 12:57:05 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:37940 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751936AbeCMQzh (ORCPT ); Tue, 13 Mar 2018 12:55:37 -0400 Received: by mail-wr0-f194.google.com with SMTP id l8so841748wrg.5 for ; Tue, 13 Mar 2018 09:55:36 -0700 (PDT) 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; bh=bv+oQvsOje9d6G3OSc9VuGO1o+H11KuvSeNs2NTn+mw=; b=K1OxrwyY696FRS29ymRHxXjN1ZxUsCoXKzxQopsYjQnSJ8QdobqNnVu1ImclM/8l+j 3SveNwOY3ewvBYY+RPsKaF+mp+a+HnKQT9IrlFi47izij8XzSca6cu/GOgeZYY/3bmaQ bnRvZDNGXDIJdkCG5iX8gkQ4+FzoyA/n7crgi2C52hXTYq8eY2ada/5IQJ8oBsXctPBj hQdjfYYM/geuDlB649p+GsrHy4w/nHfW9xphLVn/rW9MYgXE1FkuslX1Y0sWSNmA/UPa ccAo2YDBItH9k+8Ivtama58ZYiZpPlwwMAKsVvoeH9mP7P23+zkULrLCBGwiG/G7isz+ Xe2Q== X-Gm-Message-State: AElRT7H5YTIGRAVAS39vCG1iJANQy2VIu3w1vC1SUh3cQBtxLKJqMg3t eiwQ20QU5x5gRb8ZznOgaPs= X-Received: by 10.223.136.217 with SMTP id g25mr1173135wrg.203.1520960136290; Tue, 13 Mar 2018 09:55:36 -0700 (PDT) Received: from localhost.localdomain (u-087-c077.eap.uni-tuebingen.de. [134.2.87.77]) by smtp.gmail.com with ESMTPSA id r128sm378881wmf.37.2018.03.13.09.55.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 09:55:35 -0700 (PDT) From: Christian Brauner To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, ebiederm@xmission.com, torvalds@linux-foundation.org, gregkh@linuxfoundation.org Cc: containers@lists.linux-foundation.org, Christian Brauner Subject: [PATCH 1/4 v5 RESEND] devpts: hoist out check for DEVPTS_SUPER_MAGIC Date: Tue, 13 Mar 2018 17:55:24 +0100 Message-Id: <20180313165527.24038-2-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180313165527.24038-1-christian.brauner@ubuntu.com> References: <20180313165527.24038-1-christian.brauner@ubuntu.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hoist the check whether we have already found a suitable devpts filesystem out of devpts_ptmx_path() in preparation for the devpts bind-mount resolution patch. This is a non-functional change. Signed-off-by: Christian Brauner --- ChangeLog v4->v5: * dput() dentry ChangeLog v3->v4: * patch unchanged ChangeLog v2->v3: * patch unchanged ChangeLog v1->v2: * patch added ChangeLog v0->v1: * patch not present --- fs/devpts/inode.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index e31d6ed3ec32..71b901936113 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -138,10 +138,6 @@ static int devpts_ptmx_path(struct path *path) struct super_block *sb; int err; - /* Has the devpts filesystem already been found? */ - if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC) - return 0; - /* Is a devpts filesystem at "pts" in the same directory? */ err = path_pts(path); if (err) @@ -159,21 +155,25 @@ static int devpts_ptmx_path(struct path *path) struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi) { struct path path; - int err; + int err = 0; path = filp->f_path; path_get(&path); - err = devpts_ptmx_path(&path); + /* Has the devpts filesystem already been found? */ + if (path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC) + err = devpts_ptmx_path(&path); dput(path.dentry); if (err) { mntput(path.mnt); return ERR_PTR(err); } + if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) { mntput(path.mnt); return ERR_PTR(-ENODEV); } + return path.mnt; } @@ -182,15 +182,19 @@ struct pts_fs_info *devpts_acquire(struct file *filp) struct pts_fs_info *result; struct path path; struct super_block *sb; - int err; path = filp->f_path; path_get(&path); - err = devpts_ptmx_path(&path); - if (err) { - result = ERR_PTR(err); - goto out; + /* Has the devpts filesystem already been found? */ + if (path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC) { + int err; + + err = devpts_ptmx_path(&path); + if (err) { + result = ERR_PTR(err); + goto out; + } } /* -- 2.15.1