linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neilb@suse.de>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	 Christian Brauner	 <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Miklos Szeredi <miklos@szeredi.hu>,  Xiubo Li <xiubli@redhat.com>,
	Ilya Dryomov <idryomov@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	 Anton Ivanov <anton.ivanov@cambridgegreys.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	Trond Myklebust	 <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	Chuck Lever	 <chuck.lever@oracle.com>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo	 <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	Sergey Senozhatsky	 <senozhatsky@chromium.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org,
	 linux-um@lists.infradead.org, ceph-devel@vger.kernel.org,
	netfs@lists.linux.dev
Subject: Re: [PATCH 4/6] fuse: return correct dentry for ->mkdir
Date: Fri, 21 Feb 2025 08:39:29 -0500	[thread overview]
Message-ID: <0542f4a777bb3fc1ef49fc879ac5f12030aa788a.camel@kernel.org> (raw)
In-Reply-To: <20250220234630.983190-5-neilb@suse.de>

On Fri, 2025-02-21 at 10:36 +1100, NeilBrown wrote:
> fuse already uses d_splice_alias() to ensure an appropriate dentry is
> found for a newly created dentry.  Now that ->mkdir can return that
> dentry we do so.
> 
> This requires changing create_new_entry() to return a dentry and
> handling that change in all callers.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>  fs/fuse/dir.c | 55 +++++++++++++++++++++++++++++++--------------------
>  1 file changed, 34 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 5bb65f38bfb8..8c44c9c73c38 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -781,9 +781,9 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
>  /*
>   * Code shared between mknod, mkdir, symlink and link
>   */
> -static int create_new_entry(struct mnt_idmap *idmap, struct fuse_mount *fm,
> -			    struct fuse_args *args, struct inode *dir,
> -			    struct dentry *entry, umode_t mode)
> +static struct dentry *create_new_entry(struct mnt_idmap *idmap, struct fuse_mount *fm,
> +				       struct fuse_args *args, struct inode *dir,
> +				       struct dentry *entry, umode_t mode)
>  {
>  	struct fuse_entry_out outarg;
>  	struct inode *inode;
> @@ -792,11 +792,11 @@ static int create_new_entry(struct mnt_idmap *idmap, struct fuse_mount *fm,
>  	struct fuse_forget_link *forget;
>  
>  	if (fuse_is_bad(dir))
> -		return -EIO;
> +		return ERR_PTR(-EIO);
>  
>  	forget = fuse_alloc_forget();
>  	if (!forget)
> -		return -ENOMEM;
> +		return ERR_PTR(-ENOMEM);
>  
>  	memset(&outarg, 0, sizeof(outarg));
>  	args->nodeid = get_node_id(dir);
> @@ -826,29 +826,27 @@ static int create_new_entry(struct mnt_idmap *idmap, struct fuse_mount *fm,
>  			  &outarg.attr, ATTR_TIMEOUT(&outarg), 0, 0);
>  	if (!inode) {
>  		fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1);
> -		return -ENOMEM;
> +		return ERR_PTR(-ENOMEM);
>  	}
>  	kfree(forget);
>  
>  	d_drop(entry);
>  	d = d_splice_alias(inode, entry);
>  	if (IS_ERR(d))
> -		return PTR_ERR(d);
> +		return d;
>  
> -	if (d) {
> +	if (d)
>  		fuse_change_entry_timeout(d, &outarg);
> -		dput(d);
> -	} else {
> +	else
>  		fuse_change_entry_timeout(entry, &outarg);
> -	}
>  	fuse_dir_changed(dir);
> -	return 0;
> +	return d;
>  
>   out_put_forget_req:
>  	if (err == -EEXIST)
>  		fuse_invalidate_entry(entry);
>  	kfree(forget);
> -	return err;
> +	return ERR_PTR(err);
>  }
>  
>  static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir,
> @@ -856,6 +854,7 @@ static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir,
>  {
>  	struct fuse_mknod_in inarg;
>  	struct fuse_mount *fm = get_fuse_mount(dir);
> +	struct dentry *de;
>  	FUSE_ARGS(args);
>  
>  	if (!fm->fc->dont_mask)
> @@ -871,7 +870,12 @@ static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir,
>  	args.in_args[0].value = &inarg;
>  	args.in_args[1].size = entry->d_name.len + 1;
>  	args.in_args[1].value = entry->d_name.name;
> -	return create_new_entry(idmap, fm, &args, dir, entry, mode);
> +	de = create_new_entry(idmap, fm, &args, dir, entry, mode);
> +	if (IS_ERR(de))
> +		return PTR_ERR(de);
> +	if (de)
> +		dput(de);
> +	return 0;
>  }
>  
>  static int fuse_create(struct mnt_idmap *idmap, struct inode *dir,
> @@ -917,7 +921,7 @@ static struct dentry *fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>  	args.in_args[0].value = &inarg;
>  	args.in_args[1].size = entry->d_name.len + 1;
>  	args.in_args[1].value = entry->d_name.name;
> -	return ERR_PTR(create_new_entry(idmap, fm, &args, dir, entry, S_IFDIR));
> +	return create_new_entry(idmap, fm, &args, dir, entry, S_IFDIR);
>  }
>  
>  static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
> @@ -925,6 +929,7 @@ static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
>  {
>  	struct fuse_mount *fm = get_fuse_mount(dir);
>  	unsigned len = strlen(link) + 1;
> +	struct dentry *de;
>  	FUSE_ARGS(args);
>  
>  	args.opcode = FUSE_SYMLINK;
> @@ -934,7 +939,12 @@ static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
>  	args.in_args[1].value = entry->d_name.name;
>  	args.in_args[2].size = len;
>  	args.in_args[2].value = link;
> -	return create_new_entry(idmap, fm, &args, dir, entry, S_IFLNK);
> +	de = create_new_entry(idmap, fm, &args, dir, entry, S_IFLNK);
> +	if (IS_ERR(de))
> +		return PTR_ERR(de);
> +	if (de)
> +		dput(de);
> +	return 0;
>  }
>  
>  void fuse_flush_time_update(struct inode *inode)
> @@ -1117,7 +1127,7 @@ static int fuse_rename2(struct mnt_idmap *idmap, struct inode *olddir,
>  static int fuse_link(struct dentry *entry, struct inode *newdir,
>  		     struct dentry *newent)
>  {
> -	int err;
> +	struct dentry *de;
>  	struct fuse_link_in inarg;
>  	struct inode *inode = d_inode(entry);
>  	struct fuse_mount *fm = get_fuse_mount(inode);
> @@ -1131,13 +1141,16 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
>  	args.in_args[0].value = &inarg;
>  	args.in_args[1].size = newent->d_name.len + 1;
>  	args.in_args[1].value = newent->d_name.name;
> -	err = create_new_entry(&invalid_mnt_idmap, fm, &args, newdir, newent, inode->i_mode);
> -	if (!err)
> +	de = create_new_entry(&invalid_mnt_idmap, fm, &args, newdir, newent, inode->i_mode);
> +	if (!IS_ERR(de)) {
> +		if (de)
> +			dput(de);
> +		de = NULL;
>  		fuse_update_ctime_in_cache(inode);
> -	else if (err == -EINTR)
> +	} else if (PTR_ERR(de) == -EINTR)
>  		fuse_invalidate_attr(inode);
>  
> -	return err;
> +	return PTR_ERR(de);
>  }
>  
>  static void fuse_fillattr(struct mnt_idmap *idmap, struct inode *inode,

Pretty straightforward.

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


  reply	other threads:[~2025-02-21 13:40 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20 23:36 [PATCH 0/6] Change ->mkdir() and vfs_mkdir() to return a dentry NeilBrown
2025-02-20 23:36 ` [PATCH 1/6] Change inode_operations.mkdir to return struct dentry * NeilBrown
2025-02-22  4:19   ` Al Viro
2025-02-24  1:34     ` NeilBrown
2025-02-24  2:09       ` Al Viro
2025-02-24  3:09         ` NeilBrown
2025-02-24 15:56           ` Trond Myklebust
2025-02-26  2:09             ` NeilBrown
2025-02-26  2:34               ` Trond Myklebust
2025-02-26  3:18                 ` NeilBrown
2025-02-26  3:35                   ` Al Viro
2025-02-22  4:56   ` Al Viro
2025-02-20 23:36 ` [PATCH 2/6] hostfs: store inode in dentry after mkdir if possible NeilBrown
2025-02-21 13:17   ` Jeff Layton
2025-02-20 23:36 ` [PATCH 3/6] ceph: return the correct dentry on mkdir NeilBrown
2025-02-21  1:48   ` Viacheslav Dubeyko
2025-02-24  2:15     ` NeilBrown
2025-02-24 22:09       ` Viacheslav Dubeyko
2025-02-24 22:53         ` Jeff Layton
2025-02-24 23:29         ` NeilBrown
2025-02-21 13:31   ` Jeff Layton
2025-02-20 23:36 ` [PATCH 4/6] fuse: return correct dentry for ->mkdir NeilBrown
2025-02-21 13:39   ` Jeff Layton [this message]
2025-02-22  4:24   ` Al Viro
2025-02-24  2:26     ` NeilBrown
2025-02-24  2:53       ` Al Viro
2025-02-20 23:36 ` [PATCH 5/6] nfs: change mkdir inode_operation to return alternate dentry if needed NeilBrown
2025-02-22  4:41   ` Al Viro
2025-02-24  2:41     ` NeilBrown
2025-02-20 23:36 ` [PATCH 6/6] VFS: Change vfs_mkdir() to return the dentry NeilBrown
2025-02-21 14:25   ` Jeff Layton
2025-02-22  0:32   ` Chuck Lever
2025-02-24  2:51     ` NeilBrown
2025-02-24 14:22       ` Chuck Lever
  -- strict thread matches above, loose matches on Subject: below --
2025-02-27  1:32 [PATCH 0/6 v2] Change ->mkdir() and vfs_mkdir() to return a dentry NeilBrown
2025-02-27  1:32 ` [PATCH 4/6] fuse: return correct dentry for ->mkdir NeilBrown
2025-03-03 14:46   ` Miklos Szeredi

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=0542f4a777bb3fc1ef49fc879ac5f12030aa788a.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=brauner@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=idryomov@gmail.com \
    --cc=jack@suse.cz \
    --cc=johannes@sipsolutions.net \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=miklos@szeredi.hu \
    --cc=neilb@suse.de \
    --cc=netfs@lists.linux.dev \
    --cc=okorniev@redhat.com \
    --cc=richard@nod.at \
    --cc=senozhatsky@chromium.org \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiubli@redhat.com \
    /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).