All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] erofs: cleanup for fscache mode
@ 2023-02-03  3:47 Jingbo Xu
  2023-02-03  3:47 ` [PATCH 1/2] erofs: simplify instantiation of pseudo mount in " Jingbo Xu
  2023-02-03  3:47 ` [PATCH 2/2] erofs: simplify the name collision checking in share domain mode Jingbo Xu
  0 siblings, 2 replies; 5+ messages in thread
From: Jingbo Xu @ 2023-02-03  3:47 UTC (permalink / raw)
  To: xiang, chao, linux-erofs, zhujia.zj, houtao1; +Cc: huyue2, linux-kernel

These are misc cleanup for fscache mode, while patch 2 is dependent on
the page cache sharing codebase [1].

[1] https://lore.kernel.org/all/20230203030143.73105-1-jefflexu@linux.alibaba.com/

Jingbo Xu (2):
  erofs: simplify instantiation of pseudo mount in fscache mode
  erofs: simplify the name collision checking in share domain mode

 fs/erofs/fscache.c  | 84 ++++++++++++++++++++-------------------------
 fs/erofs/internal.h | 15 ++++----
 fs/erofs/super.c    | 37 +++++---------------
 3 files changed, 53 insertions(+), 83 deletions(-)

-- 
2.19.1.6.gb485710b


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] erofs: simplify instantiation of pseudo mount in fscache mode
  2023-02-03  3:47 [PATCH 0/2] erofs: cleanup for fscache mode Jingbo Xu
