diff mbox series

[v2,6/7] fuse: Switch to fc_mount() for submounts

Message ID 20210604161156.408496-7-groug@kaod.org (mailing list archive)
State New, archived
Headers show
Series fuse: Some fixes for submounts | expand

Commit Message

Greg Kurz June 4, 2021, 4:11 p.m. UTC
fc_mount() already handles the vfs_get_tree(), sb->s_umount
unlocking and vfs_create_mount() sequence. Using it greatly
simplifies fuse_dentry_automount().

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 fs/fuse/dir.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

Comments

Max Reitz June 8, 2021, 3:51 p.m. UTC | #1
On 04.06.21 18:11, Greg Kurz wrote:
> fc_mount() already handles the vfs_get_tree(), sb->s_umount
> unlocking and vfs_create_mount() sequence. Using it greatly
> simplifies fuse_dentry_automount().
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>   fs/fuse/dir.c | 26 +++++---------------------
>   1 file changed, 5 insertions(+), 21 deletions(-)
>
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index b88e5785a3dd..fc9eddf7f9b2 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -311,38 +311,22 @@ static struct vfsmount *fuse_dentry_automount(struct path *path)
>   	struct fs_context *fsc;
>   	struct vfsmount *mnt;
>   	struct fuse_inode *mp_fi = get_fuse_inode(d_inode(path->dentry));
> -	int err;
>   
>   	fsc = fs_context_for_submount(path->mnt->mnt_sb->s_type, path->dentry);
> -	if (IS_ERR(fsc)) {
> -		err = PTR_ERR(fsc);
> -		goto out;
> -	}
> +	if (IS_ERR(fsc))
> +		return (struct vfsmount *) fsc;

I think ERR_CAST(fsc) would be nicer.

Apart from that:

Reviewed-by: Max Reitz <mreitz@redhat.com>
Greg Kurz June 9, 2021, 7:45 a.m. UTC | #2
On Tue, 8 Jun 2021 17:51:03 +0200
Max Reitz <mreitz@redhat.com> wrote:

> On 04.06.21 18:11, Greg Kurz wrote:
> > fc_mount() already handles the vfs_get_tree(), sb->s_umount
> > unlocking and vfs_create_mount() sequence. Using it greatly
> > simplifies fuse_dentry_automount().
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> >   fs/fuse/dir.c | 26 +++++---------------------
> >   1 file changed, 5 insertions(+), 21 deletions(-)
> >
> > diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> > index b88e5785a3dd..fc9eddf7f9b2 100644
> > --- a/fs/fuse/dir.c
> > +++ b/fs/fuse/dir.c
> > @@ -311,38 +311,22 @@ static struct vfsmount *fuse_dentry_automount(struct path *path)
> >   	struct fs_context *fsc;
> >   	struct vfsmount *mnt;
> >   	struct fuse_inode *mp_fi = get_fuse_inode(d_inode(path->dentry));
> > -	int err;
> >   
> >   	fsc = fs_context_for_submount(path->mnt->mnt_sb->s_type, path->dentry);
> > -	if (IS_ERR(fsc)) {
> > -		err = PTR_ERR(fsc);
> > -		goto out;
> > -	}
> > +	if (IS_ERR(fsc))
> > +		return (struct vfsmount *) fsc;
> 
> I think ERR_CAST(fsc) would be nicer.
> 

Indeed. I'll fix that if I need to repost.

> Apart from that:
> 
> Reviewed-by: Max Reitz <mreitz@redhat.com>
>
Miklos Szeredi June 11, 2021, 2:44 p.m. UTC | #3
On Wed, 9 Jun 2021 at 09:45, Greg Kurz <groug@kaod.org> wrote:
>
> On Tue, 8 Jun 2021 17:51:03 +0200
> Max Reitz <mreitz@redhat.com> wrote:
>
> > On 04.06.21 18:11, Greg Kurz wrote:
> > > fc_mount() already handles the vfs_get_tree(), sb->s_umount
> > > unlocking and vfs_create_mount() sequence. Using it greatly
> > > simplifies fuse_dentry_automount().
> > >
> > > Signed-off-by: Greg Kurz <groug@kaod.org>
> > > ---
> > >   fs/fuse/dir.c | 26 +++++---------------------
> > >   1 file changed, 5 insertions(+), 21 deletions(-)
> > >
> > > diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> > > index b88e5785a3dd..fc9eddf7f9b2 100644
> > > --- a/fs/fuse/dir.c
> > > +++ b/fs/fuse/dir.c
> > > @@ -311,38 +311,22 @@ static struct vfsmount *fuse_dentry_automount(struct path *path)
> > >     struct fs_context *fsc;
> > >     struct vfsmount *mnt;
> > >     struct fuse_inode *mp_fi = get_fuse_inode(d_inode(path->dentry));
> > > -   int err;
> > >
> > >     fsc = fs_context_for_submount(path->mnt->mnt_sb->s_type, path->dentry);
> > > -   if (IS_ERR(fsc)) {
> > > -           err = PTR_ERR(fsc);
> > > -           goto out;
> > > -   }
> > > +   if (IS_ERR(fsc))
> > > +           return (struct vfsmount *) fsc;
> >
> > I think ERR_CAST(fsc) would be nicer.
> >
>
> Indeed. I'll fix that if I need to repost.

Fixed.

Thanks,
Miklos
diff mbox series

Patch

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index b88e5785a3dd..fc9eddf7f9b2 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -311,38 +311,22 @@  static struct vfsmount *fuse_dentry_automount(struct path *path)
 	struct fs_context *fsc;
 	struct vfsmount *mnt;
 	struct fuse_inode *mp_fi = get_fuse_inode(d_inode(path->dentry));
-	int err;
 
 	fsc = fs_context_for_submount(path->mnt->mnt_sb->s_type, path->dentry);
-	if (IS_ERR(fsc)) {
-		err = PTR_ERR(fsc);
-		goto out;
-	}
+	if (IS_ERR(fsc))
+		return (struct vfsmount *) fsc;
 
 	/* Pass the FUSE inode of the mount for fuse_get_tree_submount() */
 	fsc->fs_private = mp_fi;
 
-	err = vfs_get_tree(fsc);
-	if (err)
-		goto out_put_fsc;
-
-	/* We are done configuring the superblock, so unlock it */
-	up_write(&fsc->root->d_sb->s_umount);
-
 	/* Create the submount */
-	mnt = vfs_create_mount(fsc);
-	if (IS_ERR(mnt)) {
-		err = PTR_ERR(mnt);
+	mnt = fc_mount(fsc);
+	if (IS_ERR(mnt))
 		goto out_put_fsc;
-	}
 	mntget(mnt);
-	put_fs_context(fsc);
-	return mnt;
-
 out_put_fsc:
 	put_fs_context(fsc);
-out:
-	return ERR_PTR(err);
+	return mnt;
 }
 
 const struct dentry_operations fuse_dentry_operations = {