aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/shrinker.c29
-rw-r--r--fs/ubifs/super.c3
-rw-r--r--fs/ubifs/ubifs.h5
3 files changed, 24 insertions, 13 deletions
diff --git a/fs/ubifs/shrinker.c b/fs/ubifs/shrinker.c
index 9e1d05666fed..f35135e28e96 100644
--- a/fs/ubifs/shrinker.c
+++ b/fs/ubifs/shrinker.c
@@ -277,18 +277,25 @@ static int kick_a_thread(void)
277 return 0; 277 return 0;
278} 278}
279 279
280int ubifs_shrinker(struct shrinker *shrink, struct shrink_control *sc) 280unsigned long ubifs_shrink_count(struct shrinker *shrink,
281 struct shrink_control *sc)
281{ 282{
282 int nr = sc->nr_to_scan;
283 int freed, contention = 0;
284 long clean_zn_cnt = atomic_long_read(&ubifs_clean_zn_cnt); 283 long clean_zn_cnt = atomic_long_read(&ubifs_clean_zn_cnt);
285 284
286 if (nr == 0) 285 /*
287 /* 286 * Due to the way UBIFS updates the clean znode counter it may
288 * Due to the way UBIFS updates the clean znode counter it may 287 * temporarily be negative.
289 * temporarily be negative. 288 */
290 */ 289 return clean_zn_cnt >= 0 ? clean_zn_cnt : 1;
291 return clean_zn_cnt >= 0 ? clean_zn_cnt : 1; 290}
291
292unsigned long ubifs_shrink_scan(struct shrinker *shrink,
293 struct shrink_control *sc)
294{
295 unsigned long nr = sc->nr_to_scan;
296 int contention = 0;
297 unsigned long freed;
298 long clean_zn_cnt = atomic_long_read(&ubifs_clean_zn_cnt);
292 299
293 if (!clean_zn_cnt) { 300 if (!clean_zn_cnt) {
294 /* 301 /*
@@ -316,10 +323,10 @@ int ubifs_shrinker(struct shrinker *shrink, struct shrink_control *sc)
316 323
317 if (!freed && contention) { 324 if (!freed && contention) {
318 dbg_tnc("freed nothing, but contention"); 325 dbg_tnc("freed nothing, but contention");
319 return -1; 326 return SHRINK_STOP;
320 } 327 }
321 328
322out: 329out:
323 dbg_tnc("%d znodes were freed, requested %d", freed, nr); 330 dbg_tnc("%lu znodes were freed, requested %lu", freed, nr);
324 return freed; 331 return freed;
325} 332}
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 01e1ad08d08e..f69daa514a57 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -49,7 +49,8 @@ struct kmem_cache *ubifs_inode_slab;
49 49
50/* UBIFS TNC shrinker description */ 50/* UBIFS TNC shrinker description */
51static struct shrinker ubifs_shrinker_info = { 51static struct shrinker ubifs_shrinker_info = {
52 .shrink = ubifs_shrinker, 52 .scan_objects = ubifs_shrink_scan,
53 .count_objects = ubifs_shrink_count,
53 .seeks = DEFAULT_SEEKS, 54 .seeks = DEFAULT_SEEKS,
54}; 55};
55 56
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index b2babce4d70f..e8c8cfe1435c 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1624,7 +1624,10 @@ int ubifs_tnc_start_commit(struct ubifs_info *c, struct ubifs_zbranch *zroot);
1624int ubifs_tnc_end_commit(struct ubifs_info *c); 1624int ubifs_tnc_end_commit(struct ubifs_info *c);
1625 1625
1626/* shrinker.c */ 1626/* shrinker.c */
1627int ubifs_shrinker(struct shrinker *shrink, struct shrink_control *sc); 1627unsigned long ubifs_shrink_scan(struct shrinker *shrink,
1628 struct shrink_control *sc);
1629unsigned long ubifs_shrink_count(struct shrinker *shrink,
1630 struct shrink_control *sc);
1628 1631
1629/* commit.c */ 1632/* commit.c */
1630int ubifs_bg_thread(void *info); 1633int ubifs_bg_thread(void *info);