@ 2023-02-03  3:47 ` Jingbo Xu
  2023-02-03  7:14   ` Gao Xiang
  2023-02-03  3:47 ` [PATCH 2/2] erofs: simplify the name collision checking in share domain mode Jingbo Xu
  1 sibling, 1 reply; 5+ messages in thread
From: Jingbo Xu @ 2023-02-03  3:47 UTC (permalink / raw)
  To: xiang, chao, linux-erofs, zhujia.zj, houtao1; +Cc: huyue2, linux-kernel

Introduce a pseudo fs type dedicated to the pseudo mount of fscache
mode, so that the logic of real mount won't be messed up with that of
pseudo mount, making the implementation of fscache mode more
self-contained.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/fscache.c  | 46 +++++++++++++++++++++++++++------------------
 fs/erofs/internal.h |  6 ++++++
 fs/erofs/super.c    | 35 +++++++---------------------------
 3 files changed, 41 insertions(+), 46 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index af6ba52bbe8b..2eb42bbc56a4 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -6,12 +6,13 @@
 #include <linux/fscache.h>
 #include <linux/file.h>
 #include <linux/anon_inodes.h>
+#include <linux/pseudo_fs.h>
 #include "internal.h"
 
 static DEFINE_MUTEX(erofs_domain_list_lock);
 static DEFINE_MUTEX(erofs_domain_cookies_lock);
 static LIST_HEAD(erofs_domain_list);
-static struct vfsmount *erofs_pseudo_mnt;
+static struct vfsmount *erofs_pseudo_mnt __read_mostly;
 
 struct erofs_fscache_request {
 	struct erofs_fscache_request *primary;
@@ -471,10 +472,6 @@ 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);
@@ -526,15 +523,10 @@ static int erofs_fscache_init_domain(struct super_block *sb)
 	}
 
 	err = erofs_fscache_register_volume(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;
-		}
+	if (err) {
+		kfree(domain->domain_id);
+		kfree(domain);
+		return err;
 	}
 
 	domain->volume = sbi->volume;
@@ -542,10 +534,6 @@ static int erofs_fscache_init_domain(struct super_block *sb)
 	list_add(&domain->list, &erofs_domain_list);
 	sbi->domain = domain;
 	return 0;
-out:
-	kfree(domain->domain_id);
-	kfree(domain);
-	return err;
 }
 
 static int erofs_fscache_register_domain(struct super_block *sb)
@@ -780,3 +768,25 @@ void erofs_fscache_unregister_fs(struct super_block *sb)
 	sbi->volume = NULL;
 	sbi->domain = NULL;
 }
+
+static int erofs_fc_anon_get_tree(struct fs_context *fc)
+{
+	return PTR_ERR_OR_ZERO(init_pseudo(fc, EROFS_SUPER_MAGIC));
+}
+
+int __init erofs_fscache_init(void)
+{
+	static struct file_system_type erofs_anon_fs = {
+		.name		= "erofs_anonfs",
+		.init_fs_context = erofs_fc_anon_get_tree,
+		.kill_sb	= kill_anon_super,
+	};
+
+	erofs_pseudo_mnt = kern_mount(&erofs_anon_fs);
+	return PTR_ERR_OR_ZERO(erofs_pseudo_mnt);
+}
+
+void erofs_fscache_exit(void)
+{
+	kern_unmount(erofs_pseudo_mnt);
+}
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index c3ac6d613eb1..6080e382ed7e 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -634,6 +634,9 @@ static inline int z_erofs_load_lzma_config(struct super_block *sb,
 
 /* fscache.c */
 #ifdef CONFIG_EROFS_FS_ONDEMAND
+int __init erofs_fscache_init(void);
+void erofs_fscache_exit(void);
+
 int erofs_fscache_register_fs(struct super_block *sb);
 void erofs_fscache_unregister_fs(struct super_block *sb);
 
@@ -645,6 +648,9 @@ void erofs_fscache_unregister_cookie(struct erofs_fscache *fscache);
 extern const struct address_space_operations erofs_fscache_access_aops;
 extern const struct file_operations erofs_fscache_share_file_fops;
 #else
+static inline int erofs_fscache_init(void) { return 0; }
+static inline void erofs_fscache_exit(void) {}
+
 static inline int erofs_fscache_register_fs(struct super_block *sb)
 {
 	return -EOPNOTSUPP;
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 81aa63f34047..b06d29beed4e 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -712,13 +712,6 @@ static const struct export_operations erofs_export_ops = {
 	.get_parent = erofs_get_parent,
 };
 
-static int erofs_fc_fill_pseudo_super(struct super_block *sb, struct fs_context *fc)
-{
-	static const struct tree_descr empty_descr = {""};
-
-	return simple_fill_super(sb, EROFS_SUPER_MAGIC, &empty_descr);
-}
-
 static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct inode *inode;
@@ -822,11 +815,6 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
 	return 0;
 }
 
-static int erofs_fc_anon_get_tree(struct fs_context *fc)
-{
-	return get_tree_nodev(fc, erofs_fc_fill_pseudo_super);
-}
-
 static int erofs_fc_get_tree(struct fs_context *fc)
 {
 	struct erofs_fs_context *ctx = fc->fs_private;
@@ -899,20 +887,10 @@ static const struct fs_context_operations erofs_context_ops = {
 	.free		= erofs_fc_free,
 };
 
-static const struct fs_context_operations erofs_anon_context_ops = {
-	.get_tree       = erofs_fc_anon_get_tree,
-};
-
 static int erofs_init_fs_context(struct fs_context *fc)
 {
 	struct erofs_fs_context *ctx;
 
-	/* pseudo mount for anon inodes */
-	if (fc->sb_flags & SB_KERNMOUNT) {
-		fc->ops = &erofs_anon_context_ops;
-		return 0;
-	}
-
 	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
@@ -940,12 +918,6 @@ static void erofs_kill_sb(struct super_block *sb)
 
 	WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
 
-	/* pseudo mount for anon inodes */
-	if (sb->s_flags & SB_KERNMOUNT) {
-		kill_anon_super(sb);
-		return;
-	}
-
 	if (erofs_is_fscache_mode(sb))
 		kill_anon_super(sb);
 	else
@@ -1021,6 +993,10 @@ static int __init erofs_module_init(void)
 	if (err)
 		goto zip_err;
 
+	err = erofs_fscache_init();
+	if (err)
+		goto fscache_err;
+
 	err = erofs_init_sysfs();
 	if (err)
 		goto sysfs_err;
@@ -1034,6 +1010,8 @@ static int __init erofs_module_init(void)
 fs_err:
 	erofs_exit_sysfs();
 sysfs_err:
+	erofs_fscache_exit();
+fscache_err:
 	z_erofs_exit_zip_subsystem();
 zip_err:
 	z_erofs_lzma_exit();
@@ -1053,6 +1031,7 @@ static void __exit erofs_module_exit(void)
 	rcu_barrier();
 
 	erofs_exit_sysfs();
+	erofs_fscache_exit();
 	z_erofs_exit_zip_subsystem();
 	z_erofs_lzma_exit();
 	erofs_exit_shrinker();
-- 
2.19.1.6.gb485710b


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] erofs: simplify the name collision checking in share domain mode
  2023-02-03  3:47 [PATCH 0/2] erofs: cleanup for fscache mode Jingbo Xu
  2023-02-03  3:47 ` [PATCH 1/2] erofs: simplify instantiation of pseudo mount in " Jingbo Xu
@ 2023-02-03  3:47 ` Jingbo Xu
  1 sibling, 0 replies; 5+ messages in thread
From: Jingbo Xu @ 2023-02-03  3:47 UTC (permalink / raw)
  To: xiang, chao, linux-erofs, zhujia.zj, houtao1; +Cc: huyue2, linux-kernel

When share domain is enabled, data blobs can be shared among filesystem
instances in the same domain for data deduplication, while bootstrap
blobs are always dedicated to the corresponding filesystem instance, and
have no need to be shared.

In the initial implementation of share domain (commit 7d41963759fe
("erofs: Support sharing cookies in the same domain")), bootstrap blobs
are also in the share domain, and thus can be referenced by the
following filesystem instances.  In this case, mounting twice with the
same fsid and domain_id will trigger warning in sysfs.  Commit
27f2a2dcc626 ("erofs: check the uniqueness of fsid in shared domain in
advance") fixes this by introducing the name collision checking.

This patch attempts to fix the above issue in another simpler way.
Since the bootstrap blobs have no need to be shared, move them out of
the share domain, so that one bootstrap blob can not be referenced by
other filesystem instances.  Attempt to mount twice with the same fsid
and domain_id will fail with info of duplicate cookies, which is
consistent with the behavior in non-share-domain mode.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/fscache.c  | 38 +++++++++-----------------------------
 fs/erofs/internal.h |  9 ++-------
 fs/erofs/super.c    |  2 +-
 3 files changed, 12 insertions(+), 37 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 2eb42bbc56a4..d47b04dfdc48 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -656,8 +656,7 @@ struct erofs_fscache *erofs_fscache_domain_init_cookie(struct super_block *sb,
 
 static
 struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
-						   char *name,
-						   unsigned int flags)
+						   char *name)
 {
 	struct inode *inode;
 	struct erofs_fscache *ctx;
@@ -668,18 +667,12 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
 	spin_lock(&psb->s_inode_list_lock);
 	list_for_each_entry(inode, &psb->s_inodes, i_sb_list) {
 		ctx = inode->i_private;
-		if (!ctx || ctx->domain != domain || strcmp(ctx->name, name))
-			continue;
-		if (!(flags & EROFS_REG_COOKIE_NEED_NOEXIST)) {
+		if (ctx && ctx->domain == domain && !strcmp(ctx->name, name)) {
 			igrab(inode);
-		} else {
-			erofs_err(sb, "%s already exists in domain %s", name,
-				  domain->domain_id);
-			ctx = ERR_PTR(-EEXIST);
+			spin_unlock(&psb->s_inode_list_lock);
+			mutex_unlock(&erofs_domain_cookies_lock);
+			return ctx;
 		}
-		spin_unlock(&psb->s_inode_list_lock);
-		mutex_unlock(&erofs_domain_cookies_lock);
-		return ctx;
 	}
 	spin_unlock(&psb->s_inode_list_lock);
 	ctx = erofs_fscache_domain_init_cookie(sb, name);
@@ -688,11 +681,10 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
 }
 
 struct erofs_fscache *erofs_fscache_register_cookie(struct super_block *sb,
-						    char *name,
-						    unsigned int flags)
+						    char *name)
 {
 	if (EROFS_SB(sb)->domain_id)
-		return erofs_domain_register_cookie(sb, name, flags);
+		return erofs_domain_register_cookie(sb, name);
 	return erofs_fscache_acquire_cookie(sb, sb, name);
 }
 
@@ -724,7 +716,6 @@ int erofs_fscache_register_fs(struct super_block *sb)
 	int ret;
 	struct erofs_sb_info *sbi = EROFS_SB(sb);
 	struct erofs_fscache *fscache;
-	unsigned int flags = 0;
 
 	if (sbi->domain_id)
 		ret = erofs_fscache_register_domain(sb);
@@ -733,19 +724,8 @@ int erofs_fscache_register_fs(struct super_block *sb)
 	if (ret)
 		return ret;
 
-	/*
-	 * When shared domain is enabled, using NEED_NOEXIST to guarantee
-	 * the primary data blob (aka fsid) is unique in the shared domain.
-	 *
-	 * For non-shared-domain case, fscache_acquire_volume() invoked by
-	 * erofs_fscache_register_volume() has already guaranteed
-	 * the uniqueness of primary data blob.
-	 *
-	 * Acquired domain/volume will be relinquished in kill_sb() on error.
-	 */
-	if (sbi->domain_id)
-		flags |= EROFS_REG_COOKIE_NEED_NOEXIST;
-	fscache = erofs_fscache_register_cookie(sb, sbi->fsid, flags);
+	/* acquired domain/volume will be relinquished in kill_sb() on error */
+	fscache = erofs_fscache_acquire_cookie(sb, sb, sbi->fsid);
 	if (IS_ERR(fscache))
 		return PTR_ERR(fscache);
 
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 6080e382ed7e..a63a9e951fe0 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -629,9 +629,6 @@ static inline int z_erofs_load_lzma_config(struct super_block *sb,
 }
 #endif	/* !CONFIG_EROFS_FS_ZIP */
 
-/* flags for erofs_fscache_register_cookie() */
-#define EROFS_REG_COOKIE_NEED_NOEXIST	1
-
 /* fscache.c */
 #ifdef CONFIG_EROFS_FS_ONDEMAND
 int __init erofs_fscache_init(void);
@@ -641,8 +638,7 @@ int erofs_fscache_register_fs(struct super_block *sb);
 void erofs_fscache_unregister_fs(struct super_block *sb);
 
 struct erofs_fscache *erofs_fscache_register_cookie(struct super_block *sb,
-						    char *name,
-						    unsigned int flags);
+						    char *name);
 void erofs_fscache_unregister_cookie(struct erofs_fscache *fscache);
 
 extern const struct address_space_operations erofs_fscache_access_aops;
@@ -659,8 +655,7 @@ static inline void erofs_fscache_unregister_fs(struct super_block *sb) {}
 
 static inline
 struct erofs_fscache *erofs_fscache_register_cookie(struct super_block *sb,
-						     char *name,
-						     unsigned int flags)
+						     char *name)
 {
 	return ERR_PTR(-EOPNOTSUPP);
 }
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index b06d29beed4e..ed4e373b0816 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -245,7 +245,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
 	}
 
 	if (erofs_is_fscache_mode(sb)) {
-		fscache = erofs_fscache_register_cookie(sb, dif->path, 0);
+		fscache = erofs_fscache_register_cookie(sb, dif->path);
 		if (IS_ERR(fscache))
 			return PTR_ERR(fscache);
 		dif->fscache = fscache;
-- 
2.19.1.6.gb485710b


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] erofs: simplify instantiation of pseudo mount in fscache mode
  2023-02-03  3:47 ` [PATCH 1/2] erofs: simplify instantiation of pseudo mount in " Jingbo Xu
