mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Li Chen <me@linux.beauty>
To: "Jan Kara" <jack@suse.cz>
Cc: "Theodore Ts'o" <tytso@mit.edu>, "Mark Fasheh" <mark@fasheh.com>,
	"linux-ext4" <linux-ext4@vger.kernel.org>,
	"ocfs2-devel" <ocfs2-devel@lists.linux.dev>,
	"Jan Kara" <jack@suse.com>,
	"linux-kernel" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 4/4] jbd2: store jinode dirty range in PAGE_SIZE units
Date: Fri, 06 Mar 2026 13:44:02 +0800	[thread overview]
Message-ID: <19cc1aca2a2.6a1ddcaa4201103.2951903079220142463@linux.beauty> (raw)
In-Reply-To: <jekg3rqfscaashwrnzisjjwpcyep2d4w6niyiahcastic4gmcz@3lgz3oqsfavk>

Hi Jan,

 ---- On Tue, 03 Mar 2026 17:01:28 +0800  Jan Kara <jack@suse.cz> wrote --- 
 > On Mon 02-03-26 19:27:13, Jan Kara wrote:
 > > On Tue 24-02-26 17:24:33, Li Chen wrote:
 > > > jbd2_inode fields are updated under journal->j_list_lock, but some paths
 > > > read them without holding the lock (e.g. fast commit helpers and ordered
 > > > truncate helpers).
 > > > 
 > > > READ_ONCE() alone is not sufficient for the dirty range fields when they
 > > > are stored as loff_t because 32-bit platforms can observe torn loads.
 > > > Store the dirty range in PAGE_SIZE units as pgoff_t instead.
 > > > 
 > > > Use READ_ONCE() on the read side and WRITE_ONCE() on the write side for the
 > > > dirty range and i_flags to match the existing lockless access pattern.
 > > > 
 > > > Suggested-by: Jan Kara <jack@suse.cz>
 > > > Reviewed-by: Jan Kara <jack@suse.cz>
 > > > Signed-off-by: Li Chen <me@linux.beauty>
 > > ...
 > > > @@ -2654,15 +2655,20 @@ static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode,
 > > >      jbd2_debug(4, "Adding inode %lu, tid:%d\n", jinode->i_vfs_inode->i_ino,
 > > >              transaction->t_tid);
 > > >  
 > > > +    start_page = (pgoff_t)(start_byte >> PAGE_SHIFT);
 > > > +    end_page = (pgoff_t)(end_byte >> PAGE_SHIFT);
 > > 
 > > MAX_LFS_SIZE on 32-bit is ULONG_MAX << PAGE_SHIFT and that's maximum file
 > > size. So we could do here end_page = DIV_ROUND_UP(end_byte, PAGE_SIZE) and
 > > just use end_page as exclusive end of a range to flush and get rid of
 > > special JBD2_INODE_DIRTY_RANGE_NONE value.
 > > 
 > > The problem with the scheme you use is that files of MAX_LFS_SIZE would be
 > > treated as having empty flush range...
 > 
 > Or perhaps even easier might be to set start_page to ULONG_MAX and end_page
 > to 0 and use start_page > end_page as an indication of empty range.

Great idea! Thanks for the detailed review.

I will update the range handling to avoid the sentinel collision.

Regards,
Li

      reply	other threads:[~2026-03-06  5:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24  9:24 [PATCH v3 0/4] jbd2/ext4/ocfs2: lockless jinode dirty range Li Chen
2026-02-24  9:24 ` [PATCH v3 1/4] jbd2: add jinode dirty range accessors Li Chen
2026-03-02 18:07   ` Jan Kara
2026-02-24  9:24 ` [PATCH v3 2/4] ext4: use jbd2 jinode dirty range accessor Li Chen
2026-02-24  9:24 ` [PATCH v3 3/4] ocfs2: " Li Chen
2026-03-02 18:07   ` Jan Kara
2026-02-24  9:24 ` [PATCH v3 4/4] jbd2: store jinode dirty range in PAGE_SIZE units Li Chen
2026-03-02 18:27   ` Jan Kara
2026-03-03  9:01     ` Jan Kara
2026-03-06  5:44       ` Li Chen [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=19cc1aca2a2.6a1ddcaa4201103.2951903079220142463@linux.beauty \
    --to=me@linux.beauty \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=tytso@mit.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

all inboxes | Powered by JetHome®