From patchwork Fri Sep 7 14:18:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1422871 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 01FD0DF283 for ; Fri, 7 Sep 2012 14:23:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760727Ab2IGOS6 (ORCPT ); Fri, 7 Sep 2012 10:18:58 -0400 Received: from mail-vb0-f46.google.com ([209.85.212.46]:38547 "EHLO mail-vb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760658Ab2IGOSm (ORCPT ); Fri, 7 Sep 2012 10:18:42 -0400 Received: by vbbff1 with SMTP id ff1so3363795vbb.19 for ; Fri, 07 Sep 2012 07:18:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=lMWbQBQB0pLceonuMlA8ePLkZI6ro5hHpkjZ2I0zSfs=; b=bidAmqFIsZjW7YLZmKsnhMb9ptKCZQ+sXszeEHbK96Td6KlrYX3HdyLW0YV7aqnnUZ tJte43OFvUux9LV280C0UUY0krDmVhfBiQ7q/97yvz6RFdOUFev7mUuR1GIDHKdK40vw 5eDCPTSeHkcUDovaK4jpHAV4rV6Zf6QTPSvPlI7h5KpI9e/xksgt/p3jcVhBGdxMKwJg klfnLMWMjrJePF2rfva6Cm+DMA3HrTvI7SFP9CuNv/n4IVdOJ6rY6Q8kEWVpkhaBiYkz IlDhzCPO5Ht9q8wGs3PbNB+i4bwlpkq75dSo4Xe/IXf1yFNw5gOSqJU+OaxLh2mPJRUm cXPA== Received: by 10.220.248.72 with SMTP id mf8mr7334643vcb.15.1347027521395; Fri, 07 Sep 2012 07:18:41 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-069-134-145-027.nc.res.rr.com. [69.134.145.27]) by mx.google.com with ESMTPS id v9sm3207113ves.8.2012.09.07.07.18.40 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 07:18:40 -0700 (PDT) From: Jeff Layton To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, michael.brantley@deshaw.com, hch@infradead.org, miklos@szeredi.hu, pstaubach@exagrid.com Subject: [PATCH v6 04/20] vfs: add new "reval" argument to kern_path_create and user_path_create Date: Fri, 7 Sep 2012 10:18:11 -0400 Message-Id: <1347027507-20956-5-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1347027507-20956-1-git-send-email-jlayton@redhat.com> References: <1347027507-20956-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQk7n9Huqeel3uL6Ogbwg2u7DeXrglP0DLelU2vGJJ3mwvdt+WZqvojCAjXeujyox8aOxfVf Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org ...for now, all of the callers pass in "false". Eventually, we'll set that to "true" when we retry the lookup after getting back an ESTALE on a call. While we're at it, change the is_dir arg to a bool since that's how it's used currently. Signed-off-by: Jeff Layton --- arch/powerpc/platforms/cell/spufs/syscalls.c | 2 +- drivers/base/devtmpfs.c | 7 ++++--- fs/namei.c | 23 +++++++++++++++-------- fs/ocfs2/refcounttree.c | 3 ++- include/linux/namei.h | 4 ++-- net/unix/af_unix.c | 2 +- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c index 5b7d8ff..cb4acc7 100644 --- a/arch/powerpc/platforms/cell/spufs/syscalls.c +++ b/arch/powerpc/platforms/cell/spufs/syscalls.c @@ -66,7 +66,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags, struct dentry *dentry; int ret; - dentry = user_path_create(AT_FDCWD, pathname, &path, 1); + dentry = user_path_create(AT_FDCWD, pathname, &path, true, false); ret = PTR_ERR(dentry); if (!IS_ERR(dentry)) { ret = spufs_create(&path, dentry, flags, mode, neighbor); diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index deb4a45..2124437 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -148,7 +148,7 @@ static int dev_mkdir(const char *name, umode_t mode) struct path path; int err; - dentry = kern_path_create(AT_FDCWD, name, &path, 1); + dentry = kern_path_create(AT_FDCWD, name, &path, true, false); if (IS_ERR(dentry)) return PTR_ERR(dentry); @@ -193,10 +193,11 @@ static int handle_create(const char *nodename, umode_t mode, struct device *dev) struct path path; int err; - dentry = kern_path_create(AT_FDCWD, nodename, &path, 0); + dentry = kern_path_create(AT_FDCWD, nodename, &path, false, false); if (dentry == ERR_PTR(-ENOENT)) { create_path(nodename); - dentry = kern_path_create(AT_FDCWD, nodename, &path, 0); + dentry = kern_path_create(AT_FDCWD, nodename, &path, + false, false); } if (IS_ERR(dentry)) return PTR_ERR(dentry); diff --git a/fs/namei.c b/fs/namei.c index 6f9040c..d71be0b 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3038,12 +3038,18 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, return file; } -struct dentry *kern_path_create(int dfd, const char *pathname, struct path *path, int is_dir) +struct dentry *kern_path_create(int dfd, const char *pathname, struct path *path, bool is_dir, bool reval) { struct dentry *dentry = ERR_PTR(-EEXIST); struct nameidata nd; int err2; - int error = do_path_lookup(dfd, pathname, LOOKUP_PARENT, &nd); + int error; + unsigned int lookup_flags = LOOKUP_PARENT; + + if (reval) + lookup_flags |= LOOKUP_REVAL; + + error = do_path_lookup(dfd, pathname, lookup_flags, &nd); if (error) return ERR_PTR(error); @@ -3107,13 +3113,14 @@ void done_path_create(struct path *path, struct dentry *dentry) } EXPORT_SYMBOL(done_path_create); -struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, int is_dir) +struct dentry *user_path_create(int dfd, const char __user *pathname, + struct path *path, bool is_dir, bool reval) { struct getname_info *tmp = getname(pathname); struct dentry *res; if (IS_ERR(tmp)) return ERR_CAST(tmp); - res = kern_path_create(dfd, tmp->name, path, is_dir); + res = kern_path_create(dfd, tmp->name, path, is_dir, reval); putname(tmp); return res; } @@ -3174,7 +3181,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode, if (error) return error; - dentry = user_path_create(dfd, filename, &path, 0); + dentry = user_path_create(dfd, filename, &path, false, false); if (IS_ERR(dentry)) return PTR_ERR(dentry); @@ -3236,7 +3243,7 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode) struct path path; int error; - dentry = user_path_create(dfd, pathname, &path, 1); + dentry = user_path_create(dfd, pathname, &path, true, false); if (IS_ERR(dentry)) return PTR_ERR(dentry); @@ -3512,7 +3519,7 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname, if (IS_ERR(from)) return PTR_ERR(from); - dentry = user_path_create(newdfd, newname, &path, 0); + dentry = user_path_create(newdfd, newname, &path, false, false); error = PTR_ERR(dentry); if (IS_ERR(dentry)) goto out_putname; @@ -3612,7 +3619,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname, if (error) return error; - new_dentry = user_path_create(newdfd, newname, &new_path, 0); + new_dentry = user_path_create(newdfd, newname, &new_path, false, false); error = PTR_ERR(new_dentry); if (IS_ERR(new_dentry)) goto out; diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 30a0550..645e225 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4453,7 +4453,8 @@ int ocfs2_reflink_ioctl(struct inode *inode, return error; } - new_dentry = user_path_create(AT_FDCWD, newname, &new_path, 0); + new_dentry = user_path_create(AT_FDCWD, newname, &new_path, + false, false); error = PTR_ERR(new_dentry); if (IS_ERR(new_dentry)) { mlog_errno(error); diff --git a/include/linux/namei.h b/include/linux/namei.h index 4bf19d8..2202740 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -65,8 +65,8 @@ extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, extern int kern_path(const char *, unsigned, struct path *); -extern struct dentry *kern_path_create(int, const char *, struct path *, int); -extern struct dentry *user_path_create(int, const char __user *, struct path *, int); +extern struct dentry *kern_path_create(int, const char *, struct path *, bool, bool); +extern struct dentry *user_path_create(int, const char __user *, struct path *, bool, bool); extern void done_path_create(struct path *, struct dentry *); extern struct dentry *kern_path_locked(const char *, struct path *); extern int vfs_path_lookup(struct dentry *, struct vfsmount *, diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index c5ee4ff..f15b0ff 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -832,7 +832,7 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res) * Get the parent directory, calculate the hash for last * component. */ - dentry = kern_path_create(AT_FDCWD, sun_path, &path, 0); + dentry = kern_path_create(AT_FDCWD, sun_path, &path, false, false); err = PTR_ERR(dentry); if (IS_ERR(dentry)) return err;