summaryrefslogtreecommitdiffstats
path: root/fs/fuse
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2020-11-11 17:22:32 +0100
committerMiklos Szeredi <mszeredi@redhat.com>2020-11-11 17:22:32 +0100
commit514b5e3ff45e6cfc39cfa7c094727d8e6d885986 (patch)
treed6f6ae05d63a074f6f5da8f5b79c58ba47bd96a6 /fs/fuse
parentvirtiofs: simplify sb setup (diff)
downloadlinux-514b5e3ff45e6cfc39cfa7c094727d8e6d885986.tar.xz
linux-514b5e3ff45e6cfc39cfa7c094727d8e6d885986.zip
fuse: get rid of fuse_mount refcount
Fuse mount now only ever has a refcount of one (before being freed) so the count field is unnecessary. Remove the refcounting and fold fuse_mount_put() into callers. The only caller of fuse_mount_put() where fm->fc was NULL is fuse_dentry_automount() and here the fuse_conn_put() can simply be omitted. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse')
-rw-r--r--fs/fuse/dir.c3
-rw-r--r--fs/fuse/fuse_i.h8
-rw-r--r--fs/fuse/inode.c17
-rw-r--r--fs/fuse/virtio_fs.c9
4 files changed, 11 insertions, 26 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index ff7dbeb16f88..e9c244524985 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -328,12 +328,11 @@ static struct vfsmount *fuse_dentry_automount(struct path *path)
if (!fm)
goto out_put_fsc;
- refcount_set(&fm->count, 1);
fsc->s_fs_info = fm;
sb = sget_fc(fsc, NULL, set_anon_super_fc);
if (IS_ERR(sb)) {
err = PTR_ERR(sb);
- fuse_mount_put(fm);
+ kfree(fm);
goto out_put_fsc;
}
fm->fc = fuse_conn_get(fc);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index c036c4dc714a..919aaf184676 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -801,9 +801,6 @@ struct fuse_mount {
/* Underlying (potentially shared) connection to the FUSE server */
struct fuse_conn *fc;
- /* Refcount */
- refcount_t count;
-
/*
* Super block for this connection (fc->killsb must be held when
* accessing this).
@@ -1024,11 +1021,6 @@ void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm,
*/
void fuse_conn_put(struct fuse_conn *fc);
-/**
- * Release reference to fuse_mount
- */
-void fuse_mount_put(struct fuse_mount *fm);
-
struct fuse_dev *fuse_dev_alloc_install(struct fuse_conn *fc);
struct fuse_dev *fuse_dev_alloc(void);
void fuse_dev_install(struct fuse_dev *fud, struct fuse_conn *fc);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 654708574d5e..dd45dec4dc39 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -452,7 +452,8 @@ static void fuse_put_super(struct super_block *sb)
{
struct fuse_mount *fm = get_fuse_mount_super(sb);
- fuse_mount_put(fm);
+ fuse_conn_put(fm->fc);
+ kfree(fm);
}
static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr)
@@ -705,7 +706,6 @@ void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm,
INIT_LIST_HEAD(&fc->mounts);
list_add(&fm->fc_entry, &fc->mounts);
fm->fc = fc;
- refcount_set(&fm->count, 1);
}
EXPORT_SYMBOL_GPL(fuse_conn_init);
@@ -732,16 +732,6 @@ struct fuse_conn *fuse_conn_get(struct fuse_conn *fc)
}
EXPORT_SYMBOL_GPL(fuse_conn_get);
-void fuse_mount_put(struct fuse_mount *fm)
-{
- if (refcount_dec_and_test(&fm->count)) {
- if (fm->fc)
- fuse_conn_put(fm->fc);
- kfree(fm);
- }
-}
-EXPORT_SYMBOL_GPL(fuse_mount_put);
-
static struct inode *fuse_get_root_inode(struct super_block *sb, unsigned mode)
{
struct fuse_attr attr;
@@ -1458,7 +1448,8 @@ static int fuse_fill_super(struct super_block *sb, struct fs_context *fsc)
return 0;
err_put_conn:
- fuse_mount_put(fm);
+ fuse_conn_put(fc);
+ kfree(fm);
sb->s_fs_info = NULL;
err_fput:
fput(file);
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index 14d65db47778..62d89b9c30db 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -1445,15 +1445,18 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
fsc->s_fs_info = fm;
sb = sget_fc(fsc, virtio_fs_test_super, set_anon_super_fc);
- if (fsc->s_fs_info)
- fuse_mount_put(fm);
+ if (fsc->s_fs_info) {
+ fuse_conn_put(fc);
+ kfree(fm);
+ }
if (IS_ERR(sb))
return PTR_ERR(sb);
if (!sb->s_root) {
err = virtio_fs_fill_super(sb, fsc);
if (err) {
- fuse_mount_put(fm);
+ fuse_conn_put(fc);
+ kfree(fm);
sb->s_fs_info = NULL;
deactivate_locked_super(sb);
return err;