diff options
author | Darrick J. Wong <djwong@kernel.org> | 2023-04-12 04:00:22 +0200 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2023-04-12 04:00:22 +0200 |
commit | 1fc7a0597d237c17b6501f8c33b76d3eaaae9079 (patch) | |
tree | 0a255759b7315e807bc225c5c3be2bc7ffc17394 /fs/xfs/scrub/common.c | |
parent | xfs: retain the AGI when we can't iget an inode to scrub the core (diff) | |
download | linux-1fc7a0597d237c17b6501f8c33b76d3eaaae9079.tar.xz linux-1fc7a0597d237c17b6501f8c33b76d3eaaae9079.zip |
xfs: don't take the MMAPLOCK when scrubbing file metadata
The MMAPLOCK stabilizes mappings in a file's pagecache. Therefore, we
do not need it to check directories, symlinks, extended attributes, or
file-based metadata. Reduce its usage to the one case that requires it,
which is when we want to scrub the data fork of a regular file.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/scrub/common.c')
-rw-r--r-- | fs/xfs/scrub/common.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index b3ba87c4bc79..9aa79665c608 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -988,7 +988,11 @@ xchk_irele( xfs_irele(ip); } -/* Set us up to scrub a file's contents. */ +/* + * Set us up to scrub metadata mapped by a file's fork. Callers must not use + * this to operate on user-accessible regular file data because the MMAPLOCK is + * not taken. + */ int xchk_setup_inode_contents( struct xfs_scrub *sc, @@ -1000,9 +1004,10 @@ xchk_setup_inode_contents( if (error) return error; - /* Got the inode, lock it and we're ready to go. */ - sc->ilock_flags = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL; + /* Lock the inode so the VFS cannot touch this file. */ + sc->ilock_flags = XFS_IOLOCK_EXCL; xfs_ilock(sc->ip, sc->ilock_flags); + error = xchk_trans_alloc(sc, resblks); if (error) goto out; |