@@ -1328,41 +1328,24 @@ xfs_inode_free_eofblocks(
13281328}
13291329
13301330/*
1331- * Background scanning to trim post-EOF preallocated space. This is queued
1332- * based on the 'speculative_prealloc_lifetime' tunable (5m by default).
1331+ * Background scanning to trim preallocated space. This is queued based on the
1332+ * 'speculative_prealloc_lifetime' tunable (5m by default).
13331333 */
1334- void
1335- xfs_queue_eofblocks (
1336- struct xfs_mount * mp )
1334+ static inline void
1335+ xfs_blockgc_queue (
1336+ struct xfs_mount * mp )
13371337{
13381338 rcu_read_lock ();
13391339 if (radix_tree_tagged (& mp -> m_perag_tree , XFS_ICI_BLOCKGC_TAG ))
1340- queue_delayed_work (mp -> m_eofblocks_workqueue ,
1341- & mp -> m_eofblocks_work ,
1342- msecs_to_jiffies (xfs_eofb_secs * 1000 ));
1340+ queue_delayed_work (mp -> m_blockgc_workqueue ,
1341+ & mp -> m_blockgc_work ,
1342+ msecs_to_jiffies (xfs_blockgc_secs * 1000 ));
13431343 rcu_read_unlock ();
13441344}
13451345
1346- void
1347- xfs_eofblocks_worker (
1348- struct work_struct * work )
1349- {
1350- struct xfs_mount * mp = container_of (to_delayed_work (work ),
1351- struct xfs_mount , m_eofblocks_work );
1352-
1353- if (!sb_start_write_trylock (mp -> m_super ))
1354- return ;
1355- xfs_inode_walk (mp , 0 , xfs_inode_free_eofblocks , NULL ,
1356- XFS_ICI_BLOCKGC_TAG );
1357- sb_end_write (mp -> m_super );
1358-
1359- xfs_queue_eofblocks (mp );
1360- }
1361-
13621346static void
13631347xfs_blockgc_set_iflag (
13641348 struct xfs_inode * ip ,
1365- void (* execute )(struct xfs_mount * mp ),
13661349 unsigned long iflag )
13671350{
13681351 struct xfs_mount * mp = ip -> i_mount ;
@@ -1397,7 +1380,7 @@ xfs_blockgc_set_iflag(
13971380 spin_unlock (& ip -> i_mount -> m_perag_lock );
13981381
13991382 /* kick off background trimming */
1400- execute (ip -> i_mount );
1383+ xfs_blockgc_queue (ip -> i_mount );
14011384
14021385 trace_xfs_perag_set_blockgc (ip -> i_mount , pag -> pag_agno , -1 ,
14031386 _RET_IP_ );
@@ -1412,7 +1395,7 @@ xfs_inode_set_eofblocks_tag(
14121395 xfs_inode_t * ip )
14131396{
14141397 trace_xfs_inode_set_eofblocks_tag (ip );
1415- return xfs_blockgc_set_iflag (ip , xfs_queue_eofblocks , XFS_IEOFBLOCKS );
1398+ return xfs_blockgc_set_iflag (ip , XFS_IEOFBLOCKS );
14161399}
14171400
14181401static void
@@ -1556,45 +1539,12 @@ xfs_inode_free_cowblocks(
15561539 return ret ;
15571540}
15581541
1559- /*
1560- * Background scanning to trim preallocated CoW space. This is queued
1561- * based on the 'speculative_cow_prealloc_lifetime' tunable (5m by default).
1562- * (We'll just piggyback on the post-EOF prealloc space workqueue.)
1563- */
1564- void
1565- xfs_queue_cowblocks (
1566- struct xfs_mount * mp )
1567- {
1568- rcu_read_lock ();
1569- if (radix_tree_tagged (& mp -> m_perag_tree , XFS_ICI_BLOCKGC_TAG ))
1570- queue_delayed_work (mp -> m_eofblocks_workqueue ,
1571- & mp -> m_cowblocks_work ,
1572- msecs_to_jiffies (xfs_cowb_secs * 1000 ));
1573- rcu_read_unlock ();
1574- }
1575-
1576- void
1577- xfs_cowblocks_worker (
1578- struct work_struct * work )
1579- {
1580- struct xfs_mount * mp = container_of (to_delayed_work (work ),
1581- struct xfs_mount , m_cowblocks_work );
1582-
1583- if (!sb_start_write_trylock (mp -> m_super ))
1584- return ;
1585- xfs_inode_walk (mp , 0 , xfs_inode_free_cowblocks , NULL ,
1586- XFS_ICI_BLOCKGC_TAG );
1587- sb_end_write (mp -> m_super );
1588-
1589- xfs_queue_cowblocks (mp );
1590- }
1591-
15921542void
15931543xfs_inode_set_cowblocks_tag (
15941544 xfs_inode_t * ip )
15951545{
15961546 trace_xfs_inode_set_cowblocks_tag (ip );
1597- return xfs_blockgc_set_iflag (ip , xfs_queue_cowblocks , XFS_ICOWBLOCKS );
1547+ return xfs_blockgc_set_iflag (ip , XFS_ICOWBLOCKS );
15981548}
15991549
16001550void
@@ -1610,17 +1560,15 @@ void
16101560xfs_stop_block_reaping (
16111561 struct xfs_mount * mp )
16121562{
1613- cancel_delayed_work_sync (& mp -> m_eofblocks_work );
1614- cancel_delayed_work_sync (& mp -> m_cowblocks_work );
1563+ cancel_delayed_work_sync (& mp -> m_blockgc_work );
16151564}
16161565
16171566/* Enable post-EOF and CoW block auto-reclamation. */
16181567void
16191568xfs_start_block_reaping (
16201569 struct xfs_mount * mp )
16211570{
1622- xfs_queue_eofblocks (mp );
1623- xfs_queue_cowblocks (mp );
1571+ xfs_blockgc_queue (mp );
16241572}
16251573
16261574/* Scan all incore inodes for block preallocations that we can remove. */
@@ -1644,6 +1592,24 @@ xfs_blockgc_scan(
16441592 return 0 ;
16451593}
16461594
1595+ /* Background worker that trims preallocated space. */
1596+ void
1597+ xfs_blockgc_worker (
1598+ struct work_struct * work )
1599+ {
1600+ struct xfs_mount * mp = container_of (to_delayed_work (work ),
1601+ struct xfs_mount , m_blockgc_work );
1602+ int error ;
1603+
1604+ if (!sb_start_write_trylock (mp -> m_super ))
1605+ return ;
1606+ error = xfs_blockgc_scan (mp , NULL );
1607+ if (error )
1608+ xfs_info (mp , "preallocation gc worker failed, err=%d" , error );
1609+ sb_end_write (mp -> m_super );
1610+ xfs_blockgc_queue (mp );
1611+ }
1612+
16471613/*
16481614 * Try to free space in the filesystem by purging eofblocks and cowblocks.
16491615 */
0 commit comments