linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: Trond Myklebust <trond.myklebust@primarydata.com>,
	Jeff Layton <jlayton@poochiereds.net>,
	Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
	Oleg Drokin <green@linuxhacker.ru>
Subject: [PATCH 2/2] staging/lustre: Prevent spurious EPERM on mkdir
Date: Thu,  7 Jul 2016 01:53:47 -0400	[thread overview]
Message-ID: <1467870827-2959489-3-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1467870827-2959489-1-git-send-email-green@linuxhacker.ru>

if the name already exists, but we don't have write permissions
in the parent

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/llite/namei.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 9321bd8..4c3dde1 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -544,8 +544,12 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
 	CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p),flags=%u\n",
 	       dentry, PFID(ll_inode2fid(parent)), parent, flags);
 
-	/* Optimize away (CREATE && !OPEN). Let .create handle the race. */
-	if ((flags & LOOKUP_CREATE) && !(flags & LOOKUP_OPEN))
+	/* Optimize away (CREATE && !OPEN). Let .create handle the race.
+	 * but only if we have write permissions there, otherwise we need
+	 * to proceed with lookup. LU-4185
+	 */
+	if ((flags & LOOKUP_CREATE) && !(flags & LOOKUP_OPEN) &&
+	    (inode_permission(parent, MAY_WRITE | MAY_EXEC) == 0))
 		return NULL;
 
 	if (flags & (LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE))
-- 
2.7.4


  parent reply	other threads:[~2016-07-07  5:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-07  5:53 [RFC] [PATCH 0/2] mkdir lookup optimization Oleg Drokin
2016-07-07  5:53 ` [PATCH 1/2] nfs: Fix spurios EPERM when mkdir of existing dentry Oleg Drokin
2016-07-07 16:16   ` Trond Myklebust
2016-07-07 16:52     ` Oleg Drokin
2016-07-07 16:59       ` Trond Myklebust
2016-07-07 17:07         ` Oleg Drokin
2016-07-07 17:27           ` Trond Myklebust
2016-07-07 17:32             ` Oleg Drokin
2016-07-07 21:52             ` Oleg Drokin
2016-07-07 23:17               ` Trond Myklebust
2016-07-07  5:53 ` Oleg Drokin [this message]
2016-07-07 10:53 ` [RFC] [PATCH 0/2] mkdir lookup optimization Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467870827-2959489-3-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=jlayton@poochiereds.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@primarydata.com \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).