Re: [PATCH 1/3] jbd2: use READ_ONCE for lockless jinode reads

From: Jan Kara

Date: Mon Feb 02 2026 - 11:44:57 EST


On Fri 30-01-26 11:12:30, 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 the ordered truncate fast path).
>
> Use READ_ONCE() for these lockless reads to correct the
> concurrency assumptions.
>
> Suggested-by: Jan Kara <jack@xxxxxxxx>
> Signed-off-by: Li Chen <me@linux.beauty>

Just one nit below. With that fixed feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

> @@ -191,12 +197,30 @@ EXPORT_SYMBOL(jbd2_submit_inode_data);
>
> int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode)
> {
> - if (!jinode || !(jinode->i_flags & JI_WAIT_DATA) ||
> - !jinode->i_vfs_inode || !jinode->i_vfs_inode->i_mapping)
> + struct address_space *mapping;
> + struct inode *inode;
> + unsigned long flags;
> + loff_t start, end;
> +
> + if (!jinode)
> + return 0;
> +
> + flags = READ_ONCE(jinode->i_flags);
> + if (!(flags & JI_WAIT_DATA))
> + return 0;
> +
> + inode = READ_ONCE(jinode->i_vfs_inode);

i_vfs_inode never changes so READ_ONCE is pointless here.

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR