aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2012-12-14 07:28:30 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2013-01-29 05:27:28 -0500
commit2a005855938235771b6960206d7581a4933cf6b7 (patch)
tree5868618caf3e160222e28d0aedc6ef5a45917468 /fs/gfs2
parent6abb7c25775b7fb2225ad0508236d63ca710e65f (diff)
GFS2: Separate LRU scanning from shrinker
This breaks out the LRU scanning function from the shrinker in preparation for adding other callers to the LRU scanner. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/glock.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 992c5c0cb504..3ad8fd36f8da 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1376,23 +1376,19 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
1376 gfs2_glock_put(gl); 1376 gfs2_glock_put(gl);
1377} 1377}
1378 1378
1379/**
1380 * gfs2_scan_glock_lru - Scan the LRU looking for locks to demote
1381 * @nr: The number of entries to scan
1382 *
1383 */
1379 1384
1380static int gfs2_shrink_glock_memory(struct shrinker *shrink, 1385static void gfs2_scan_glock_lru(int nr)
1381 struct shrink_control *sc)
1382{ 1386{
1383 struct gfs2_glock *gl; 1387 struct gfs2_glock *gl;
1384 int may_demote; 1388 int may_demote;
1385 int nr_skipped = 0; 1389 int nr_skipped = 0;
1386 int nr = sc->nr_to_scan;
1387 gfp_t gfp_mask = sc->gfp_mask;
1388 LIST_HEAD(skipped); 1390 LIST_HEAD(skipped);
1389 1391
1390 if (nr == 0)
1391 goto out;
1392
1393 if (!(gfp_mask & __GFP_FS))
1394 return -1;
1395
1396 spin_lock(&lru_lock); 1392 spin_lock(&lru_lock);
1397 while(nr && !list_empty(&lru_list)) { 1393 while(nr && !list_empty(&lru_list)) {
1398 gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru); 1394 gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru);
@@ -1425,7 +1421,17 @@ static int gfs2_shrink_glock_memory(struct shrinker *shrink,
1425 list_splice(&skipped, &lru_list); 1421 list_splice(&skipped, &lru_list);
1426 atomic_add(nr_skipped, &lru_count); 1422 atomic_add(nr_skipped, &lru_count);
1427 spin_unlock(&lru_lock); 1423 spin_unlock(&lru_lock);
1428out: 1424}
1425
1426static int gfs2_shrink_glock_memory(struct shrinker *shrink,
1427 struct shrink_control *sc)
1428{
1429 if (sc->nr_to_scan) {
1430 if (!(sc->gfp_mask & __GFP_FS))
1431 return -1;
1432 gfs2_scan_glock_lru(sc->nr_to_scan);
1433 }
1434
1429 return (atomic_read(&lru_count) / 100) * sysctl_vfs_cache_pressure; 1435 return (atomic_read(&lru_count) / 100) * sysctl_vfs_cache_pressure;
1430} 1436}
1431 1437