[PATCH v4 0/4] jbd2/ext4/ocfs2: lockless jinode dirty range

Li Chen posted 4 patches 3 months, 1 week ago
fs/ext4/inode.c       | 10 ++++++--
fs/ext4/super.c       | 16 +++++++++----
fs/jbd2/commit.c      | 55 +++++++++++++++++++++++++++++++++----------
fs/jbd2/journal.c     |  5 ++--
fs/jbd2/transaction.c | 21 +++++++++++------
fs/ocfs2/journal.c    |  9 +++++--
include/linux/jbd2.h  | 38 ++++++++++++++++++++++++------
7 files changed, 115 insertions(+), 39 deletions(-)
[PATCH v4 0/4] jbd2/ext4/ocfs2: lockless jinode dirty range
Posted by Li Chen 3 months, 1 week ago
This series makes the jbd2_inode dirty range tracking safe for lockless
reads in jbd2 and filesystem callbacks used by ext4 and ocfs2.

Some paths access jinode fields without holding journal->j_list_lock
(e.g. fast commit helpers and ordered truncate helpers). v1 used READ_ONCE()
on i_dirty_start/end, but Matthew pointed out that loff_t can be torn on
32-bit platforms, and Jan suggested storing the dirty range in PAGE_SIZE
units as pgoff_t.

With this series, jbd2 stores the dirty range as page indexes and uses
READ_ONCE()/WRITE_ONCE() for lockless access. ext4 and ocfs2 use the new
jbd2_jinode_get_dirty_range() accessor which converts the page-based range
back to byte offsets for writeback.

This is based on Jan's suggestion in the review of the ext4 jinode
publication race fix. [1]

Changes since v3:
- Store i_dirty_end_page as an exclusive end page and drop the sentinel.
- Publish end_page before start_page and treat start_page >= end_page as
  empty.

Changes since v2:
- Add jbd2_jinode_get_dirty_range() accessor and convert ext4/ocfs2 to use it
  before switching the underlying representation (per Andreas).
- Rename the dirty range fields to i_dirty_start_page/end_page to make the
  PAGE_SIZE units explicit and avoid silent unit mismatches when bisecting.

Changes since v1:
- Store i_dirty_start/end in PAGE_SIZE units (pgoff_t) to avoid torn loads on
  32-bit (pointed out by Matthew, suggested by Jan).
- Use WRITE_ONCE() for i_dirty_* / i_flags updates in jbd2 (per Jan).
- Drop pointless READ_ONCE() on i_vfs_inode in jbd2_wait_inode_data (per Jan).
- Convert ext4/ocfs2 callbacks to translate page range to byte offsets.

[1]: https://lore.kernel.org/all/4jxwogttddiaoqbstlgou5ox6zs27ngjjz5ukrxafm2z5ijxod@so4eqnykiegj/

v3: https://lore.kernel.org/all/20260224092434.202122-1-me@linux.beauty/
v2: https://lore.kernel.org/all/20260219114645.778338-1-me@linux.beauty/
v1: https://lore.kernel.org/all/20260130031232.60780-1-me@linux.beauty/

Li Chen (4):
  jbd2: add jinode dirty range accessors
  ext4: use jbd2 jinode dirty range accessor
  ocfs2: use jbd2 jinode dirty range accessor
  jbd2: store jinode dirty range in PAGE_SIZE units

 fs/ext4/inode.c       | 10 ++++++--
 fs/ext4/super.c       | 16 +++++++++----
 fs/jbd2/commit.c      | 55 +++++++++++++++++++++++++++++++++----------
 fs/jbd2/journal.c     |  5 ++--
 fs/jbd2/transaction.c | 21 +++++++++++------
 fs/ocfs2/journal.c    |  9 +++++--
 include/linux/jbd2.h  | 38 ++++++++++++++++++++++++------
 7 files changed, 115 insertions(+), 39 deletions(-)

-- 
2.53.0
Re: [PATCH v4 0/4] jbd2/ext4/ocfs2: lockless jinode dirty range
Posted by Li Chen 2 months ago
Hi,

One more note: if there are any remaining concerns or comments on the
series, please let me know and I'll address them promptly.

Thanks,
Li
Re: [PATCH v4 0/4] jbd2/ext4/ocfs2: lockless jinode dirty range
Posted by Li Chen 2 months ago
Hi,

Just a gentle ping on this series posted on March 6, 2026.

The current v4 has Reviewed-by tags from Jan on all four patches.
If there are no further concerns, could you please consider it for
merging?

I'm happy to resend if that would help.

Thanks,
Li
Re: [PATCH v4 0/4] jbd2/ext4/ocfs2: lockless jinode dirty range
Posted by Theodore Ts'o 2 months ago
On Fri, 06 Mar 2026 16:56:38 +0800, Li Chen wrote:
> This series makes the jbd2_inode dirty range tracking safe for lockless
> reads in jbd2 and filesystem callbacks used by ext4 and ocfs2.
> 
> Some paths access jinode fields without holding journal->j_list_lock
> (e.g. fast commit helpers and ordered truncate helpers). v1 used READ_ONCE()
> on i_dirty_start/end, but Matthew pointed out that loff_t can be torn on
> 32-bit platforms, and Jan suggested storing the dirty range in PAGE_SIZE
> units as pgoff_t.
> 
> [...]

Applied, thanks!

[1/4] jbd2: add jinode dirty range accessors
      commit: 5267f6ef49cb5fba426f2d286817b1355fde31da
[2/4] ext4: use jbd2 jinode dirty range accessor
      commit: 660d23669982202c99798658e2a15ccdd001f82b
[3/4] ocfs2: use jbd2 jinode dirty range accessor
      commit: be81084e032c2d74f51173e30f687ce13476cb73
[4/4] jbd2: store jinode dirty range in PAGE_SIZE units
      commit: 4edafa81a1d6020272d0c6eb68faeb810dd083c1

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>