Re: [PATCH v2] f2fs: add READ_ONCE() for i_blocks in f2fs_update_inode()

From: Chao Yu

Date: Thu Mar 19 2026 - 07:04:36 EST


On 2026/3/18 15:32, Cen Zhang wrote:
f2fs_update_inode() reads inode->i_blocks without holding i_lock to
serialize it to the on-disk inode, while concurrent truncate or
allocation paths may modify i_blocks under i_lock. Since blkcnt_t is
u64, this risks torn reads on 32-bit architectures.

Following the approach in ext4_inode_blocks_set(), add READ_ONCE() to prevent
potential compiler-induced tearing.

Fixes: 19f99cee206c ("f2fs: add core inode operations")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Cen Zhang <zzzccc427@xxxxxxxxx>

Reviewed-by: Chao Yu <chao@xxxxxxxxxx>

Thanks,