From: Matthew Wilcox <willy@infradead.org>
To: Li Chen <me@linux.beauty>
Cc: Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
Jan Kara <jack@suse.com>
Subject: Re: [PATCH 3/3] ocfs2: use READ_ONCE for lockless jinode reads
Date: Fri, 30 Jan 2026 05:27:59 +0000 [thread overview]
Message-ID: <aXxBX2Ul-S6nJzG5@casper.infradead.org> (raw)
In-Reply-To: <20260130031232.60780-4-me@linux.beauty>
On Fri, Jan 30, 2026 at 11:12:32AM +0800, Li Chen wrote:
> ocfs2 journal commit callback reads jbd2_inode dirty range fields without
> holding journal->j_list_lock.
>
> Use READ_ONCE() for these reads to correct the concurrency assumptions.
I don't think this is the right solution to the problem. If it is,
there needs to be much better argumentation in the commit message.
As I understand it, jbd2_journal_file_inode() initialises jinode,
then adds it to the t_inode_list, then drops the j_list_lock. So the
actual problem we need to address is that there's no memory barrier
between the store to i_dirty_start and the list_add(). Once that's
added, there's no need for a READ_ONCE here.
Or have I misunderstood the problem?
> Suggested-by: Jan Kara <jack@suse.com>
> Signed-off-by: Li Chen <me@linux.beauty>
> ---
> fs/ocfs2/journal.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index 85239807dec7..7032284cdbd6 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -902,8 +902,11 @@ int ocfs2_journal_alloc(struct ocfs2_super *osb)
>
> static int ocfs2_journal_submit_inode_data_buffers(struct jbd2_inode *jinode)
> {
> - return filemap_fdatawrite_range(jinode->i_vfs_inode->i_mapping,
> - jinode->i_dirty_start, jinode->i_dirty_end);
> + struct address_space *mapping = jinode->i_vfs_inode->i_mapping;
> + loff_t dirty_start = READ_ONCE(jinode->i_dirty_start);
> + loff_t dirty_end = READ_ONCE(jinode->i_dirty_end);
> +
> + return filemap_fdatawrite_range(mapping, dirty_start, dirty_end);
> }
>
> int ocfs2_journal_init(struct ocfs2_super *osb, int *dirty)
> --
> 2.52.0
>
next prev parent reply other threads:[~2026-01-30 5:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 3:12 [PATCH 0/3] jbd2/ext4/ocfs2: " Li Chen
2026-01-30 3:12 ` [PATCH 1/3] jbd2: use " Li Chen
2026-02-02 16:40 ` Jan Kara
2026-02-02 16:52 ` Jan Kara
2026-01-30 3:12 ` [PATCH 2/3] ext4: " Li Chen
2026-02-02 16:41 ` Jan Kara
2026-01-30 3:12 ` [PATCH 3/3] ocfs2: " Li Chen
2026-01-30 5:27 ` Matthew Wilcox [this message]
2026-01-30 12:26 ` Li Chen
2026-01-30 16:36 ` Matthew Wilcox
2026-02-01 4:37 ` Li Chen
2026-02-02 17:17 ` Jan Kara
2026-02-03 12:10 ` Li Chen
2026-02-03 12:37 ` Jan Kara
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=aXxBX2Ul-S6nJzG5@casper.infradead.org \
--to=willy@infradead.org \
--cc=jack@suse.com \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=me@linux.beauty \
--cc=ocfs2-devel@lists.linux.dev \
/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®