All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
@ 2022-10-17  1:55 ` Dawei Li
  0 siblings, 0 replies; 9+ messages in thread
From: Dawei Li @ 2022-10-17  1:55 UTC (permalink / raw)
  To: xiang, chao
  Cc: zhujia.zj, huyue2, jefflexu, linux-erofs, linux-kernel, Dawei Li

s_inodes is superblock-specific resource, which should be
protected by sb's specific lock s_inode_list_lock.

v2: update the locking mechanisim to protect mutual-exclusive access
both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
reviewing comments from Jia Zhu.

v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/

base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1

Signed-off-by: Dawei Li <set_pte_at@outlook.com>
---
 fs/erofs/fscache.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 998cd26a1b3b..fe05bc51f9f2 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
 	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
 
 	mutex_lock(&erofs_domain_cookies_lock);
+	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;
 		igrab(inode);
+		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, need_inode);
 	mutex_unlock(&erofs_domain_cookies_lock);
 	return ctx;
-- 
2.25.1


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

* [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
@ 2022-10-17  1:55 ` Dawei Li
  0 siblings, 0 replies; 9+ messages in thread
From: Dawei Li @ 2022-10-17  1:55 UTC (permalink / raw)
  To: xiang, chao; +Cc: linux-kernel, huyue2, Dawei Li, linux-erofs

s_inodes is superblock-specific resource, which should be
protected by sb's specific lock s_inode_list_lock.

v2: update the locking mechanisim to protect mutual-exclusive access
both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
reviewing comments from Jia Zhu.

v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/

base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1

Signed-off-by: Dawei Li <set_pte_at@outlook.com>
---
 fs/erofs/fscache.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 998cd26a1b3b..fe05bc51f9f2 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
 	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
 
 	mutex_lock(&erofs_domain_cookies_lock);
+	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;
 		igrab(inode);
+		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, need_inode);
 	mutex_unlock(&erofs_domain_cookies_lock);
 	return ctx;
-- 
2.25.1


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

* Re: [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
  2022-10-17  1:55 ` Dawei Li
  (?)
@ 2022-10-17  2:31 ` Yue Hu
  -1 siblings, 0 replies; 9+ messages in thread
From: Yue Hu @ 2022-10-17  2:31 UTC (permalink / raw)
  To: Dawei Li; +Cc: linux-erofs, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]

On Mon, 17 Oct 2022 09:55:53 +0800
Dawei Li <set_pte_at@outlook.com> wrote:

> s_inodes is superblock-specific resource, which should be
> protected by sb's specific lock s_inode_list_lock.
> 
> v2: update the locking mechanisim to protect mutual-exclusive access
> both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
> reviewing comments from Jia Zhu.
> 
> v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
> 
> base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>
> ---
>  fs/erofs/fscache.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 998cd26a1b3b..fe05bc51f9f2 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
>  	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
>  
>  	mutex_lock(&erofs_domain_cookies_lock);
> +	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;
>  		igrab(inode);
> +		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, need_inode);
>  	mutex_unlock(&erofs_domain_cookies_lock);
>  	return ctx;

I will make clear that this change is fscache related in title.

Reviewed-by: Yue Hu <huyue2@coolpad.com>

