linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org,
	David Howells <dhowells@redhat.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Mike Marshall <hubcap@omnibond.com>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Bob Peterson <rpeterso@redhat.com>,
	Steve French <sfrench@samba.org>,
	Richard Weinberger <richard@nod.at>,
	Dominique Martinet <asmadeus@codewreck.org>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v2 10/15] cifs: have ->mkdir() handle race with another client sanely
Date: Mon, 15 Mar 2021 13:08:53 -0400	[thread overview]
Message-ID: <33555846ce325ceb7b282f359861fbbcf22840ec.camel@kernel.org> (raw)
In-Reply-To: <20210313043824.1283821-10-viro@zeniv.linux.org.uk>

On Sat, 2021-03-13 at 04:38 +0000, Al Viro wrote:
> if we have mkdir request reported successful *and* simulating lookup
> gets us a non-directory (which is possible if another client has
> managed to get rmdir and create in between), the sane action is not
> to mangle ->i_mode of non-directory inode to S_IFDIR | mode, it's
> "report success and return with dentry negative unhashed" - that
> way the next lookup will do the right thing.
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  fs/cifs/inode.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index d46b36d52211..80c487fcf10e 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -1739,6 +1739,16 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
>  	if (rc)
>  		return rc;
>  
> 
> +	if (!S_ISDIR(inode->i_mode)) {
> +		/*
> +		 * mkdir succeeded, but another client has managed to remove the
> +		 * sucker and replace it with non-directory.  Return success,
> +		 * but don't leave the child in dcache.
> +		 */
> +		 iput(inode);
> +		 d_drop(dentry);
> +		 return 0;
> +	}
>  	/*
>  	 * setting nlink not necessary except in cases where we failed to get it
>  	 * from the server or was set bogus. Also, since this is a brand new
> @@ -1790,7 +1800,7 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
>  		}
>  	}
>  	d_instantiate(dentry, inode);
> -	return rc;
> +	return 0;
>  }
>  
> 
>  static int

Reviewed-by: Jeff Layton <jlayton@kernel.org>


  reply	other threads:[~2021-03-15 17:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <YDqRThxQOVQO9uOx@zeniv-ca.linux.org.uk>
2021-03-13  4:35 ` [RFC][PATCHSET v2] inode type bits fixes Al Viro
2021-03-13  4:38   ` [PATCH v2 01/15] new helper: inode_wrong_type() Al Viro
2021-03-13  4:38     ` [PATCH v2 02/15] ceph: fix up error handling with snapdirs Al Viro
2021-03-13  4:38     ` [PATCH v2 03/15] ceph: don't allow type or device number to change on non-I_NEW inodes Al Viro
2021-03-13  4:38     ` [PATCH v2 04/15] afs: Fix updating of i_mode due to 3rd party change Al Viro
2021-03-13  4:38     ` [PATCH v2 05/15] vboxsf: don't allow to change the inode type Al Viro
2021-03-13  4:38     ` [PATCH v2 06/15] orangefs_inode_is_stale(): i_mode type bits do *not* form a bitmap Al Viro
2021-03-13  4:38     ` [PATCH v2 07/15] ocfs2_inode_lock_update(): make sure we don't change the type bits of i_mode Al Viro
2021-03-13  4:38     ` [PATCH v2 08/15] gfs2: be careful with inode refresh Al Viro
2021-03-13  4:38     ` [PATCH v2 09/15] do_cifs_create(): don't set ->i_mode of something we had not created Al Viro
2021-03-15 17:12       ` Jeff Layton
2021-03-13  4:38     ` [PATCH v2 10/15] cifs: have ->mkdir() handle race with another client sanely Al Viro
2021-03-15 17:08       ` Jeff Layton [this message]
2021-03-13  4:38     ` [PATCH v2 11/15] cifs: have cifs_fattr_to_inode() refuse to change type on live inode Al Viro
2021-03-15 17:13       ` Jeff Layton
2021-03-13  4:38     ` [PATCH v2 12/15] hostfs_mknod(): don't bother with init_special_inode() Al Viro
2021-03-13  4:38     ` [PATCH v2 13/15] openpromfs: don't do unlock_new_inode() until the new inode is set up Al Viro
2021-03-13  4:38     ` [PATCH v2 14/15] 9p: missing chunk of "fs/9p: Don't update file type when updating file attributes" Al Viro
2021-03-15 17:14       ` Jeff Layton
2021-03-13  4:38     ` [PATCH v2 15/15] spufs: fix bogosity in S_ISGID handling Al Viro
2021-03-15 17:19     ` [PATCH v2 01/15] new helper: inode_wrong_type() 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=33555846ce325ceb7b282f359861fbbcf22840ec.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=arnd@arndb.de \
    --cc=asmadeus@codewreck.org \
    --cc=dhowells@redhat.com \
    --cc=hdegoede@redhat.com \
    --cc=hubcap@omnibond.com \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=richard@nod.at \
    --cc=rpeterso@redhat.com \
    --cc=sfrench@samba.org \
    --cc=torvalds@linux-foundation.org \
    --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).