From: Dawei Li set_pte_at@outlook.com
anolis inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IB5UKT
Reference: https://gitee.com/anolis/cloud-kernel/commit/496c8bbd9a1b
--------------------------------
ANBZ: #3234
commit ce4b815686573bef82d5ee53bf6f509bf20904dc upstream.
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@TYCP286MB23... Fixes: 7d41963759fe ("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 Signed-off-by: Jingbo Xu jefflexu@linux.alibaba.com Reviewed-by: Joseph Qi joseph.qi@linux.alibaba.com Link: https://gitee.com/anolis/cloud-kernel/pulls/893 Signed-off-by: Baokun Li libaokun1@huawei.com --- fs/erofs/fscache.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 217290ab8a8c..a6302a06f1e4 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -488,14 +488,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;