summaryrefslogtreecommitdiff
path: root/fs/erofs/fscache.c
diff options
context:
space:
mode:
authorJia Zhu <zhujia.zj@bytedance.com>2022-09-18 07:34:54 +0300
committerGao Xiang <hsiangkao@linux.alibaba.com>2022-09-20 03:01:54 +0300
commita9849560c55e9e4ab9c53d073363dd6e19ec06ef (patch)
tree9bcce3b3d532a51f4304c02dd5bf170e35743688 /fs/erofs/fscache.c
parent8b7adf1dff3d5baf687acda936f193f80b7e0179 (diff)
downloadlinux-a9849560c55e9e4ab9c53d073363dd6e19ec06ef.tar.xz
erofs: introduce a pseudo mnt to manage shared cookies
Use a pseudo mnt to manage shared cookies. Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com> Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com> Link: https://lore.kernel.org/r/20220918043456.147-5-zhujia.zj@bytedance.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Diffstat (limited to 'fs/erofs/fscache.c')
-rw-r--r--fs/erofs/fscache.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 8a1be6077ca4..0480aaf44cb9 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -8,6 +8,7 @@
static DEFINE_MUTEX(erofs_domain_list_lock);
static LIST_HEAD(erofs_domain_list);
+static struct vfsmount *erofs_pseudo_mnt;
static struct netfs_io_request *erofs_fscache_alloc_request(struct address_space *mapping,
loff_t start, size_t len)
@@ -432,6 +433,10 @@ static void erofs_fscache_domain_put(struct erofs_domain *domain)
mutex_lock(&erofs_domain_list_lock);
if (refcount_dec_and_test(&domain->ref)) {
list_del(&domain->list);
+ if (list_empty(&erofs_domain_list)) {
+ kern_unmount(erofs_pseudo_mnt);
+ erofs_pseudo_mnt = NULL;
+ }
mutex_unlock(&erofs_domain_list_lock);
fscache_relinquish_volume(domain->volume, NULL, false);
kfree(domain->domain_id);
@@ -486,6 +491,14 @@ static int erofs_fscache_init_domain(struct super_block *sb)
if (err)
goto out;
+ if (!erofs_pseudo_mnt) {
+ erofs_pseudo_mnt = kern_mount(&erofs_fs_type);
+ if (IS_ERR(erofs_pseudo_mnt)) {
+ err = PTR_ERR(erofs_pseudo_mnt);
+ goto out;
+ }
+ }
+
domain->volume = sbi->volume;
refcount_set(&domain->ref, 1);
list_add(&domain->list, &erofs_domain_list);