xfs: make rtbitmap ILOCKing consistent when scanning the rt bitmap file
authorDarrick J. Wong <djwong@kernel.org>
Mon, 7 Nov 2022 01:03:18 +0000 (17:03 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 16 Nov 2022 23:25:03 +0000 (15:25 -0800)
xfs_rtalloc_query_range scans the realtime bitmap file in order of
increasing file offset, so this caller can take ILOCK_SHARED on the rt
bitmap inode instead of ILOCK_EXCL.  This isn't going to yield any
practical benefits at mount time, but we'd like to make the locking
usage consistent around xfs_rtalloc_query_all calls.  Make all the
places we do this use the same xfs_ilock lockflags for consistency.

Fixes: 4c934c7dd60c ("xfs: report realtime space information via the rtbitmap")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/xfs_fsmap.c
fs/xfs/xfs_rtalloc.c

index d8337274c74d09edecfc5774ee2cfb6e7183e2b3..88a88506ffffe4aaeaba676e2b734bd0bce6e7cf 100644 (file)
@@ -524,7 +524,7 @@ xfs_getfsmap_rtdev_rtbitmap_query(
        struct xfs_mount                *mp = tp->t_mountp;
        int                             error;
 
-       xfs_ilock(mp->m_rbmip, XFS_ILOCK_SHARED);
+       xfs_ilock(mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP);
 
        /*
         * Set up query parameters to return free rtextents covering the range
@@ -551,7 +551,7 @@ xfs_getfsmap_rtdev_rtbitmap_query(
        if (error)
                goto err;
 err:
-       xfs_iunlock(mp->m_rbmip, XFS_ILOCK_SHARED);
+       xfs_iunlock(mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP);
        return error;
 }
 
index b0846204c436d3ad293c5b03eb5d30021387ba40..16534e9873f69449644992dbb8b8797684713e4b 100644 (file)
@@ -1311,10 +1311,10 @@ xfs_rtalloc_reinit_frextents(
        uint64_t                val = 0;
        int                     error;
 
-       xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL);
+       xfs_ilock(mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP);
        error = xfs_rtalloc_query_all(mp, NULL, xfs_rtalloc_count_frextent,
                        &val);
-       xfs_iunlock(mp->m_rbmip, XFS_ILOCK_EXCL);
+       xfs_iunlock(mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP);
        if (error)
                return error;