diff options
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/glock.c | 30 | ||||
-rw-r--r-- | fs/gfs2/main.c | 3 | ||||
-rw-r--r-- | fs/gfs2/quota.c | 18 | ||||
-rw-r--r-- | fs/gfs2/quota.h | 6 |
4 files changed, 35 insertions, 22 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 722329cac98f..c2f41b4d00b9 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -1427,21 +1427,22 @@ __acquires(&lru_lock) | |||
1427 | * gfs2_dispose_glock_lru() above. | 1427 | * gfs2_dispose_glock_lru() above. |
1428 | */ | 1428 | */ |
1429 | 1429 | ||
1430 | static void gfs2_scan_glock_lru(int nr) | 1430 | static long gfs2_scan_glock_lru(int nr) |
1431 | { | 1431 | { |
1432 | struct gfs2_glock *gl; | 1432 | struct gfs2_glock *gl; |
1433 | LIST_HEAD(skipped); | 1433 | LIST_HEAD(skipped); |
1434 | LIST_HEAD(dispose); | 1434 | LIST_HEAD(dispose); |
1435 | long freed = 0; | ||
1435 | 1436 | ||
1436 | spin_lock(&lru_lock); | 1437 | spin_lock(&lru_lock); |
1437 | while(nr && !list_empty(&lru_list)) { | 1438 | while ((nr-- >= 0) && !list_empty(&lru_list)) { |
1438 | gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru); | 1439 | gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru); |
1439 | 1440 | ||
1440 | /* Test for being demotable */ | 1441 | /* Test for being demotable */ |
1441 | if (!test_and_set_bit(GLF_LOCK, &gl->gl_flags)) { | 1442 | if (!test_and_set_bit(GLF_LOCK, &gl->gl_flags)) { |
1442 | list_move(&gl->gl_lru, &dispose); | 1443 | list_move(&gl->gl_lru, &dispose); |
1443 | atomic_dec(&lru_count); | 1444 | atomic_dec(&lru_count); |
1444 | nr--; | 1445 | freed++; |
1445 | continue; | 1446 | continue; |
1446 | } | 1447 | } |
1447 | 1448 | ||
@@ -1451,23 +1452,28 @@ static void gfs2_scan_glock_lru(int nr) | |||
1451 | if (!list_empty(&dispose)) | 1452 | if (!list_empty(&dispose)) |
1452 | gfs2_dispose_glock_lru(&dispose); | 1453 | gfs2_dispose_glock_lru(&dispose); |
1453 | spin_unlock(&lru_lock); | 1454 | spin_unlock(&lru_lock); |
1455 | |||
1456 | return freed; | ||
1454 | } | 1457 | } |
1455 | 1458 | ||
1456 | static int gfs2_shrink_glock_memory(struct shrinker *shrink, | 1459 | static unsigned long gfs2_glock_shrink_scan(struct shrinker *shrink, |
1457 | struct shrink_control *sc) | 1460 | struct shrink_control *sc) |
1458 | { | 1461 | { |
1459 | if (sc->nr_to_scan) { | 1462 | if (!(sc->gfp_mask & __GFP_FS)) |
1460 | if (!(sc->gfp_mask & __GFP_FS)) | 1463 | return SHRINK_STOP; |
1461 | return -1; | 1464 | return gfs2_scan_glock_lru(sc->nr_to_scan); |
1462 | gfs2_scan_glock_lru(sc->nr_to_scan); | 1465 | } |
1463 | } | ||
1464 | 1466 | ||
1465 | return (atomic_read(&lru_count) / 100) * sysctl_vfs_cache_pressure; | 1467 | static unsigned long gfs2_glock_shrink_count(struct shrinker *shrink, |
1468 | struct shrink_control *sc) | ||
1469 | { | ||
1470 | return vfs_pressure_ratio(atomic_read(&lru_count)); | ||
1466 | } | 1471 | } |
1467 | 1472 | ||
1468 | static struct shrinker glock_shrinker = { | 1473 | static struct shrinker glock_shrinker = { |
1469 | .shrink = gfs2_shrink_glock_memory, | ||
1470 | .seeks = DEFAULT_SEEKS, | 1474 | .seeks = DEFAULT_SEEKS, |
1475 | .count_objects = gfs2_glock_shrink_count, | ||
1476 | .scan_objects = gfs2_glock_shrink_scan, | ||
1471 | }; | 1477 | }; |
1472 | 1478 | ||
1473 | /** | 1479 | /** |
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 7b0f5043cf24..351586e24e30 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c | |||
@@ -32,7 +32,8 @@ | |||
32 | struct workqueue_struct *gfs2_control_wq; | 32 | struct workqueue_struct *gfs2_control_wq; |
33 | 33 | ||
34 | static struct shrinker qd_shrinker = { | 34 | static struct shrinker qd_shrinker = { |
35 | .shrink = gfs2_shrink_qd_memory, | 35 | .count_objects = gfs2_qd_shrink_count, |
36 | .scan_objects = gfs2_qd_shrink_scan, | ||
36 | .seeks = DEFAULT_SEEKS, | 37 | .seeks = DEFAULT_SEEKS, |
37 | }; | 38 | }; |
38 | 39 | ||
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 3768c2f40e43..db441359ee8c 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -75,17 +75,16 @@ static LIST_HEAD(qd_lru_list); | |||
75 | static atomic_t qd_lru_count = ATOMIC_INIT(0); | 75 | static atomic_t qd_lru_count = ATOMIC_INIT(0); |
76 | static DEFINE_SPINLOCK(qd_lru_lock); | 76 | static DEFINE_SPINLOCK(qd_lru_lock); |
77 | 77 | ||
78 | int gfs2_shrink_qd_memory(struct shrinker *shrink, struct shrink_control *sc) | 78 | unsigned long gfs2_qd_shrink_scan(struct shrinker *shrink, |
79 | struct shrink_control *sc) | ||
79 | { | 80 | { |
80 | struct gfs2_quota_data *qd; | 81 | struct gfs2_quota_data *qd; |
81 | struct gfs2_sbd *sdp; | 82 | struct gfs2_sbd *sdp; |
82 | int nr_to_scan = sc->nr_to_scan; | 83 | int nr_to_scan = sc->nr_to_scan; |
83 | 84 | long freed = 0; | |
84 | if (nr_to_scan == 0) | ||
85 | goto out; | ||
86 | 85 | ||
87 | if (!(sc->gfp_mask & __GFP_FS)) | 86 | if (!(sc->gfp_mask & __GFP_FS)) |
88 | return -1; | 87 | return SHRINK_STOP; |
89 | 88 | ||
90 | spin_lock(&qd_lru_lock); | 89 | spin_lock(&qd_lru_lock); |
91 | while (nr_to_scan && !list_empty(&qd_lru_list)) { | 90 | while (nr_to_scan && !list_empty(&qd_lru_list)) { |
@@ -110,11 +109,16 @@ int gfs2_shrink_qd_memory(struct shrinker *shrink, struct shrink_control *sc) | |||
110 | kmem_cache_free(gfs2_quotad_cachep, qd); | 109 | kmem_cache_free(gfs2_quotad_cachep, qd); |
111 | spin_lock(&qd_lru_lock); | 110 | spin_lock(&qd_lru_lock); |
112 | nr_to_scan--; | 111 | nr_to_scan--; |
112 | freed++; | ||
113 | } | 113 | } |
114 | spin_unlock(&qd_lru_lock); | 114 | spin_unlock(&qd_lru_lock); |
115 | return freed; | ||
116 | } | ||
115 | 117 | ||
116 | out: | 118 | unsigned long gfs2_qd_shrink_count(struct shrinker *shrink, |
117 | return (atomic_read(&qd_lru_count) * sysctl_vfs_cache_pressure) / 100; | 119 | struct shrink_control *sc) |
120 | { | ||
121 | return vfs_pressure_ratio(atomic_read(&qd_lru_count)); | ||
118 | } | 122 | } |
119 | 123 | ||
120 | static u64 qd2index(struct gfs2_quota_data *qd) | 124 | static u64 qd2index(struct gfs2_quota_data *qd) |
diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h index 4f5e6e44ed83..0f64d9deb1b0 100644 --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h | |||
@@ -53,8 +53,10 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip) | |||
53 | return ret; | 53 | return ret; |
54 | } | 54 | } |
55 | 55 | ||
56 | extern int gfs2_shrink_qd_memory(struct shrinker *shrink, | 56 | extern unsigned long gfs2_qd_shrink_count(struct shrinker *shrink, |
57 | struct shrink_control *sc); | 57 | struct shrink_control *sc); |
58 | extern unsigned long gfs2_qd_shrink_scan(struct shrinker *shrink, | ||
59 | struct shrink_control *sc); | ||
58 | extern const struct quotactl_ops gfs2_quotactl_ops; | 60 | extern const struct quotactl_ops gfs2_quotactl_ops; |
59 | 61 | ||
60 | #endif /* __QUOTA_DOT_H__ */ | 62 | #endif /* __QUOTA_DOT_H__ */ |