mm: mmap_region: kill correct_wcount/inode, use allow_write_access()
authorOleg Nesterov <oleg@redhat.com>
Wed, 11 Sep 2013 21:20:20 +0000 (14:20 -0700)
committerGrazvydas Ignotas <notasas@gmail.com>
Sat, 16 Sep 2017 21:29:32 +0000 (00:29 +0300)
commit5dc8e6980d28cb1021c03b30ee95a06b61ce0dbb
treee2f2e75809e13ad72a0c82a61ec35c34866f1122
parentd80de620e38ecd1b40217d361604fb7a839f07ad
mm: mmap_region: kill correct_wcount/inode, use allow_write_access()

correct_wcount and inode in mmap_region() just complicate the code.  This
boolean was needed previously, when deny_write_access() was called before
vma_merge(), now we can simply check VM_DENYWRITE and do
allow_write_access() if it is set.

allow_write_access() checks file != NULL, so this is safe even if it was
possible to use VM_DENYWRITE && !file.  Just we need to ensure we use the
same file which was deny_write_access()'ed, so the patch also moves "file
= vma->vm_file" down after allow_write_access().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Colin Cross <ccross@android.com>
Cc: David Rientjes <rientjes@google.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/mmap.c