[-- Attachment #2: Type: text/html, Size: 3406 bytes --]

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

* Re: [External] [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
  2022-10-17  1:55 ` Dawei Li
@ 2022-10-17  3:14   ` Jia Zhu
  -1 siblings, 0 replies; 9+ messages in thread
From: Jia Zhu @ 2022-10-17  3:14 UTC (permalink / raw)
  To: Dawei Li, xiang, chao; +Cc: huyue2, jefflexu, linux-erofs, linux-kernel



在 2022/10/17 09:55, Dawei Li 写道:
> s_inodes is superblock-specific resource, which should be
> protected by sb's specific lock s_inode_list_lock.
> 
> v2: update the locking mechanisim to protect mutual-exclusive access
> both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
> reviewing comments from Jia Zhu.
> 
> v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
> 
> base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>
> ---
>   fs/erofs/fscache.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 998cd26a1b3b..fe05bc51f9f2 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
>   	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
>   
>   	mutex_lock(&erofs_domain_cookies_lock);
> +	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;
>   		igrab(inode);
> +		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, need_inode);
>   	mutex_unlock(&erofs_domain_cookies_lock);
>   	return ctx;
LGTM
Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com>

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

* Re: [External] [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
@ 2022-10-17  3:14   ` Jia Zhu
  0 siblings, 0 replies; 9+ messages in thread
From: Jia Zhu @ 2022-10-17  3:14 UTC (permalink / raw)
  To: Dawei Li, xiang, chao; +Cc: huyue2, linux-erofs, linux-kernel



在 2022/10/17 09:55, Dawei Li 写道:
> s_inodes is superblock-specific resource, which should be
> protected by sb's specific lock s_inode_list_lock.
> 
> v2: update the locking mechanisim to protect mutual-exclusive access
> both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
> reviewing comments from Jia Zhu.
> 
> v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
> 
> base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>
> ---
>   fs/erofs/fscache.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 998cd26a1b3b..fe05bc51f9f2 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
>   	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
>   
>   	mutex_lock(&erofs_domain_cookies_lock);
> +	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;
>   		igrab(inode);
> +		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, need_inode);
>   	mutex_unlock(&erofs_domain_cookies_lock);
>   	return ctx;
LGTM
Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com>

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

* Re: [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
  2022-10-17  1:55 ` Dawei Li
@ 2022-10-17  4:58   ` JeffleXu
  -1 siblings, 0 replies; 9+ messages in thread
From: JeffleXu @ 2022-10-17  4:58 UTC (permalink / raw)
  To: Dawei Li, xiang, chao; +Cc: zhujia.zj, huyue2, linux-erofs, linux-kernel



On 10/17/22 9:55 AM, Dawei Li wrote:
> s_inodes is superblock-specific resource, which should be
> protected by sb's specific lock s_inode_list_lock.
> 
> v2: update the locking mechanisim to protect mutual-exclusive access
> both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
> reviewing comments from Jia Zhu.
> 
> v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
> 
> base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>

Fixes: 7d41963759fe ("erofs: Support sharing cookies in the same domain")

LGTM.

Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>

> ---
>  fs/erofs/fscache.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 998cd26a1b3b..fe05bc51f9f2 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
>  	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
>  
>  	mutex_lock(&erofs_domain_cookies_lock);
> +	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;
>  		igrab(inode);
> +		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, need_inode);
>  	mutex_unlock(&erofs_domain_cookies_lock);
>  	return ctx;

-- 
Thanks,
Jingbo

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

* Re: [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
@ 2022-10-17  4:58   ` JeffleXu
  0 siblings, 0 replies; 9+ messages in thread
From: JeffleXu @ 2022-10-17  4:58 UTC (permalink / raw)
  To: Dawei Li, xiang, chao; +Cc: huyue2, linux-erofs, linux-kernel



On 10/17/22 9:55 AM, Dawei Li wrote:
> s_inodes is superblock-specific resource, which should be
> protected by sb's specific lock s_inode_list_lock.
> 
> v2: update the locking mechanisim to protect mutual-exclusive access
> both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
> reviewing comments from Jia Zhu.
> 
> v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
> 
> base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>

Fixes: 7d41963759fe ("erofs: Support sharing cookies in the same domain")

LGTM.

Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>

> ---
>  fs/erofs/fscache.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 998cd26a1b3b..fe05bc51f9f2 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
>  	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
>  
>  	mutex_lock(&erofs_domain_cookies_lock);
> +	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;
>  		igrab(inode);
> +		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, need_inode);
>  	mutex_unlock(&erofs_domain_cookies_lock);
>  	return ctx;

-- 
Thanks,
Jingbo

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

* Re: [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
  2022-10-17  1:55 ` Dawei Li
@ 2022-10-20  8:09   ` Chao Yu
  -1 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2022-10-20  8:09 UTC (permalink / raw)
  To: Dawei Li, xiang; +Cc: zhujia.zj, huyue2, jefflexu, linux-erofs, linux-kernel

On 2022/10/17 9:55, Dawei Li wrote:
> s_inodes is superblock-specific resource, which should be
> protected by sb's specific lock s_inode_list_lock.
> 
> v2: update the locking mechanisim to protect mutual-exclusive access
> both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
> reviewing comments from Jia Zhu.
> 
> v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
> 
> base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

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

* Re: [PATCH v2] erofs: protect s_inodes with s_inode_list_lock
@ 2022-10-20  8:09   ` Chao Yu
  0 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2022-10-20  8:09 UTC (permalink / raw)
  To: Dawei Li, xiang; +Cc: huyue2, linux-erofs, linux-kernel

On 2022/10/17 9:55, Dawei Li wrote:
> s_inodes is superblock-specific resource, which should be
> protected by sb's specific lock s_inode_list_lock.
> 
> v2: update the locking mechanisim to protect mutual-exclusive access
> both for s_inode_list_lock & erofs_fscache_domain_init_cookie(), as the
> reviewing comments from Jia Zhu.
> 
> v1: https://lore.kernel.org/all/TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
> 
> base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

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

end of thread, other threads:[~2022-10-20  8:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17  1:55 [PATCH v2] erofs: protect s_inodes with s_inode_list_lock Dawei Li
2022-10-17  1:55 ` Dawei Li
2022-10-17  2:31 ` Yue Hu
2022-10-17  3:14 ` [External] " Jia Zhu
2022-10-17  3:14   ` Jia Zhu
2022-10-17  4:58 ` JeffleXu
2022-10-17  4:58   ` JeffleXu
2022-10-20  8:09 ` Chao Yu
2022-10-20  8:09   ` Chao Yu

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.