ext4: cleanup pagecache before swap i_data
authoryangerkun <yangerkun@huawei.com>
Mon, 11 Feb 2019 05:05:24 +0000 (00:05 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 19:10:02 +0000 (20:10 +0100)
commit071f68163cc0e98d543685a188dc2d909b6bb464
tree948201b1adefa6353efce62ebf31e5a1ce8aeb52
parentcdf9941b770748eb007bbe98df618b0c705b7745
ext4: cleanup pagecache before swap i_data

commit a46c68a318b08f819047843abf349aeee5d10ac2 upstream.

While do swap, we should make sure there has no new dirty page since we
should swap i_data between two inode:
1.We should lock i_mmap_sem with write to avoid new pagecache from mmap
read/write;
2.Change filemap_flush to filemap_write_and_wait and move them to the
space protected by inode lock to avoid new pagecache from buffer read/write.

Signed-off-by: yangerkun <yangerkun@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/ioctl.c