[PATCH OLK-6.6 0/2] mfs: fix two potential deadlock in remote mode
Fix two potential deadlock in remote mode. Hongbo Li (2): mfs: remove FAROUND event to avoid context switch during map_pages mfs: avoid deadlock when the cache layer is modified Documentation/filesystems/mfs.rst | 4 +--- fs/mfs/data.c | 22 ---------------------- fs/mfs/inode.c | 5 ++++- include/uapi/linux/mfs.h | 1 - 4 files changed, 5 insertions(+), 27 deletions(-) -- 2.34.1
hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/13283 ------------------ The .map_pages holds the rcu_read_lock() before calling specifical .map_pages helpers. And in MFS's remote mode, the .map_pages will trigger sync events and call schedule() after sending the messages. This may cause potential deadlock risk and the rcu detector also reports the warning. The .map_pages tries to reduce the minor page fault overhead, that means the data is already in page cache. And we also can prefetch the data in strategy when the major fault is happened. So the MFS_OP_FAROUND event can be removed. Fixes: bfa1ad801c5d ("mfs: Add basic cache framework: check method and control structure") Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- Documentation/filesystems/mfs.rst | 4 +--- fs/mfs/data.c | 22 ---------------------- include/uapi/linux/mfs.h | 1 - 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/Documentation/filesystems/mfs.rst b/Documentation/filesystems/mfs.rst index a291fbf48cf1..b81ba1fea818 100644 --- a/Documentation/filesystems/mfs.rst +++ b/Documentation/filesystems/mfs.rst @@ -110,11 +110,9 @@ Currently the opcode is defined as follows:: enum mfs_opcode { MFS_OP_READ = 0, MFS_OP_FAULT, - MFS_OP_FAROUND, }; -where means: normal read event, page fault event and the fault around event -before ongoing fault. +where means: normal read event and page fault event. Running mode ============ diff --git a/fs/mfs/data.c b/fs/mfs/data.c index 32d0b6947aa8..c4d429b6644d 100644 --- a/fs/mfs/data.c +++ b/fs/mfs/data.c @@ -430,12 +430,9 @@ static vm_fault_t mfs_filemap_map_pages(struct vm_fault *vmf, { struct file *cfile, *file = vmf->vma->vm_file; struct mfs_file_info *fi = file->private_data; - size_t isize = i_size_read(file_inode(file)); const struct vm_operations_struct *cvm_ops; struct vm_area_struct cvma, *vma, **vma_; - struct range_ctx ctx; vm_fault_t ret; - int err; vma = vmf->vma; memcpy(&cvma, vma, sizeof(struct vm_area_struct)); @@ -445,27 +442,8 @@ static vm_fault_t mfs_filemap_map_pages(struct vm_fault *vmf, if (unlikely(!cvm_ops->map_pages)) return 0; - if ((start_pgoff << PAGE_SHIFT) >= isize) - return 0; (void)get_file(cfile); - ctx.file = cfile; - ctx.object = file_inode(file)->i_private; - ctx.off = start_pgoff << PAGE_SHIFT; - ctx.len = min_t(size_t, isize - ctx.off, (end_pgoff - start_pgoff) << PAGE_SHIFT); - ctx.op = MFS_OP_FAROUND; - ctx.sync = false; - ctx.checker = range_check_mem; - if (need_sync_event(file_inode(file)->i_sb)) { - ctx.sync = true; - ctx.checker = range_check_disk; - } - err = mfs_check_range(&ctx); - if (err) { - fput(cfile); - return 0; - } - vma_ = (struct vm_area_struct **)&vmf->vma; *vma_ = &cvma; ret = cvm_ops->map_pages(vmf, start_pgoff, end_pgoff); diff --git a/include/uapi/linux/mfs.h b/include/uapi/linux/mfs.h index a7d5882b5e50..8a79a4e061fa 100644 --- a/include/uapi/linux/mfs.h +++ b/include/uapi/linux/mfs.h @@ -9,7 +9,6 @@ enum mfs_opcode { MFS_OP_READ = 0, MFS_OP_FAULT, - MFS_OP_FAROUND, }; enum { -- 2.34.1
hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/13283 ------------------ In MFS's remote mode, the directory tree in cache layer will sync from mtree layer. The MFS will hold the parent inode lock and truncate the file which will hold the sb_writers lock first. At this time, if one process create file in the same parent directory, it will holds the sb_writers lock first. And this cause the ABBA deadlock. ``` CPU0 CPU1 ---- ---- lock(&type->i_mutex_dir_key#6/1); lock(sb_writers#9); lock(&type->i_mutex_dir_key#6/1); rlock(sb_writers#9); ``` Fixes: d4b9a6307289 ("mfs: Add basic metadata operation for MFS") Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- fs/mfs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/mfs/inode.c b/fs/mfs/inode.c index e45a5da7a67c..83ae8580573b 100644 --- a/fs/mfs/inode.c +++ b/fs/mfs/inode.c @@ -90,18 +90,21 @@ static int _lookup_create(struct path *lpath, struct path *parent_cpath, dput(dentry); goto retry; } + inode_unlock(cdir); } else { /* dir or file, symlink will be considerred the regular file */ ret = vfs_create(&nop_mnt_idmap, cdir, dentry, linode->i_mode, true); if (ret) goto new_err; + inode_unlock(cdir); ret = vfs_truncate(cpath, linode->i_size); if (ret) goto truncate_err; } - goto out; + return ret; truncate_err: + inode_lock_nested(cdir, I_MUTEX_PARENT); _ret = vfs_unlink(&nop_mnt_idmap, cdir, dentry, NULL); if (_ret) pr_err("cleanup failed for file:%s, err:%d\n", name, _ret); -- 2.34.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/19926 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/OEH... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/19926 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/OEH...
participants (2)
-
Hongbo Li -
patchwork bot