Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wenjie Qi" <qwjhust@gmail.com>, jaegeuk@kernel.org, chao@kernel.org
Cc: hch@lst.de, jack@suse.cz, axboe@kernel.dk, tz2294@columbia.edu,
	baohua@kernel.org, linux-mm@kvack.org, qiwenjie@xiaomi.com,
	syzbot+cid5582b8164122eda@syzkaller.appspotmail.com
Subject: Re: [PATCH v6 2/2] f2fs: enable buffered RWF_DONTCACHE
Date: Sat, 28 Nov 2026 08:49:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-238563@kernel.org> (raw)
In-Reply-To: <cfdfaea72b21b8abf58cb250495150d92e73beda.1795746008.git.qiwenjie@xiaomi.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] f2fs: lost dropbehind state on compressed writes in
  f2fs_write_begin()
--

commit 2b2066d5ccd0493ea51e9dc20f74af55a2621a50
Author: Wenjie Qi <qwjhust@gmail.com>

f2fs: enable buffered RWF_DONTCACHE

This commit adds buffered RWF_DONTCACHE support to f2fs by passing
FGP_DONTCACHE to f2fs_filemap_get_folio() in f2fs_write_begin() and
advertising FOP_DONTCACHE in f2fs_file_operations.

> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 37d74afc8b26a..f3559c27d44cb 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -5622,6 +5622,9 @@ static int f2fs_write_begin(const struct kiocb *iocb,
>  	unsigned int blen;
>  	int err = 0;
>  
> +	if (iocb && iocb->ki_flags & IOCB_DONTCACHE)
> +		fgp |= FGP_DONTCACHE;
> +
>  	trace_f2fs_write_begin(inode, pos, len);
>  
>  	if (!f2fs_is_checkpoint_ready(sbi)) {

[Severity: Medium]
Does an RWF_DONTCACHE write to a compressed file lose its dropbehind
state on cluster folios?

When f2fs_write_begin() takes the f2fs_prepare_compress_overwrite() path
and returns early, prepare_compress_overwrite() looks up and relocks
cluster folios with hardcoded FGP_LOCK | FGP_WRITE | FGP_CREAT and
filemap_lock_folio() without FGP_DONTCACHE:

fs/f2fs/compress.c:prepare_compress_overwrite() {
	...
	fgf_t fgp_flag = FGP_LOCK | FGP_WRITE | FGP_CREAT;
	...
		folio = f2fs_filemap_get_folio(mapping, f_index,
				fgp_flag, GFP_NOFS);
	...
		folio = filemap_lock_folio(mapping, f_index);
}

New cluster folios are never marked dropbehind, and existing ones have
PG_dropbehind cleared by __filemap_get_folio_mpol().  During writeback,
f2fs_write_compressed_pages() also skips f2fs_outplace_write_data() for
i == 0 and i > cc->valid_nr_cblocks, so BIO_COMPLETE_IN_TASK is not set
from all folios in cc->rpages[] even though f2fs_compress_write_end_io()
calls folio_end_writeback() on all cic->nr_rpages folios when the last
compressed block finishes I/O.  As a result, compressed cluster folios
written with RWF_DONTCACHE remain in the page cache after writeback.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795746008.git.qiwenjie@xiaomi.com?part=2


      reply	other threads:[~2026-11-28  8:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 12:59 [PATCH v4 0/2] f2fs: enable buffered RWF_DONTCACHE Wenjie Qi
2026-09-03 12:59 ` [PATCH v4 1/2] f2fs: complete dropbehind write bios in task context Wenjie Qi
2026-09-04 22:35   ` Tal Zussman
2026-09-03 12:59 ` [PATCH v4 2/2] f2fs: enable buffered RWF_DONTCACHE Wenjie Qi
2026-09-05  7:07 ` [syzbot ci] " syzbot ci
2026-09-05 13:29   ` [PATCH] f2fs: handle NULL kiocb in write_begin Wenjie Qi
2026-09-05 14:26     ` [syzbot ci] Re: f2fs: enable buffered RWF_DONTCACHE syzbot ci
2026-09-08  3:55 ` [PATCH v5 0/2] " Wenjie Qi
2026-09-08  3:55   ` [PATCH v5 1/2] f2fs: complete dropbehind write bios in task context Wenjie Qi
2026-09-08  3:55   ` [PATCH v5 2/2] f2fs: enable buffered RWF_DONTCACHE Wenjie Qi
2026-09-15  1:57   ` [PATCH v5 0/2] " Wenjie Qi
2026-11-27  8:48   ` [PATCH v6 " Wenjie Qi
2026-11-27  8:48     ` [PATCH v6 1/2] f2fs: complete dropbehind write bios in task context Wenjie Qi
2026-11-28  8:49       ` sashiko-bot
2026-11-27  8:48     ` [PATCH v6 2/2] f2fs: enable buffered RWF_DONTCACHE Wenjie Qi
2026-11-28  8:49       ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-238563@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=baohua@kernel.org \
    --cc=chao@kernel.org \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=jaegeuk@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=qiwenjie@xiaomi.com \
    --cc=qwjhust@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=syzbot+cid5582b8164122eda@syzkaller.appspotmail.com \
    --cc=tz2294@columbia.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox