Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1466879

[PATCH 08/13] staging/lustre: Always return EEXIST on mkdir for existing names

From Oleg Drokin <green@linuxhacker.ru>
Newsgroups linux.kernel
Subject [PATCH 08/13] staging/lustre: Always return EEXIST on mkdir for existing names
Date 2016-08-20 23:40 +0200
Message-ID <s8m9I-8ms-33@gated-at.bofh.it> (permalink)
References <s8m9H-8ms-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


if the name already exists, but we don't have write permissions
in the parent, force talking to the MDS to determine what
more sensical error code to return.
This also happens to fix matlab and other such programs that
assume that EEXIST is the only valid error code for mkdir of
an existing directory.

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 09e1801..8350943 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -541,8 +541,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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/13] Lustre patches Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
  [PATCH 04/13] lustre: ->kss_scratch... are unused now Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
  [PATCH 01/13] ksocknal_lib_recv_iov(): recvmsg doesn't bugger iovec anymore... Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
  [PATCH 02/13] ksocknal_lib_send_iov(): sendmsg doesn't bugger iovec... Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
  [PATCH 07/13] lustre: introduce lnet_copy_{k,}iov2iter(), kill lnet_copy_{k,}iov2{k,}iov() Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
  [PATCH 09/13] staging/lustre: Add spaces preferred around that '{+,-,*,/,|,<<,>>,&}' Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
    Re: [PATCH 09/13] staging/lustre: Add spaces preferred around that  '{+, -, *, /, |, <<, >>, &}' Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-08-21 23:20 +0200
  [PATCH 05/13] lustre: constify lib-move.c stuff Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
  [PATCH 10/13] staging/lustre: Fix unnecessary parentheses around variables Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
  [PATCH 08/13] staging/lustre: Always return EEXIST on mkdir for existing names Oleg Drokin <green@linuxhacker.ru> - 2016-08-20 23:40 +0200
  Re: [PATCH 11/13] staging/lustre: Make alignment match open  parenthesis Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-08-21 23:20 +0200

csiph-web