aboutsummaryrefslogtreecommitdiffstats
path: root/fs/drop_caches.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2010-03-23 06:06:58 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-05-21 18:31:16 -0400
commit01a05b337a5b647909e1d6670f57e7202318a5fb (patch)
tree7877f08db14877d06346c8e1ef52aa17f2483e93 /fs/drop_caches.c
parent35cf7ba0b46dc3582a01c3860b14bff122662aa3 (diff)
new helper: iterate_supers()
... and switch the simple "loop over superblocks and do something" loops to it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/drop_caches.c')
-rw-r--r--fs/drop_caches.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index 52047cf4177f..83c4f600786a 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -8,12 +8,11 @@
8#include <linux/writeback.h> 8#include <linux/writeback.h>
9#include <linux/sysctl.h> 9#include <linux/sysctl.h>
10#include <linux/gfp.h> 10#include <linux/gfp.h>
11#include "internal.h"
12 11
13/* A global variable is a bit ugly, but it keeps the code simple */ 12/* A global variable is a bit ugly, but it keeps the code simple */
14int sysctl_drop_caches; 13int sysctl_drop_caches;
15 14
16static void drop_pagecache_sb(struct super_block *sb) 15static void drop_pagecache_sb(struct super_block *sb, void *unused)
17{ 16{
18 struct inode *inode, *toput_inode = NULL; 17 struct inode *inode, *toput_inode = NULL;
19 18
@@ -34,26 +33,6 @@ static void drop_pagecache_sb(struct super_block *sb)
34 iput(toput_inode); 33 iput(toput_inode);
35} 34}
36 35
37static void drop_pagecache(void)
38{
39 struct super_block *sb, *n;
40
41 spin_lock(&sb_lock);
42 list_for_each_entry_safe(sb, n, &super_blocks, s_list) {
43 if (list_empty(&sb->s_instances))
44 continue;
45 sb->s_count++;
46 spin_unlock(&sb_lock);
47 down_read(&sb->s_umount);
48 if (sb->s_root)
49 drop_pagecache_sb(sb);
50 up_read(&sb->s_umount);
51 spin_lock(&sb_lock);
52 __put_super(sb);
53 }
54 spin_unlock(&sb_lock);
55}
56
57static void drop_slab(void) 36static void drop_slab(void)
58{ 37{
59 int nr_objects; 38 int nr_objects;
@@ -69,7 +48,7 @@ int drop_caches_sysctl_handler(ctl_table *table, int write,
69 proc_dointvec_minmax(table, write, buffer, length, ppos); 48 proc_dointvec_minmax(table, write, buffer, length, ppos);
70 if (write) { 49 if (write) {
71 if (sysctl_drop_caches & 1) 50 if (sysctl_drop_caches & 1)
72 drop_pagecache(); 51 iterate_supers(drop_pagecache_sb, NULL);
73 if (sysctl_drop_caches & 2) 52 if (sysctl_drop_caches & 2)
74 drop_slab(); 53 drop_slab();
75 } 54 }