@ 2023-02-03  7:14   ` Gao Xiang
  2023-02-03  7:17     ` Gao Xiang
  0 siblings, 1 reply; 5+ messages in thread
From: Gao Xiang @ 2023-02-03  7:14 UTC (permalink / raw)
  To: Jingbo Xu, xiang, chao, linux-erofs, zhujia.zj, houtao1
  Cc: huyue2, linux-kernel



On 2023/2/3 11:47, Jingbo Xu wrote:
> Introduce a pseudo fs type dedicated to the pseudo mount of fscache
> mode, so that the logic of real mount won't be messed up with that of
> pseudo mount, making the implementation of fscache mode more
> self-contained.
> 
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
> ---
>   fs/erofs/fscache.c  | 46 +++++++++++++++++++++++++++------------------
>   fs/erofs/internal.h |  6 ++++++
>   fs/erofs/super.c    | 35 +++++++---------------------------
>   3 files changed, 41 insertions(+), 46 deletions(-)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index af6ba52bbe8b..2eb42bbc56a4 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -6,12 +6,13 @@
>   #include <linux/fscache.h>
>   #include <linux/file.h>
>   #include <linux/anon_inodes.h>
> +#include <linux/pseudo_fs.h>
>   #include "internal.h"
>   
>   static DEFINE_MUTEX(erofs_domain_list_lock);
>   static DEFINE_MUTEX(erofs_domain_cookies_lock);
>   static LIST_HEAD(erofs_domain_list);
> -static struct vfsmount *erofs_pseudo_mnt;
> +static struct vfsmount *erofs_pseudo_mnt __read_mostly;
>   
>   struct erofs_fscache_request {
>   	struct erofs_fscache_request *primary;
> @@ -471,10 +472,6 @@ 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);
> @@ -526,15 +523,10 @@ static int erofs_fscache_init_domain(struct super_block *sb)
>   	}
>   
>   	err = erofs_fscache_register_volume(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;
> -		}
> +	if (err) {
> +		kfree(domain->domain_id);
> +		kfree(domain);
> +		return err;
>   	}
>   
>   	domain->volume = sbi->volume;
> @@ -542,10 +534,6 @@ static int erofs_fscache_init_domain(struct super_block *sb)
>   	list_add(&domain->list, &erofs_domain_list);
>   	sbi->domain = domain;
>   	return 0;
> -out:
> -	kfree(domain->domain_id);
> -	kfree(domain);
> -	return err;
>   }
>   
>   static int erofs_fscache_register_domain(struct super_block *sb)
> @@ -780,3 +768,25 @@ void erofs_fscache_unregister_fs(struct super_block *sb)
>   	sbi->volume = NULL;
>   	sbi->domain = NULL;
>   }
> +
> +static int erofs_fc_anon_get_tree(struct fs_context *fc)
> +{
> +	return PTR_ERR_OR_ZERO(init_pseudo(fc, EROFS_SUPER_MAGIC));
> +}
> +
> +int __init erofs_fscache_init(void)
> +{
> +	static struct file_system_type erofs_anon_fs = {
> +		.name		= "erofs_anonfs",
> +		.init_fs_context = erofs_fc_anon_get_tree,
> +		.kill_sb	= kill_anon_super,
> +	};


Please don't add another filesystem type, thanks.

Thanks,
Gao Xiang

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] erofs: simplify instantiation of pseudo mount in fscache mode
  2023-02-03  7:14   ` Gao Xiang
@ 2023-02-03  7:17     ` Gao Xiang
  0 siblings, 0 replies; 5+ messages in thread
