]> git.ipfire.org Git - thirdparty/linux.git/commit
f2fs: add READ_ONCE() for i_blocks in f2fs_update_inode()
authorCen Zhang <zzzccc427@gmail.com>
Wed, 18 Mar 2026 07:32:53 +0000 (15:32 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 24 Mar 2026 17:21:01 +0000 (17:21 +0000)
commit5471834a96fb697874be2ca0b052e74bcf3c23d1
tree8b820ccfc7c6fd08643bda26d4ffda5c74286e6f
parent1e134c33b931a1b082605b15116403571dab6bbb
f2fs: add READ_ONCE() for i_blocks in f2fs_update_inode()

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@vger.kernel.org
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/inode.c