Re: [f2fs-dev] [PATCH 14/14] f2fs: make compressed files compatible with large folio
From: Daeho Jeong
Date: Fri Aug 28 2026 - 13:53:50 EST
On Wed, Aug 26, 2026 at 8:10 AM Nanzhe Zhao via Linux-f2fs-devel
<linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx> wrote:
>
> The compression flag is the hint indicates that the inode can be
> compressed, when the inode is using large folio, we expected it keeps
> using the large folio read/write paths and its data stays uncompressed
> on disk until the inode is evicted and re-read
>
> Let f2fs_write_begin() skip the compression overwrite preparation for
> such inodes and remove the compressed-file gate in
> f2fs_read_data_large_folio() so the data is simply read/written as
> regular blocks.
>
Patch 14 removes the compressed-file gate in
f2fs_read_data_large_folio() under the
assumption that "data stays uncompressed on disk".
However, if a file already contains existing compressed clusters on
disk (e.g. from
earlier writes before large folios or created without large folios),
`f2fs_read_data_large_folio()` will issue regular bio reads without
decompressing them.
Userspace reading from an existing compressed cluster will receive raw
compressed
bytes instead of plaintext data.
Fix: If an inode has existing compressed clusters (or until large
folio read path
supports decompression), I think we must not read compressed clusters
via f2fs_read_data_large_folio().
Thanks,
> Signed-off-by: Nanzhe Zhao <zhaonanzhe@xxxxxxxxxx>
> ---
> fs/f2fs/data.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 2e20833c6417..befcdc3742f6 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -2955,12 +2955,6 @@ static int f2fs_read_data_large_folio(struct inode *inode,
> int ret = 0;
> bool folio_in_bio = false;
>
> - if (f2fs_compressed_file(inode)) {
> - if (folio)
> - folio_unlock(folio);
> - return -EOPNOTSUPP;
> - }
> -
> map.m_seg_type = NO_CHECK_TYPE;
>
> if (rac)
> @@ -4935,7 +4929,8 @@ static int f2fs_write_begin(const struct kiocb *iocb,
> }
>
> #ifdef CONFIG_F2FS_FS_COMPRESSION
> - if (f2fs_compressed_file(inode)) {
> + if (f2fs_compressed_file(inode) &&
> + !mapping_large_folio_support(inode->i_mapping)) {
> int ret;
> struct page *page;
>
> --
> 2.43.0
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel