From patchwork Fri Jun 29 18:57:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1133321 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 2CBF7DFF34 for ; Fri, 29 Jun 2012 19:02:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932681Ab2F2TB6 (ORCPT ); Fri, 29 Jun 2012 15:01:58 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:36203 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932678Ab2F2S6S (ORCPT ); Fri, 29 Jun 2012 14:58:18 -0400 Received: by mail-gh0-f174.google.com with SMTP id r11so3053276ghr.19 for ; Fri, 29 Jun 2012 11:58:17 -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=lwWE9KD6Xjfkp13X/pAWDPoFyTgPkk5g8svvNai/Zvc=; b=N2aLWNaPB3ZzUpEx7qWIj+82hBlE4N6AN3FDQPg7+CECXy+ts6keQz+cmPN3tVaHv0 ca7/wjZOkBJloV/gwYR0Ml5mawSkJSe/Fy3ifILg6NRZJERAT+LTSgwr/ghOVIRseC+o cJFWSEYoGrQ1YiVog7xc3C5iEYOmSlARolocsGvNJD0FHZT6aBzuEo/zzmJt711l4V4l CoG7kHun7kRcVyVsWcjRBbKNMdLsT5l4p5VhCbl6pDhxUyrdTIDsl7NE6cGjz8u0A+1+ yGDGOQtMK4rf8zmni5DoIlsKlO4GdCCDUmCSg+xkUPOuZrkAX9+zG0ZDYU4SmEaD5Aj+ Ju9Q== Received: by 10.236.191.138 with SMTP id g10mr4527844yhn.25.1340996297773; Fri, 29 Jun 2012 11:58:17 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-076-182-054-194.nc.res.rr.com. [76.182.54.194]) by mx.google.com with ESMTPS id l13sm3936309ann.2.2012.06.29.11.58.16 (version=SSLv3 cipher=OTHER); Fri, 29 Jun 2012 11:58:16 -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 v3 07/17] vfs: add new "reval" argument to kern_path_create Date: Fri, 29 Jun 2012 14:57:50 -0400 Message-Id: <1340996280-27123-8-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1340996280-27123-1-git-send-email-jlayton@redhat.com> References: <1340996280-27123-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQkRK2xiR0Fr1QY2iAErxWjr8A1Un+cfYtMynA5PrZT2emBBIRnOLDxLn2pGjZJD7WJVzbNy 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 --- drivers/base/devtmpfs.c | 7 ++++--- fs/namei.c | 12 +++++++++--- include/linux/namei.h | 2 +- net/unix/af_unix.c | 3 ++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 765c3a2..fdd1bff 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); @@ -195,10 +195,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 a20faa5..86aa8ee 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2536,11 +2536,17 @@ 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 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); @@ -2594,7 +2600,7 @@ struct dentry *user_path_create(int dfd, const char __user *pathname, struct pat struct dentry *res; if (IS_ERR(tmp)) return ERR_CAST(tmp); - res = kern_path_create(dfd, tmp, path, is_dir); + res = kern_path_create(dfd, tmp, path, (bool)is_dir, false); putname(tmp); return res; } diff --git a/include/linux/namei.h b/include/linux/namei.h index 1ea93d5..9e135e3 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -76,7 +76,7 @@ extern int user_path_at(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 *kern_path_create(int, const char *, struct path *, bool, bool); extern struct dentry *user_path_create(int, const char __user *, struct path *, int); extern int kern_path_parent(const char *, struct nameidata *); extern int vfs_path_lookup(struct dentry *, struct vfsmount *, diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 641f2e4..d94caa9 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -866,7 +866,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) * 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)) goto out_mknod_parent;