From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1C38C3279B for ; Wed, 11 Jul 2018 02:25:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0C8120936 for ; Wed, 11 Jul 2018 02:25:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0C8120936 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ZenIV.linux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732856AbeGKC1G (ORCPT ); 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