Received: by 2002:ac0:adb4:0:0:0:0:0 with SMTP id o49-v6csp6580imb; Tue, 10 Jul 2018 19:28:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd1ViCJgeDYwjvCBCX4apszzRDEt7diQXyhPTNIdYAuRNu8gMUt5LK4v4X0nqoGIinDAhid X-Received: by 2002:a17:902:3343:: with SMTP id a61-v6mr26416758plc.241.1531276107160; Tue, 10 Jul 2018 19:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531276107; cv=none; d=google.com; s=arc-20160816; b=biAWPDjk8stmE/t1NRR5mXTKp46uFIg+lskRgq7XOngv7AlfUpHN1d2YlaBFUxd2jm tNvKogBqcjdetZrJEurg/I4koVNfohhGfO3/Bre/UyaBEIIwgkSJt3hxM9QvafbWzQ42 6uTejaKpYlCwtyPCTq7mbMuZHyny0BHjSYjmJOwcnFzLZ2BYN9gWRP2STZXv1iei1wwc B091yc7fWou9bVX7wMMPeUuGSTprK5u0uUNgtE4hwexe6BkJwQWH/bw3pOkYk+MgArqc IrnvUfb4+lKwWnqwDmIWU1RU3H/horF9p5fDiuh59shLc64m5L4feAMk5+w1lGYqL8dg Qluw== 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=7i+uM+LMufN/QaudKBiOTwDlxrjqSmAr4eI9m0a0hS0=; b=jiNppTVLWz35d9IGv5DX8FzipvZfFtJ+d5XpHTxJK8Ltc04GhsGj8meXwyVJ1v2zAO uzVBY456mCAZDCU59k9+hUgwqF+wlkKX8sBOP6ycU8CcJoTBA0O+hK6CLFS9FgI/o8LV QTDx5F7ZeNPZmcRZUhX49HdEsYlvIDynKZTLKrB/CPJt7cHCc9X7RUfQ5TVZWKhBG3gD gzPiJUD/iBizmXi9H1/Mb13jRL7bdDCzsuyz7eOMbSMoMFrsMjgDJGPZLXcWzImZ9sU/ ir2I42zcrcjEMS4lZVnMwVEx02BADx67gSCU4QqwrsHTUUSfaCOJR/DHvdNOAJh4RI33 97Vg== 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 s71-v6si19271120pfa.367.2018.07.10.19.28.11; Tue, 10 Jul 2018 19:28:27 -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 S1732557AbeGKC2T (ORCPT + 99 others); Tue, 10 Jul 2018 22:28:19 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45578 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732384AbeGKCYE (ORCPT ); Tue, 10 Jul 2018 22:24:04 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fd4lb-0003J0-Oy; 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 16/42] now we can fold open_check_o_direct() into do_dentry_open() Date: Wed, 11 Jul 2018 03:21:40 +0100 Message-Id: <20180711022206.12571-16-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 Signed-off-by: Al Viro --- fs/internal.h | 1 - fs/namei.c | 7 +------ fs/open.c | 17 +++++------------ 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index ab84a29f4874..33a28438570e 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -125,7 +125,6 @@ int do_fchmodat(int dfd, const char __user *filename, umode_t mode); int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, int flag); -extern int open_check_o_direct(struct file *f); extern int vfs_open(const struct path *, struct file *); /* diff --git a/fs/namei.c b/fs/namei.c index 5a79bd170410..39b5da70d6f5 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3401,9 +3401,7 @@ static int do_last(struct nameidata *nd, goto out; *opened |= FILE_OPENED; opened: - error = open_check_o_direct(file); - if (!error) - error = ima_file_check(file, op->acc_mode, *opened); + error = ima_file_check(file, op->acc_mode, *opened); if (!error && will_truncate) error = handle_truncate(file); out: @@ -3479,9 +3477,6 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags, goto out2; file->f_path.mnt = path.mnt; error = finish_open(file, child, NULL, opened); - if (error) - goto out2; - error = open_check_o_direct(file); out2: mnt_drop_write(path.mnt); out: diff --git a/fs/open.c b/fs/open.c index affdeebe5fd5..2aa3dc03e2fd 100644 --- a/fs/open.c +++ b/fs/open.c @@ -724,16 +724,6 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group) return ksys_fchown(fd, user, group); } -int open_check_o_direct(struct file *f) -{ - /* NB: we're sure to have correct a_ops only after f_op->open */ - if (f->f_flags & O_DIRECT) { - if (!f->f_mapping->a_ops || !f->f_mapping->a_ops->direct_IO) - return -EINVAL; - } - return 0; -} - static int do_dentry_open(struct file *f, struct inode *inode, int (*open)(struct inode *, struct file *)) @@ -809,6 +799,11 @@ static int do_dentry_open(struct file *f, file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping); + /* NB: we're sure to have correct a_ops only after f_op->open */ + if (f->f_flags & O_DIRECT) { + if (!f->f_mapping->a_ops || !f->f_mapping->a_ops->direct_IO) + return -EINVAL; + } return 0; cleanup_all: @@ -925,8 +920,6 @@ struct file *dentry_open(const struct path *path, int flags, if (!IS_ERR(f)) { f->f_flags = flags; error = vfs_open(path, f); - if (!error) - error = open_check_o_direct(f); if (error) { fput(f); f = ERR_PTR(error); -- 2.11.0