From: Andreas Dilger <adilger@dilger.ca>
To: Li Chen <me@linux.beauty>
Cc: Theodore Ts'o <tytso@mit.edu>, Jan Kara <jack@suse.cz>,
Mark Fasheh <mark@fasheh.com>,
linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev,
Matthew Wilcox <willy@infradead.org>, Jan Kara <jack@suse.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] jbd2: store jinode dirty range in PAGE_SIZE units
Date: Thu, 19 Feb 2026 14:00:13 -0700 [thread overview]
Message-ID: <63C86D0D-9EF6-4D33-95B2-8D0F5B305B0B@dilger.ca> (raw)
In-Reply-To: <20260219114645.778338-2-me@linux.beauty>
On Feb 19, 2026, at 04:46, Li Chen <me@linux.beauty> 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 i_dirty_start/end as they are
> loff_t and 32-bit platforms can observe torn loads. Store the dirty range
> in PAGE_SIZE units as pgoff_t so lockless readers can take non-torn
> snapshots.
When making semantic changes like this, it is best to change the variable
names as well, so that breaks compilation if bisection happens to land
between these patches. Otherwise, that could cause some random behavior
if jbd2 is treating these as pages, but ext4/ocfs2 are treating them as
bytes or vice versa.
Something like i_dirty_{start,end} -> i_dirty_{start,end}_page would make
this very clear what the units are.
To avoid breakage between the patches (which is desirable to avoid problems
with automated bisection) you should make an initial patch with wrappers to
access these values and convert ext4/ocfs2 to use them:
static inline loff_t jbd2_jinode_dirty_start(struct jbd2_inode *jinode)
{
return jinode->i_dirty_start;
}
static inline loff_t jbd2_jinode_dirty_end(struct jbd2_inode *jinode)
{
return jinode->i_dirty_end;
}
then change this in the jbd2 patch at the end, which would then be self-contained:
static inline loff_t jbd2_jinode_dirty_start(struct jbd2_inode *jinode)
{
return (loff_t)jinode->i_dirty_start_page << PAGE_SHIFT;
}
static inline loff_t jbd2_jinode_dirty_end(struct jbd2_inode *jinode)
{
return ((loff_t)jinode->i_dirty_end_page << PAGE_SHIFT) + ~PAGE_MASK;
}
Cheers, Andreas
> 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>
> ---
>
next prev parent reply other threads:[~2026-02-19 21:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 11:46 [PATCH v2 0/3] jbd2/ext4/ocfs2: lockless jinode dirty range Li Chen
2026-02-19 11:46 ` [PATCH v2 1/3] jbd2: store jinode dirty range in PAGE_SIZE units Li Chen
2026-02-19 21:00 ` Andreas Dilger [this message]
2026-02-20 6:43 ` Li Chen
2026-02-23 1:11 ` Andreas Dilger
2026-02-19 11:46 ` [PATCH v2 2/3] ext4: use READ_ONCE for lockless jinode reads Li Chen
2026-02-19 11:46 ` [PATCH v2 3/3] ocfs2: " Li Chen
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=63C86D0D-9EF6-4D33-95B2-8D0F5B305B0B@dilger.ca \
--to=adilger@dilger.ca \
--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=me@linux.beauty \
--cc=ocfs2-devel@lists.linux.dev \
--cc=tytso@mit.edu \
--cc=willy@infradead.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®