Skip to content

Commit d6b636e

Browse files
committed
xfs: halt auto-reclamation activities while rebuilding rmap
Rebuilding the reverse-mapping tree requires us to quiesce all inodes in the filesystem, so we must stop background reclamation of post-EOF and CoW prealloc blocks. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 95eb308 commit d6b636e

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

fs/xfs/xfs_icache.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,3 +1826,21 @@ xfs_inode_clear_cowblocks_tag(
18261826
return __xfs_inode_clear_blocks_tag(ip,
18271827
trace_xfs_perag_clear_cowblocks, XFS_ICI_COWBLOCKS_TAG);
18281828
}
1829+
1830+
/* Disable post-EOF and CoW block auto-reclamation. */
1831+
void
1832+
xfs_icache_disable_reclaim(
1833+
struct xfs_mount *mp)
1834+
{
1835+
cancel_delayed_work_sync(&mp->m_eofblocks_work);
1836+
cancel_delayed_work_sync(&mp->m_cowblocks_work);
1837+
}
1838+
1839+
/* Enable post-EOF and CoW block auto-reclamation. */
1840+
void
1841+
xfs_icache_enable_reclaim(
1842+
struct xfs_mount *mp)
1843+
{
1844+
xfs_queue_eofblocks(mp);
1845+
xfs_queue_cowblocks(mp);
1846+
}

fs/xfs/xfs_icache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,7 @@ xfs_fs_eofblocks_from_user(
131131
int xfs_icache_inode_is_allocated(struct xfs_mount *mp, struct xfs_trans *tp,
132132
xfs_ino_t ino, bool *inuse);
133133

134+
void xfs_icache_disable_reclaim(struct xfs_mount *mp);
135+
void xfs_icache_enable_reclaim(struct xfs_mount *mp);
136+
134137
#endif

fs/xfs/xfs_mount.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,7 @@ xfs_unmountfs(
10721072
uint64_t resblks;
10731073
int error;
10741074

1075-
cancel_delayed_work_sync(&mp->m_eofblocks_work);
1076-
cancel_delayed_work_sync(&mp->m_cowblocks_work);
1077-
1075+
xfs_icache_disable_reclaim(mp);
10781076
xfs_fs_unreserve_ag_blocks(mp);
10791077
xfs_qm_unmount_quotas(mp);
10801078
xfs_rtunmount_inodes(mp);

fs/xfs/xfs_super.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,6 @@ xfs_fs_remount(
13721372
*/
13731373
xfs_restore_resvblks(mp);
13741374
xfs_log_work_queue(mp);
1375-
xfs_queue_eofblocks(mp);
13761375

13771376
/* Recover any CoW blocks that never got remapped. */
13781377
error = xfs_reflink_recover_cow(mp);
@@ -1382,7 +1381,7 @@ xfs_fs_remount(
13821381
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
13831382
return error;
13841383
}
1385-
xfs_queue_cowblocks(mp);
1384+
xfs_icache_enable_reclaim(mp);
13861385

13871386
/* Create the per-AG metadata reservation pool .*/
13881387
error = xfs_fs_reserve_ag_blocks(mp);
@@ -1392,8 +1391,13 @@ xfs_fs_remount(
13921391

13931392
/* rw -> ro */
13941393
if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & SB_RDONLY)) {
1394+
/*
1395+
* Cancel background eofb scanning so it cannot race with the
1396+
* final log force+buftarg wait and deadlock the remount.
1397+
*/
1398+
xfs_icache_disable_reclaim(mp);
1399+
13951400
/* Get rid of any leftover CoW reservations... */
1396-
cancel_delayed_work_sync(&mp->m_cowblocks_work);
13971401
error = xfs_icache_free_cowblocks(mp, NULL);
13981402
if (error) {
13991403
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
@@ -1416,12 +1420,6 @@ xfs_fs_remount(
14161420
*/
14171421
xfs_save_resvblks(mp);
14181422

1419-
/*
1420-
* Cancel background eofb scanning so it cannot race with the
1421-
* final log force+buftarg wait and deadlock the remount.
1422-
*/
1423-
cancel_delayed_work_sync(&mp->m_eofblocks_work);
1424-
14251423
xfs_quiesce_attr(mp);
14261424
mp->m_flags |= XFS_MOUNT_RDONLY;
14271425
}
@@ -1441,6 +1439,7 @@ xfs_fs_freeze(
14411439
{
14421440
struct xfs_mount *mp = XFS_M(sb);
14431441

1442+
xfs_icache_disable_reclaim(mp);
14441443
xfs_save_resvblks(mp);
14451444
xfs_quiesce_attr(mp);
14461445
return xfs_sync_sb(mp, true);
@@ -1454,6 +1453,7 @@ xfs_fs_unfreeze(
14541453

14551454
xfs_restore_resvblks(mp);
14561455
xfs_log_work_queue(mp);
1456+
xfs_icache_enable_reclaim(mp);
14571457
return 0;
14581458
}
14591459

0 commit comments

Comments
 (0)