diff options
author | Long Li <leo.lilong@huawei.com> | 2022-11-18 00:02:56 +0300 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2022-11-21 21:00:01 +0300 |
commit | 28b4b0596343d19d140da059eee0e5c2b5328731 (patch) | |
tree | c33a8c9c5251fede2e7cafd56205187f909083d3 /fs/affs | |
parent | 64c80dfd04d1dd2ecf550542c8f3f41b54b20207 (diff) | |
download | linux-28b4b0596343d19d140da059eee0e5c2b5328731.tar.xz |
xfs: fix incorrect i_nlink caused by inode racing
The following error occurred during the fsstress test:
XFS: Assertion failed: VFS_I(ip)->i_nlink >= 2, file: fs/xfs/xfs_inode.c, line: 2452
The problem was that inode race condition causes incorrect i_nlink to be
written to disk, and then it is read into memory. Consider the following
call graph, inodes that are marked as both XFS_IFLUSHING and
XFS_IRECLAIMABLE, i_nlink will be reset to 1 and then restored to original
value in xfs_reinit_inode(). Therefore, the i_nlink of directory on disk
may be set to 1.
xfsaild
xfs_inode_item_push
xfs_iflush_cluster
xfs_iflush
xfs_inode_to_disk
xfs_iget
xfs_iget_cache_hit
xfs_iget_recycle
xfs_reinit_inode
inode_init_always
xfs_reinit_inode() needs to hold the ILOCK_EXCL as it is changing internal
inode state and can race with other RCU protected inode lookups. On the
read side, xfs_iflush_cluster() grabs the ILOCK_SHARED while under rcu +
ip->i_flags_lock, and so xfs_iflush/xfs_inode_to_disk() are protected from
racing inode updates (during transactions) by that lock.
Fixes: ff7bebeb91f8 ("xfs: refactor the inode recycling code") # goes further back than this
Signed-off-by: Long Li <leo.lilong@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/affs')
0 files changed, 0 insertions, 0 deletions