aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-08-27 20:18:09 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-09-10 18:56:31 -0400
commit1ab6c4997e04a00c50c6d786c2f046adc0d1f5de (patch)
tree55561fc74c062a8ed0e03fe56f54d7db9cfd9e12 /fs/quota
parent35163417fb7a55a24b6b0ebb102e9991adf309aa (diff)
fs: convert fs shrinkers to new scan/count API
Convert the filesystem shrinkers to use the new API, and standardise some of the behaviours of the shrinkers at the same time. For example, nr_to_scan means the number of objects to scan, not the number of objects to free. I refactored the CIFS idmap shrinker a little - it really needs to be broken up into a shrinker per tree and keep an item count with the tree root so that we don't need to walk the tree every time the shrinker needs to count the number of objects in the tree (i.e. all the time under memory pressure). [glommer@openvz.org: fixes for ext4, ubifs, nfs, cifs and glock. Fixes are needed mainly due to new code merged in the tree] [assorted fixes folded in] Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Glauber Costa <glommer@openvz.org> Acked-by: Mel Gorman <mgorman@suse.de> Acked-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Acked-by: Jan Kara <jack@suse.cz> Acked-by: Steven Whitehouse <swhiteho@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: Arve Hjønnevåg <arve@android.com> Cc: Carlos Maiolino <cmaiolino@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Chuck Lever <chuck.lever@oracle.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: David Rientjes <rientjes@google.com> Cc: Gleb Natapov <gleb@redhat.com> Cc: Greg Thelen <gthelen@google.com> Cc: J. Bruce Fields <bfields@redhat.com> Cc: Jan Kara <jack@suse.cz> Cc: Jerome Glisse <jglisse@redhat.com> Cc: John Stultz <john.stultz@linaro.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Kent Overstreet <koverstreet@google.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Steven Whitehouse <swhiteho@redhat.com> Cc: Thomas Hellstrom <thellstrom@vmware.com> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/quota')
-rw-r--r--fs/quota/dquot.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 13eee847605c..831d49a4111f 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -687,44 +687,37 @@ int dquot_quota_sync(struct super_block *sb, int type)
687} 687}
688EXPORT_SYMBOL(dquot_quota_sync); 688EXPORT_SYMBOL(dquot_quota_sync);
689 689
690/* Free unused dquots from cache */ 690static unsigned long
691static void prune_dqcache(int count) 691dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
692{ 692{
693 struct list_head *head; 693 struct list_head *head;
694 struct dquot *dquot; 694 struct dquot *dquot;
695 unsigned long freed = 0;
695 696
696 head = free_dquots.prev; 697 head = free_dquots.prev;
697 while (head != &free_dquots && count) { 698 while (head != &free_dquots && sc->nr_to_scan) {
698 dquot = list_entry(head, struct dquot, dq_free); 699 dquot = list_entry(head, struct dquot, dq_free);
699 remove_dquot_hash(dquot); 700 remove_dquot_hash(dquot);
700 remove_free_dquot(dquot); 701 remove_free_dquot(dquot);
701 remove_inuse(dquot); 702 remove_inuse(dquot);
702 do_destroy_dquot(dquot); 703 do_destroy_dquot(dquot);
703 count--; 704 sc->nr_to_scan--;
705 freed++;
704 head = free_dquots.prev; 706 head = free_dquots.prev;
705 } 707 }
708 return freed;
706} 709}
707 710
708/* 711static unsigned long
709 * This is called from kswapd when we think we need some 712dqcache_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
710 * more memory
711 */
712static int shrink_dqcache_memory(struct shrinker *shrink,
713 struct shrink_control *sc)
714{ 713{
715 int nr = sc->nr_to_scan;
716
717 if (nr) {
718 spin_lock(&dq_list_lock);
719 prune_dqcache(nr);
720 spin_unlock(&dq_list_lock);
721 }
722 return vfs_pressure_ratio( 714 return vfs_pressure_ratio(
723 percpu_counter_read_positive(&dqstats.counter[DQST_FREE_DQUOTS])); 715 percpu_counter_read_positive(&dqstats.counter[DQST_FREE_DQUOTS]));
724} 716}
725 717
726static struct shrinker dqcache_shrinker = { 718static struct shrinker dqcache_shrinker = {
727 .shrink = shrink_dqcache_memory, 719 .count_objects = dqcache_shrink_count,
720 .scan_objects = dqcache_shrink_scan,
728 .seeks = DEFAULT_SEEKS, 721 .seeks = DEFAULT_SEEKS,
729}; 722};
730 723