From patchwork Fri Mar 13 23:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 11438005 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15E2614B4 for ; Fri, 13 Mar 2020 23:54:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E62FD2074E for ; Fri, 13 Mar 2020 23:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727767AbgCMXyI (ORCPT ); Fri, 13 Mar 2020 19:54:08 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:50210 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727855AbgCMXyH (ORCPT ); Fri, 13 Mar 2020 19:54:07 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCu7y-00B6ex-IU; Fri, 13 Mar 2020 23:54:06 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v4 67/69] open_last_lookups(): move complete_walk() into do_open() Date: Fri, 13 Mar 2020 23:53:55 +0000 Message-Id: <20200313235357.2646756-67-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200313235357.2646756-1-viro@ZenIV.linux.org.uk> References: <20200313235303.GP23230@ZenIV.linux.org.uk> <20200313235357.2646756-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Al Viro Signed-off-by: Al Viro --- fs/namei.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 3e1573373773..88ff59dcfd47 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3127,10 +3127,7 @@ static const char *open_last_lookups(struct nameidata *nd, if (nd->last_type != LAST_NORM) { if (nd->depth) put_link(nd); - res = handle_dots(nd, nd->last_type); - if (likely(!res)) - res = ERR_PTR(complete_walk(nd)); - return res; + return handle_dots(nd, nd->last_type); } if (!(open_flag & O_CREAT)) { @@ -3195,13 +3192,9 @@ static const char *open_last_lookups(struct nameidata *nd, if (nd->depth) put_link(nd); res = step_into(nd, WALK_TRAILING, dentry, inode, seq); - if (unlikely(res)) { + if (unlikely(res)) nd->flags &= ~(LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_EXCL); - return res; - } - - /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */ - return ERR_PTR(complete_walk(nd)); + return res; } /* @@ -3215,6 +3208,11 @@ static int do_open(struct nameidata *nd, int acc_mode; int error; + if (!(file->f_mode & (FMODE_OPENED | FMODE_CREATED))) { + error = complete_walk(nd); + if (error) + return error; + } if (!(file->f_mode & FMODE_CREATED)) audit_inode(nd->name, nd->path.dentry, 0); if (open_flag & O_CREAT) {