Commit 0fc48a6e authored by Wei Yang's avatar Wei Yang Committed by Linus Torvalds

mm/mmap: check on file instead of the rb_root_cached of its address_space

In __vma_adjust(), we do the check on *root* to decide whether to adjust
the address_space.  It seems to be more meaningful to do the check on
*file* itself.  This means we are adjusting some data because it is a file
backed vma.

Since we seem to assume the address_space is valid if it is a file backed
vma, let's just replace *root* with *file* here.
Signed-off-by: default avatarWei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Link: https://lkml.kernel.org/r/20200913133631.37781-2-richard.weiyang@linux.alibaba.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 808fbdbe
...@@ -823,7 +823,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, ...@@ -823,7 +823,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
anon_vma_interval_tree_pre_update_vma(next); anon_vma_interval_tree_pre_update_vma(next);
} }
if (root) { if (file) {
flush_dcache_mmap_lock(mapping); flush_dcache_mmap_lock(mapping);
vma_interval_tree_remove(vma, root); vma_interval_tree_remove(vma, root);
if (adjust_next) if (adjust_next)
...@@ -844,7 +844,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, ...@@ -844,7 +844,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
next->vm_pgoff += adjust_next >> PAGE_SHIFT; next->vm_pgoff += adjust_next >> PAGE_SHIFT;
} }
if (root) { if (file) {
if (adjust_next) if (adjust_next)
vma_interval_tree_insert(next, root); vma_interval_tree_insert(next, root);
vma_interval_tree_insert(vma, root); vma_interval_tree_insert(vma, root);
...@@ -896,7 +896,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, ...@@ -896,7 +896,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
anon_vma_unlock_write(anon_vma); anon_vma_unlock_write(anon_vma);
} }
if (root) { if (file) {
i_mmap_unlock_write(mapping); i_mmap_unlock_write(mapping);
uprobe_mmap(vma); uprobe_mmap(vma);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment