erofs: protect s_inodes with s_inode_list_lock for fscache
s_inodes is superblock-specific resource, which should be
protected by sb's specific lock s_inode_list_lock.
Link: https://lore.kernel.org/r/TYCP286MB23238380DE3B74874E8D78ABCA299@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM
Fixes: 7d41963759
("erofs: Support sharing cookies in the same domain")
Reviewed-by: Yue Hu <huyue2@coolpad.com>
Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com>
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Dawei Li <set_pte_at@outlook.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
This commit is contained in:
parent
e7933278b4
commit
ce4b815686
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue