aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_sync.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c71
1 files changed, 27 insertions, 44 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index 5cc158e52d4c..e4c938afb910 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -179,6 +179,8 @@ restart:
179 if (error == EFSCORRUPTED) 179 if (error == EFSCORRUPTED)
180 break; 180 break;
181 181
182 cond_resched();
183
182 } while (nr_found && !done); 184 } while (nr_found && !done);
183 185
184 if (skipped) { 186 if (skipped) {
@@ -984,6 +986,8 @@ restart:
984 986
985 *nr_to_scan -= XFS_LOOKUP_BATCH; 987 *nr_to_scan -= XFS_LOOKUP_BATCH;
986 988
989 cond_resched();
990
987 } while (nr_found && !done && *nr_to_scan > 0); 991 } while (nr_found && !done && *nr_to_scan > 0);
988 992
989 if (trylock && !done) 993 if (trylock && !done)
@@ -1001,7 +1005,7 @@ restart:
1001 * ensure that when we get more reclaimers than AGs we block rather 1005 * ensure that when we get more reclaimers than AGs we block rather
1002 * than spin trying to execute reclaim. 1006 * than spin trying to execute reclaim.
1003 */ 1007 */
1004 if (trylock && skipped && *nr_to_scan > 0) { 1008 if (skipped && (flags & SYNC_WAIT) && *nr_to_scan > 0) {
1005 trylock = 0; 1009 trylock = 0;
1006 goto restart; 1010 goto restart;
1007 } 1011 }
@@ -1019,44 +1023,38 @@ xfs_reclaim_inodes(
1019} 1023}
1020 1024
1021/* 1025/*
1022 * Inode cache shrinker. 1026 * Scan a certain number of inodes for reclaim.
1023 * 1027 *
1024 * When called we make sure that there is a background (fast) inode reclaim in 1028 * When called we make sure that there is a background (fast) inode reclaim in
1025 * progress, while we will throttle the speed of reclaim via doiing synchronous 1029 * progress, while we will throttle the speed of reclaim via doing synchronous
1026 * reclaim of inodes. That means if we come across dirty inodes, we wait for 1030 * reclaim of inodes. That means if we come across dirty inodes, we wait for
1027 * them to be cleaned, which we hope will not be very long due to the 1031 * them to be cleaned, which we hope will not be very long due to the
1028 * background walker having already kicked the IO off on those dirty inodes. 1032 * background walker having already kicked the IO off on those dirty inodes.
1029 */ 1033 */
1030static int 1034void
1031xfs_reclaim_inode_shrink( 1035xfs_reclaim_inodes_nr(
1032 struct shrinker *shrink, 1036 struct xfs_mount *mp,
1033 struct shrink_control *sc) 1037 int nr_to_scan)
1034{ 1038{
1035 struct xfs_mount *mp; 1039 /* kick background reclaimer and push the AIL */
1036 struct xfs_perag *pag; 1040 xfs_syncd_queue_reclaim(mp);
1037 xfs_agnumber_t ag; 1041 xfs_ail_push_all(mp->m_ail);
1038 int reclaimable;
1039 int nr_to_scan = sc->nr_to_scan;
1040 gfp_t gfp_mask = sc->gfp_mask;
1041
1042 mp = container_of(shrink, struct xfs_mount, m_inode_shrink);
1043 if (nr_to_scan) {
1044 /* kick background reclaimer and push the AIL */
1045 xfs_syncd_queue_reclaim(mp);
1046 xfs_ail_push_all(mp->m_ail);
1047 1042
1048 if (!(gfp_mask & __GFP_FS)) 1043 xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, &nr_to_scan);
1049 return -1; 1044}
1050 1045
1051 xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, 1046/*
1052 &nr_to_scan); 1047 * Return the number of reclaimable inodes in the filesystem for
1053 /* terminate if we don't exhaust the scan */ 1048 * the shrinker to determine how much to reclaim.
1054 if (nr_to_scan > 0) 1049 */
1055 return -1; 1050int
1056 } 1051xfs_reclaim_inodes_count(
1052 struct xfs_mount *mp)
1053{
1054 struct xfs_perag *pag;
1055 xfs_agnumber_t ag = 0;
1056 int reclaimable = 0;
1057 1057
1058 reclaimable = 0;
1059 ag = 0;
1060 while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) { 1058 while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) {
1061 ag = pag->pag_agno + 1; 1059 ag = pag->pag_agno + 1;
1062 reclaimable += pag->pag_ici_reclaimable; 1060 reclaimable += pag->pag_ici_reclaimable;
@@ -1065,18 +1063,3 @@ xfs_reclaim_inode_shrink(
1065 return reclaimable; 1063 return reclaimable;
1066} 1064}
1067 1065
1068void
1069xfs_inode_shrinker_register(
1070 struct xfs_mount *mp)
1071{
1072 mp->m_inode_shrink.shrink = xfs_reclaim_inode_shrink;
1073 mp->m_inode_shrink.seeks = DEFAULT_SEEKS;
1074 register_shrinker(&mp->m_inode_shrink);
1075}
1076
1077void
1078xfs_inode_shrinker_unregister(
1079 struct xfs_mount *mp)
1080{
1081 unregister_shrinker(&mp->m_inode_shrink);
1082}