Skip to content

Commit ce4b815

Browse files
Dawei Lihsiangkao
authored andcommitted
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: 7d41963 ("erofs: Support sharing cookies in the same domain") Reviewed-by: Yue Hu <[email protected]> Reviewed-by: Jia Zhu <[email protected]> Reviewed-by: Jingbo Xu <[email protected]> Signed-off-by: Dawei Li <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent e793327 commit ce4b815

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/erofs/fscache.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,14 +590,17 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
590590
struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
591591

592592
mutex_lock(&erofs_domain_cookies_lock);
593+
spin_lock(&psb->s_inode_list_lock);
593594
list_for_each_entry(inode, &psb->s_inodes, i_sb_list) {
594595
ctx = inode->i_private;
595596
if (!ctx || ctx->domain != domain || strcmp(ctx->name, name))
596597
continue;
597598
igrab(inode);
599+
spin_unlock(&psb->s_inode_list_lock);
598600
mutex_unlock(&erofs_domain_cookies_lock);
599601
return ctx;
600602
}
603+
spin_unlock(&psb->s_inode_list_lock);
601604
ctx = erofs_fscache_domain_init_cookie(sb, name, need_inode);
602605
mutex_unlock(&erofs_domain_cookies_lock);
603606
return ctx;

0 commit comments

Comments
 (0)