]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ext4: fix races between buffered IO and collapse / insert range
authorJan Kara <jack@suse.com>
Mon, 7 Dec 2015 19:31:11 +0000 (14:31 -0500)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:45:45 +0000 (15:45 -0700)
commit1b0baafb550a9b2ffa5848a5c7a8122abcb1cc08
tree951f4b583c069fbe81f3877164e92007d2120818
parentce2d8bf9508e231afecbb9054b94650fc030a2d3
ext4: fix races between buffered IO and collapse / insert range

Orabug: 23331011

Current code implementing FALLOC_FL_COLLAPSE_RANGE and
FALLOC_FL_INSERT_RANGE is prone to races with buffered writes and page
faults. If buffered write or write via mmap manages to squeeze between
filemap_write_and_wait_range() and truncate_pagecache() in the fallocate
implementations, the written data is simply discarded by
truncate_pagecache() although it should have been shifted.

Fix the problem by moving filemap_write_and_wait_range() call inside
i_mutex and i_mmap_sem. That way we are protected against races with
both buffered writes and page faults.

Signed-off-by: Jan Kara <jack@suse.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Mingming Cao <mingming.cao@oracle.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 181aaebde9360b8235df647ee36dafdc041d4964)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
fs/ext4/extents.c