erofs: relinquish volume with mutex held

Message ID 20230208073206.111814-1-jefflexu@linux.alibaba.com
State New
Headers
Series erofs: relinquish volume with mutex held |

Commit Message

Jingbo Xu Feb. 8, 2023, 7:32 a.m. UTC
  Relinquish fscache volume with mutex held.  Otherwise if a new domain is
registered when the old domain with the same name gets removed from the
list but not relinquished yet, fscache may complain the collision.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/fscache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jia Zhu Feb. 8, 2023, 9:09 a.m. UTC | #1
在 2023/2/8 15:32, Jingbo Xu 写道:
> Relinquish fscache volume with mutex held.  Otherwise if a new domain is
> registered when the old domain with the same name gets removed from the
> list but not relinquished yet, fscache may complain the collision.
> 
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>

Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com>

> ---
>   fs/erofs/fscache.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 8da6e05e9d23..35b2d8b5773e 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -328,8 +328,8 @@ static void erofs_fscache_domain_put(struct erofs_domain *domain)
>   			kern_unmount(erofs_pseudo_mnt);
>   			erofs_pseudo_mnt = NULL;
>   		}
> -		mutex_unlock(&erofs_domain_list_lock);
>   		fscache_relinquish_volume(domain->volume, NULL, false);
> +		mutex_unlock(&erofs_domain_list_lock);
>   		kfree(domain->domain_id);
>   		kfree(domain);
>   		return;
  

Patch

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 8da6e05e9d23..35b2d8b5773e 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -328,8 +328,8 @@  static void erofs_fscache_domain_put(struct erofs_domain *domain)
 			kern_unmount(erofs_pseudo_mnt);
 			erofs_pseudo_mnt = NULL;
 		}
-		mutex_unlock(&erofs_domain_list_lock);
 		fscache_relinquish_volume(domain->volume, NULL, false);
+		mutex_unlock(&erofs_domain_list_lock);
 		kfree(domain->domain_id);
 		kfree(domain);
 		return;