Received: by 2002:ac0:adb4:0:0:0:0:0 with SMTP id o49-v6csp5438imb; Tue, 10 Jul 2018 19:26:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeubdONOz7NueQunwWKNqPm7U+XLjHcFxql6aRqPcC7rMqoRBnWz6D//zAmg01xP+0SjXTB X-Received: by 2002:a17:902:7044:: with SMTP id h4-v6mr21653893plt.179.1531276009263; Tue, 10 Jul 2018 19:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531276009; cv=none; d=google.com; s=arc-20160816; b=KDwrB7JuTUTpEH0tAEO1YLb7AKTvsCidDb1SyqSVTNvU/ip7eQ6eByeYd9I07tUNO7 nAX6c3LWEJ8Fqr9WozFbS3MA1dIQZnEypgb2/u/ZXj4lm+JedmJ9w1N3WZxx5MECgclB Hzj6hNNsnVbW3LOGGojQj6d6Mz63yeL+SSDQKkaj2bCWY3nSYkfXhg553gCRLw+C7fMs 1kWm/jIEIiKCMpC4gEEKXtagR4VwhkGgbVhCkno8i/J/xTFwmTS5NsrG4CqmZWQ7hbxX BCRDR7yoLYVmvFfqTanuuI18+OpEwclauTGjr3evTo/HgaUew2dJE8yNgLekhIgSivdi /d4Q== 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=ktNdwwwTogNShevBGa5ejLotMkfRa5Z5l7WbgOiZoVo=; b=jw3AA7I5762Qzk8TkAK1gAb0ftqaCY7bSNXl2Tp05JKFJeePyM7zsJ2yWiM7t0TheT VbUH92Y1i55ZLF0jq3hMI8yGrGZOnudaJ3MQwzcDNVdu1ppBYuuTsoqYfmrrC4kpGRae XIt7dFluZ0b5KvfSnvEuuq/1LOFQWi1QEbM6D+MmxiEKCDvWk5zw5KpeMRAwXCJraNfG 5n+uu6rRbKWZIak5q6K1a6+jsa20RUN9tWzsvjVD5Ts8sRRaAPMkSn1WuKiuDFwa6epv HJLHzGSuUldzEBsL3fIOgOqlhz7Z7vNbDwAEVCwL9fSNFUgIcCkUFd+dzIMXknJtf60s fFQA== 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 e4-v6si18270609pfi.184.2018.07.10.19.26.33; Tue, 10 Jul 2018 19:26:49 -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 S1732853AbeGKC1G (ORCPT + 99 others); Tue, 10 Jul 2018 22:27:06 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45582 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732387AbeGKCYF (ORCPT ); Tue, 10 Jul 2018 22:24:05 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fd4lb-0003J7-Sq; Wed, 11 Jul 2018 02:22:07 +0000 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Miklos Szeredi Subject: [RFC][PATCH 17/42] switch all remaining checks for FILE_OPENED to FMODE_OPENED Date: Wed, 11 Jul 2018 03:21:41 +0100 Message-Id: <20180711022206.12571-17-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180711022206.12571-1-viro@ZenIV.linux.org.uk> References: <20180711021136.GN30522@ZenIV.linux.org.uk> <20180711022206.12571-1-viro@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro ... and don't bother with setting FILE_OPENED at all. Signed-off-by: Al Viro --- fs/gfs2/inode.c | 2 +- fs/namei.c | 7 ++----- fs/open.c | 9 ++------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index feda55f67050..67c588edf8d8 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1250,7 +1250,7 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry, if (d != NULL) dentry = d; if (d_really_is_positive(dentry)) { - if (!(*opened & FILE_OPENED)) + if (!(file->f_mode & FMODE_OPENED)) return finish_no_open(file, d); dput(d); return 0; diff --git a/fs/namei.c b/fs/namei.c index 39b5da70d6f5..ad8d53c3243c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3395,11 +3395,10 @@ static int do_last(struct nameidata *nd, error = may_open(&nd->path, acc_mode, open_flag); if (error) goto out; - BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ + BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */ error = vfs_open(&nd->path, file); if (error) goto out; - *opened |= FILE_OPENED; opened: error = ima_file_check(file, op->acc_mode, *opened); if (!error && will_truncate) @@ -3517,8 +3516,6 @@ static struct file *path_openat(struct nameidata *nd, if (unlikely(file->f_flags & O_PATH)) { error = do_o_path(nd, flags, file); - if (!error) - opened |= FILE_OPENED; goto out2; } @@ -3539,7 +3536,7 @@ static struct file *path_openat(struct nameidata *nd, terminate_walk(nd); out2: if (likely(!error)) { - if (likely(opened & FILE_OPENED)) + if (likely(file->f_mode & FMODE_OPENED)) return file; WARN_ON(1); error = -EINVAL; diff --git a/fs/open.c b/fs/open.c index 2aa3dc03e2fd..1f379656feab 100644 --- a/fs/open.c +++ b/fs/open.c @@ -849,15 +849,10 @@ int finish_open(struct file *file, struct dentry *dentry, int (*open)(struct inode *, struct file *), int *opened) { - int error; - BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ + BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */ file->f_path.dentry = dentry; - error = do_dentry_open(file, d_backing_inode(dentry), open); - if (!error) - *opened |= FILE_OPENED; - - return error; + return do_dentry_open(file, d_backing_inode(dentry), open); } EXPORT_SYMBOL(finish_open); -- 2.11.0