Chao Yu bd2b9872d3 f2fs: fix avoid race between truncate and background GC
[ Upstream commit a33c150237a20d97a174243bc658c86502f9d370 ]

Thread A				Background GC
- f2fs_setattr isize to 0
 - truncate_setsize
					- gc_data_segment
					 - f2fs_get_read_data_page page #0
					  - set_page_dirty
					  - set_cold_data
 - f2fs_truncate

- f2fs_setattr isize to 4k
- read 4k <--- hit data in cached page #0

Above race condition can cause read out invalid data in a truncated
page, fix it by i_gc_rwsem[WRITE] lock.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-15 09:46:50 +02:00
..
2018-06-11 10:16:13 -07:00
2018-06-15 07:55:24 +09:00
2018-09-15 09:46:46 +02:00
2018-05-22 14:27:52 -04:00
2018-05-22 14:27:52 -04:00
2018-05-22 14:27:53 -04:00
2018-06-15 18:11:26 -03:00
2018-07-27 12:51:00 -07:00
2018-06-07 17:34:40 -07:00
2018-06-05 19:23:26 +02:00
2018-06-08 17:21:52 -07:00
2018-06-07 17:34:35 -07:00
2018-05-03 16:11:37 -06:00
2018-06-11 08:22:34 -07:00
2018-09-09 10:32:41 +02:00