* [f2fs-dev] [PATCH v2] f2fs: Prevent swap file in LFS mode
@ 2021-05-10 11:24 Shin'ichiro Kawasaki
2021-05-10 11:50 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Shin'ichiro Kawasaki @ 2021-05-10 11:24 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu, linux-f2fs-devel; +Cc: Damien Le Moal
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+
---
fs/f2fs/data.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 96f1a354f89f..285302d009aa 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -4050,6 +4050,12 @@ static int f2fs_swap_activate(struct swap_info_struct *sis, struct file *file,
if (f2fs_readonly(F2FS_I_SB(inode)->sb))
return -EROFS;
+ if (f2fs_lfs_mode(F2FS_I_SB(inode))) {
+ f2fs_err(F2FS_I_SB(inode),
+ "Swapfile not supported in LFS mode");
+ return -EINVAL;
+ }
+
ret = f2fs_convert_inline_inode(inode);
if (ret)
return ret;
--
2.30.2
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: Prevent swap file in LFS mode
2021-05-10 11:24 [f2fs-dev] [PATCH v2] f2fs: Prevent swap file in LFS mode Shin'ichiro Kawasaki
@ 2021-05-10 11:50 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2021-05-10 11:50 UTC (permalink / raw)
To: Shin'ichiro Kawasaki, Jaegeuk Kim, Chao Yu, linux-f2fs-devel
Cc: Damien Le Moal
On 2021/5/10 19:24, Shin'ichiro Kawasaki wrote:
> 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>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-10 11:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-10 11:24 [f2fs-dev] [PATCH v2] f2fs: Prevent swap file in LFS mode Shin'ichiro Kawasaki
2021-05-10 11:50 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).