Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1123651ybl; Sat, 18 Jan 2020 19:21:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxDwaHMaIo/ZEaY7GLSYvNnLrkJ4ScxNUYwyU6I/Ubnl3LzC5hfzI0FDUg1jeqst6CVTWbd X-Received: by 2002:a54:4595:: with SMTP id z21mr8934915oib.136.1579404083603; Sat, 18 Jan 2020 19:21:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579404083; cv=none; d=google.com; s=arc-20160816; b=uqqLMJeCsFSNC0aFcSgmzCeDc/2MzAkrG6jXWqDygAX6qKTl8xKr4uMLkeGOwmApw5 ZCc4dVa26JFmg9067cfxbxqE59JWDVvh/d3LwgTotft9iYDlqdrUcLE4qWeOiFzsckXH hUsXnW0/sx4UkWERwmHlwSrULFB+wlbNIUMo5yNDJyiPxg6kF74u4scey0Boe0uis8OP e5fqNY0zLjdqgrbv3gWW4H5OF4oHZUXY2DWAIfs4tRUnH3JN/3K5Rn/xdjSJMu65dDFr baQclpUJpXNrqgdfEfoMNyl1ZIkVESpeL9fdq+EHryt597+MoGw+TeflZn9MJly8j96S ThTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vF2e+ovR0ZeQaI9yPyeV0y4RmU5lMaOvSFbwG7LjaBE=; b=07NXvGxhZlSxCykUQbx36uuGyUAdd+7kKiN1ffpXcDZcrbFBNUl6J6YvjhpBLVvcNb jTiSVsvBFrhh5INiV2DavsL57bpzUHMJeqksG+TCPkKuJP8ZM7By0W9XxWaQdNdWzZmh CrBGWp30+GEf/0mN+Op+7XPnvg5nBN+xTrmYNFgvUzqos3D5VF3LmHzFJ0POlv6rk5b0 cMuZ/IWwWchE2vvbCzuOtyxtrSHN+0r5qce2zPKZsDxcL0d9mfUA2M0KBg9zFshttzte yRLuRgd9d+JWdO2LZ4RtyNk1daC3o8ILSGic4lrAilFSc/D/J5Z05xEtOHquN0JCoRFB LUaA== 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 f81si16536417oig.110.2020.01.18.19.21.11; Sat, 18 Jan 2020 19:21:23 -0800 (PST) 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 S1727138AbgASDUD (ORCPT + 99 others); Sat, 18 Jan 2020 22:20:03 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:56742 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgASDUD (ORCPT ); Sat, 18 Jan 2020 22:20:03 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1it17e-00BFXJ-12; Sun, 19 Jan 2020 03:19:41 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Aleksa Sarai , David Howells , Eric Biederman , Christian Brauner , Al Viro Subject: [PATCH 07/17] atomic_open(): saner calling conventions (return dentry on success) Date: Sun, 19 Jan 2020 03:17:19 +0000 Message-Id: <20200119031738.2681033-7-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200119031738.2681033-1-viro@ZenIV.linux.org.uk> References: <20200119031423.GV8904@ZenIV.linux.org.uk> <20200119031738.2681033-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro Currently it either returns -E... or puts (nd->path.mnt,dentry) into *path and returns 0. Make it return ERR_PTR(-E...) or dentry; adjust the caller. Fewer arguments and it's easier to keep track of *path contents that way. Signed-off-by: Al Viro --- fs/namei.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 4c867d0970d5..9d8837432a7b 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2955,10 +2955,10 @@ static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t m * * Returns an error code otherwise. */ -static int atomic_open(struct nameidata *nd, struct dentry *dentry, - struct path *path, struct file *file, - const struct open_flags *op, - int open_flag, umode_t mode) +static struct dentry *atomic_open(struct nameidata *nd, struct dentry *dentry, + struct file *file, + const struct open_flags *op, + int open_flag, umode_t mode) { struct dentry *const DENTRY_NOT_SET = (void *) -1UL; struct inode *dir = nd->path.dentry->d_inode; @@ -2999,17 +2999,15 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, } if (file->f_mode & FMODE_CREATED) fsnotify_create(dir, dentry); - if (unlikely(d_is_negative(dentry))) { + if (unlikely(d_is_negative(dentry))) error = -ENOENT; - } else { - path->dentry = dentry; - path->mnt = nd->path.mnt; - return 0; - } } } - dput(dentry); - return error; + if (error) { + dput(dentry); + dentry = ERR_PTR(error); + } + return dentry; } /* @@ -3104,11 +3102,16 @@ static int lookup_open(struct nameidata *nd, struct path *path, } if (dir_inode->i_op->atomic_open) { - error = atomic_open(nd, dentry, path, file, op, open_flag, - mode); - if (unlikely(error == -ENOENT) && create_error) - error = create_error; - return error; + dentry = atomic_open(nd, dentry, file, op, open_flag, mode); + if (IS_ERR(dentry)) { + error = PTR_ERR(dentry); + if (unlikely(error == -ENOENT) && create_error) + error = create_error; + return error; + } + path->mnt = nd->path.mnt; + path->dentry = dentry; + return 0; } no_open: -- 2.20.1