[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260219114645.778338-4-me@linux.beauty>
Date: Thu, 19 Feb 2026 19:46:44 +0800
From: Li Chen <me@...ux.beauty>
To: Theodore Ts'o <tytso@....edu>,
Jan Kara <jack@...e.cz>,
Mark Fasheh <mark@...heh.com>,
linux-ext4@...r.kernel.org,
ocfs2-devel@...ts.linux.dev,
Matthew Wilcox <willy@...radead.org>,
Joel Becker <jlbec@...lplan.org>,
Joseph Qi <joseph.qi@...ux.alibaba.com>,
linux-kernel@...r.kernel.org
Cc: Li Chen <me@...ux.beauty>
Subject: [PATCH v2 3/3] ocfs2: use READ_ONCE for lockless jinode reads
ocfs2 journal commit callback reads jbd2_inode dirty range fields without
holding journal->j_list_lock.
Use READ_ONCE() for these reads to match the lockless access pattern.
Convert the dirty range from PAGE_SIZE units back to byte offsets before
passing it to writeback.
Suggested-by: Jan Kara <jack@...e.cz>
Signed-off-by: Li Chen <me@...ux.beauty>
---
Changes since v1:
- Convert the jinode dirty range from PAGE_SIZE units (pgoff_t) back to byte
offsets before passing it to writeback.
fs/ocfs2/journal.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 85239807dec7..0b40383ebcdf 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -902,8 +902,17 @@ 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;
+ pgoff_t dirty_start = READ_ONCE(jinode->i_dirty_start);
+ pgoff_t dirty_end = READ_ONCE(jinode->i_dirty_end);
+ loff_t start_byte, end_byte;
+
+ if (dirty_end == JBD2_INODE_DIRTY_RANGE_NONE)
+ return 0;
+ start_byte = (loff_t)dirty_start << PAGE_SHIFT;
+ end_byte = ((loff_t)dirty_end << PAGE_SHIFT) + PAGE_SIZE - 1;
+
+ return filemap_fdatawrite_range(mapping, start_byte, end_byte);
}
int ocfs2_journal_init(struct ocfs2_super *osb, int *dirty)
--
2.52.0
Powered by blists - more mailing lists