summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_rtalloc.h
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-01-04 17:38:36 -0800
committerDarrick J. Wong <djwong@kernel.org>2022-01-11 15:11:04 -0800
commit65552b02a10acea68127081faf414b84a65d1855 (patch)
treefc7b6d9dc15c866923c23d224e79afcf75ed5a53 /fs/xfs/xfs_rtalloc.h
parent7e937bb3cbe1f6b9840a43f879aa6e3f1a5e6537 (diff)
xfs: take the ILOCK when readdir inspects directory mapping dataxfs-5.17-merge_2022-01-11
I was poking around in the directory code while diagnosing online fsck bugs, and noticed that xfs_readdir doesn't actually take the directory ILOCK when it calls xfs_dir2_isblock. xfs_dir_open most probably loaded the data fork mappings and the VFS took i_rwsem (aka IOLOCK_SHARED) so we're protected against writer threads, but we really need to follow the locking model like we do in other places. To avoid unnecessarily cycling the ILOCK for fairly small directories, change the block/leaf _getdents functions to consume the ILOCK hold that the parent readdir function took to decide on a _getdents implementation. It is ok to cycle the ILOCK in readdir because the VFS takes the IOLOCK in the appropriate mode during lookups and writes, and we don't want to be holding the ILOCK when we copy directory entries to userspace in case there's a page fault. We really only need it to protect against data fork lookups, like we do for other files. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_rtalloc.h')
0 files changed, 0 insertions, 0 deletions