From: Gao Xiang @ 2023-02-03  7:17 UTC (permalink / raw)
  To: Jingbo Xu, xiang, chao, linux-erofs, zhujia.zj, houtao1
  Cc: huyue2, linux-kernel



On 2023/2/3 15:14, Gao Xiang wrote:
> 
> 
> On 2023/2/3 11:47, Jingbo Xu wrote:
>> Introduce a pseudo fs type dedicated to the pseudo mount of fscache
>> mode, so that the logic of real mount won't be messed up with that of
>> pseudo mount, making the implementation of fscache mode more
>> self-contained.
>>
>> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
>> ---
>>   fs/erofs/fscache.c  | 46 +++++++++++++++++++++++++++------------------
>>   fs/erofs/internal.h |  6 ++++++
>>   fs/erofs/super.c    | 35 +++++++---------------------------
>>   3 files changed, 41 insertions(+), 46 deletions(-)
>>
>> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
>> index af6ba52bbe8b..2eb42bbc56a4 100644
>> --- a/fs/erofs/fscache.c
>> +++ b/fs/erofs/fscache.c
>> @@ -6,12 +6,13 @@
>>   #include <linux/fscache.h>
>>   #include <linux/file.h>
>>   #include <linux/anon_inodes.h>
>> +#include <linux/pseudo_fs.h>
>>   #include "internal.h"
>>   static DEFINE_MUTEX(erofs_domain_list_lock);
>>   static DEFINE_MUTEX(erofs_domain_cookies_lock);
>>   static LIST_HEAD(erofs_domain_list);
>> -static struct vfsmount *erofs_pseudo_mnt;
>> +static struct vfsmount *erofs_pseudo_mnt __read_mostly;
>>   struct erofs_fscache_request {
>>       struct erofs_fscache_request *primary;
>> @@ -471,10 +472,6 @@ 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);
>> @@ -526,15 +523,10 @@ static int erofs_fscache_init_domain(struct super_block *sb)
>>       }
>>       err = erofs_fscache_register_volume(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;
>> -        }
>> +    if (err) {
>> +        kfree(domain->domain_id);
>> +        kfree(domain);
>> +        return err;
>>       }
>>       domain->volume = sbi->volume;
>> @@ -542,10 +534,6 @@ static int erofs_fscache_init_domain(struct super_block *sb)
>>       list_add(&domain->list, &erofs_domain_list);
>>       sbi->domain = domain;
>>       return 0;
>> -out:
>> -    kfree(domain->domain_id);
>> -    kfree(domain);
>> -    return err;
>>   }
>>   static int erofs_fscache_register_domain(struct super_block *sb)
>> @@ -780,3 +768,25 @@ void erofs_fscache_unregister_fs(struct super_block *sb)
>>       sbi->volume = NULL;
>>       sbi->domain = NULL;
>>   }
>> +
>> +static int erofs_fc_anon_get_tree(struct fs_context *fc)
>> +{
>> +    return PTR_ERR_OR_ZERO(init_pseudo(fc, EROFS_SUPER_MAGIC));
>> +}
>> +
>> +int __init erofs_fscache_init(void)
>> +{
>> +    static struct file_system_type erofs_anon_fs = {
>> +        .name        = "erofs_anonfs",
>> +        .init_fs_context = erofs_fc_anon_get_tree,
>> +        .kill_sb    = kill_anon_super,
>> +    };
> 
> 
> Please don't add another filesystem type, thanks.

I think it can be cleaned up nicely with Christoph's patchset, please help
follow if possible,
https://lore.kernel.org/linux-fsdevel/20210310083723.GC5217@lst.de/

Thanks,
Gao Xiang

> 
> Thanks,
> Gao Xiang

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-03  7:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03  3:47 [PATCH 0/2] erofs: cleanup for fscache mode Jingbo Xu
2023-02-03  3:47 ` [PATCH 1/2] erofs: simplify instantiation of pseudo mount in " Jingbo Xu
2023-02-03  7:14   ` Gao Xiang
2023-02-03  7:17     ` Gao Xiang
2023-02-03  3:47 ` [PATCH 2/2] erofs: simplify the name collision checking in share domain mode Jingbo Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.