mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: Daeho Jeong <daeho43@gmail.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com,
	Daeho Jeong <daehojeong@google.com>
Subject: Re: [f2fs-dev] [PATCH v2 06/20] f2fs: support subpage blocks in data read path and GC
Date: Tue, 17 Nov 2026 16:51:34 +0000	[thread overview]
Message-ID: <avyGFkZdLhKIC9Rs@google.com> (raw)
In-Reply-To: <22a8264a-0538-458d-a20e-f1d732aa69ac@kernel.org>

On 11/17, Chao Yu wrote:
> On 11/16/26 12:08, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@google.com>
> > 
> > With subpage blocks, a folio can be partially uptodate, so reads and GC
> > have to work per block.
> > 
> > - Read only the non-uptodate blocks of a multi-block folio, and send
> >   every inode to this path in subpage mode.
> > - Do not use the folio state when a single bio reads the whole folio.
> > - Implement ->is_partially_uptodate.
> > - Convert block indices to folio indices in the data folio getters and
> >   GC, and prefetch the whole folio in GC so that its blocks are read
> >   together.
> > - Fix error handling in f2fs_read_data_large_folio().
> > - Zero the blocks past EOF in f2fs_read_data_large_folio() instead of
> >   reading them, as f2fs_read_single_page() does. With subpage blocks,
> >   they share a page with the last block of the file and can be seen
> >   through mmap.
> > - Test the per-block uptodate state in f2fs_find_data_folio() under the
> >   folio lock, as ->release_folio can free the folio state otherwise. A
> >   fully uptodate folio is still returned without the lock.
> > - Keep the folio state of a folio that is not fully uptodate in
> >   ->release_folio while the folio has other users. Otherwise a block
> >   that a lockless reader, e.g. a dentry lookup, is using can be read
> >   from disk again.
> > - Get sbi from the folio in f2fs_finish_read_bio() only after the
> >   compressed page check, as nothing pins the inode of a compressed page
> >   once its cluster is unlocked.
> > - Rename helpers that now take block indices, e.g.
> >   f2fs_submit_page_read() to f2fs_submit_block_read().
> > 
> > The read changes also apply to large folios when the block size equals
> > PAGE_SIZE.
> > 
> > Signed-off-by: Daeho Jeong <daehojeong@google.com>
> 
> Reviewed-by: Chao Yu <chao@kernel.org>
> 
> > @@ -5636,6 +5684,16 @@ bool f2fs_release_folio(struct folio *folio, gfp_t wait)
> >  	if (folio_test_dirty(folio))
> >  		return false;
> >  
> > +	/*
> > +	 * The folio state holds the uptodate state of the blocks of a folio
> > +	 * that is not fully uptodate. Keep it while the folio has users other
> > +	 * than the caller, e.g. a dentry lookup that parses a block without
> > +	 * the folio lock, so that the block is not read again under them.
> > +	 */
> > +	if (f2fs_folio_has_ffs(folio) && !folio_test_uptodate(folio) &&
> > +	    folio_ref_count(folio) > folio_expected_ref_count(folio) + 1)
> > +		return false;
> > +
> >  	ffs_detach_free(folio);
> >  	return true;
> >  }
> 
> BTW, we should notice this side effect, dio may be blocked due to it can not
> invalidate folios which is referenced by other buffered reader.

Not from my end. Can we add a bug_on to detect this first with a reproducer?

> 
>     Thread A (buffered read)                Thread B (DIO write, same range)
>     - filemap_read
>      - filemap_get_pages
>      : folio ref taken (batch), folio
>        partially uptodate, ffs present
>      - copy_folio_to_iter
>                                             - iomap_dio_complete
>                                              - kiocb_invalidate_post_direct_write
>                                               - invalidate_inode_pages2_range
>                                                - folio_unmap_invalidate
>                                                 - f2fs_release_folio
>                                                 : !uptodate && ref > expected + 1
>                                                   -> false
>                                                : -EBUSY
>                                               - dio_warn_stale_pagecache
>                                               : pr_crit, wb_err = -EIO
> 
> Thanks,

  reply	other threads:[~2026-11-17 16:51 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  4:08 [PATCH v2 00/20] f2fs: support block size smaller than PAGE_SIZE Daeho Jeong
2026-11-16  4:08 ` [PATCH v2 01/20] f2fs: use block-based index and size calculations in more paths Daeho Jeong
2026-11-17  8:53   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 02/20] f2fs: support subpage block size superblock and mount Daeho Jeong
2026-11-17  8:53   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 03/20] f2fs: extend f2fs_folio_state for subpage blocks Daeho Jeong
2026-11-17  8:54   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 04/20] f2fs: support subpage blocks in directory operations Daeho Jeong
2026-11-17  8:54   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 05/20] f2fs: convert inode dirty page counters to dirty block counters Daeho Jeong
2026-11-17  8:54   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 06/20] f2fs: support subpage blocks in data read path and GC Daeho Jeong
2026-11-17  8:58   ` [f2fs-dev] " Chao Yu
2026-11-17 16:51     ` Jaegeuk Kim [this message]
2026-11-16  4:08 ` [PATCH v2 07/20] f2fs: support subpage blocks in data write path and writeback Daeho Jeong
2026-11-17 10:43   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 08/20] f2fs: adapt range operations and mmap for subpage blocks Daeho Jeong
2026-11-17 11:05   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 09/20] f2fs: support subpage blocks in pinned files Daeho Jeong
2026-11-17 11:09   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 10/20] f2fs: support subpage blocks in collapse and insert range Daeho Jeong
2026-11-17 11:13   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 11/20] f2fs: support subpage blocks in move range Daeho Jeong
2026-11-17 11:22   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 12/20] f2fs: support subpage blocks in defragmentation Daeho Jeong
2026-11-17 11:25   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 13/20] f2fs: support subpage blocks in swapfile activation Daeho Jeong
2026-11-17 11:25   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 14/20] f2fs: support subpage blocks in fs-verity enablement Daeho Jeong
2026-11-17 11:38   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 15/20] f2fs: support subpage blocks in atomic writes Daeho Jeong
2026-11-17 11:39   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 16/20] f2fs: preserve inline data in subpage block mode Daeho Jeong
2026-11-17 11:40   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 17/20] f2fs: support subpage blocks in online resize Daeho Jeong
2026-11-17 11:41   ` [f2fs-dev] " Chao Yu
2026-11-16  4:08 ` [PATCH v2 18/20] f2fs: support subpage blocks in compression Daeho Jeong
2026-11-16  4:08 ` [PATCH v2 19/20] f2fs: count compress cache entries in pages for its memory limit Daeho Jeong
2026-11-16  4:08 ` [PATCH v2 20/20] f2fs: enable subpage block size support Daeho Jeong
2026-11-17 16:50 ` [f2fs-dev] [PATCH v2 00/20] f2fs: support block size smaller than PAGE_SIZE patchwork-bot+f2fs

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=avyGFkZdLhKIC9Rs@google.com \
    --to=jaegeuk@kernel.org \
    --cc=chao@kernel.org \
    --cc=daeho43@gmail.com \
    --cc=daehojeong@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®