f2fs: Prevent swap file in LFS mode
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Mon, 10 May 2021 11:24:44 +0000 (20:24 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:55:43 +0000 (16:55 +0200)
commite582a2f35245de96836a2f18ebc0f2b7caee7a03
tree19364906ac45c9abe55151ac03222dd43236e2a7
parent36ae903607f6aadfd73e0f345e6f6abf8d1bde23
f2fs: Prevent swap file in LFS mode

commit d927ccfccb009ede24448d69c08b12e7c8a6979b upstream.

The kernel writes to swap files on f2fs directly without the assistance
of the filesystem. This direct write by kernel can be non-sequential
even when the f2fs is in LFS mode. Such non-sequential write conflicts
with the LFS semantics. Especially when f2fs is set up on zoned block
devices, the non-sequential write causes unaligned write command errors.

To avoid the non-sequential writes to swap files, prevent swap file
activation when the filesystem is in LFS mode.

Fixes: 4969c06a0d83 ("f2fs: support swap file w/ DIO")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: stable@vger.kernel.org # v5.10+
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/f2fs/data.c