mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 23:22:31 +02:00
xfs: improve rt metadata use for scrub
This short series makes some small changes to the way we handle the realtime metadata inodes. First, we now make sure that the bitmap and summary file forks are always loaded at mount time so that every scrubber won't have to call xfs_iread_extents. This won't be easy if we're, say, cross-referencing realtime space allocations. The second change makes the ILOCK annotations more consistent with the rest of XFS. Signed-off-by: Darrick J. Wong <djwong@kernel.org> -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEUzaAxoMeQq6m2jMV+H93GTRKtOsFAmN1fwoACgkQ+H93GTRK tOsLwg/+K27LJjHR9FF/Wpj4A4yupWPj91LYtB10Vd2TVjd6xUoCPxuYBUDctjGG jb40eEg3hE8qFjaOavA8TgY5Od4M0EcdZKnZm9rLIB2w/WYjq00ZW13dnk6n5GXr 9y3OzSEHOyzimbvjddOLv/jyaeUJV8m6uKls653Ou2wRWXmT4oVmYeJGPSv8ZKjL NLmE4zC9o7Qi8UfDOX6r9mrwQgLZLF3qHTGAQrGI0GG+TPjp4PI/SeN4WB27H0Ue VklFPlMh2/Nmo4mfKoNupRLw2G0ZgMM4akkhdG2b0rHO9DC27/swycYUzKUV/pMP L5rlzXE7a2eeia2OF1/HECBJ4meUvJI1qlxm8wMZTPCu92J49swE4o5CUhNhyo3e 31LLf9kiFaJnmWxxDOrDUGP8tK461MfRX3moGpLPNMPjks0QiLE61fbW6FsH7Dlu CwPwVXSgr6JSfYjHpMMDwmYGI9li2KUmuDXXvjEvx0yAU/D2+R8HyTZiVmJiXHXK kseQUTYv8BEloQAFmejf5pPqe3IRQ0CTGuS89k4uoGE2bXaQGwFsvof8ASePM02L ITI4x1aYRRTMnfrj4VFIlK2oAvet9opV7mODW1repSM3OpYXSW7b/uHg5CY/u4eC JrOr222viO1C26p+cCqHaiWn/WxIHy6/Dl3Ju5R55dINNjpFCfs= =Nuyw -----END PGP SIGNATURE----- Merge tag 'scrub-fix-rtmeta-ilocking-6.2_2022-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.2-mergeA xfs: improve rt metadata use for scrub This short series makes some small changes to the way we handle the realtime metadata inodes. First, we now make sure that the bitmap and summary file forks are always loaded at mount time so that every scrubber won't have to call xfs_iread_extents. This won't be easy if we're, say, cross-referencing realtime space allocations. The second change makes the ILOCK annotations more consistent with the rest of XFS. Signed-off-by: Darrick J. Wong <djwong@kernel.org> * tag 'scrub-fix-rtmeta-ilocking-6.2_2022-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux: xfs: make rtbitmap ILOCKing consistent when scanning the rt bitmap file xfs: load rtbitmap and rtsummary extent mapping btrees at mount time
This commit is contained in:
commit
b76f593b33
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -1325,6 +1325,41 @@ xfs_rtalloc_reinit_frextents(
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read in the bmbt of an rt metadata inode so that we never have to load them
|
||||
* at runtime. This enables the use of shared ILOCKs for rtbitmap scans. Use
|
||||
* an empty transaction to avoid deadlocking on loops in the bmbt.
|
||||
*/
|
||||
static inline int
|
||||
xfs_rtmount_iread_extents(
|
||||
struct xfs_inode *ip,
|
||||
unsigned int lock_class)
|
||||
{
|
||||
struct xfs_trans *tp;
|
||||
int error;
|
||||
|
||||
error = xfs_trans_alloc_empty(ip->i_mount, &tp);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
xfs_ilock(ip, XFS_ILOCK_EXCL | lock_class);
|
||||
|
||||
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
|
||||
if (error)
|
||||
goto out_unlock;
|
||||
|
||||
if (xfs_inode_has_attr_fork(ip)) {
|
||||
error = xfs_iread_extents(tp, ip, XFS_ATTR_FORK);
|
||||
if (error)
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
xfs_iunlock(ip, XFS_ILOCK_EXCL | lock_class);
|
||||
xfs_trans_cancel(tp);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the bitmap and summary inodes and the summary cache into the mount
|
||||
* structure at mount time.
|
||||
|
|
@ -1342,14 +1377,27 @@ xfs_rtmount_inodes(
|
|||
return error;
|
||||
ASSERT(mp->m_rbmip != NULL);
|
||||
|
||||
error = xfs_rtmount_iread_extents(mp->m_rbmip, XFS_ILOCK_RTBITMAP);
|
||||
if (error)
|
||||
goto out_rele_bitmap;
|
||||
|
||||
error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip);
|
||||
if (error) {
|
||||
xfs_irele(mp->m_rbmip);
|
||||
return error;
|
||||
}
|
||||
if (error)
|
||||
goto out_rele_bitmap;
|
||||
ASSERT(mp->m_rsumip != NULL);
|
||||
|
||||
error = xfs_rtmount_iread_extents(mp->m_rsumip, XFS_ILOCK_RTSUM);
|
||||
if (error)
|
||||
goto out_rele_summary;
|
||||
|
||||
xfs_alloc_rsum_cache(mp, sbp->sb_rbmblocks);
|
||||
return 0;
|
||||
|
||||
out_rele_summary:
|
||||
xfs_irele(mp->m_rsumip);
|
||||
out_rele_bitmap:
|
||||
xfs_irele(mp->m_rbmip);
|
||||
return error;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user