diff options
Diffstat (limited to 'fs/drop_caches.c')
-rw-r--r-- | fs/drop_caches.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 2195c213ab2f..98b77c89494c 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c | |||
@@ -8,6 +8,7 @@ | |||
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" | ||
11 | 12 | ||
12 | /* A global variable is a bit ugly, but it keeps the code simple */ | 13 | /* A global variable is a bit ugly, but it keeps the code simple */ |
13 | int sysctl_drop_caches; | 14 | int sysctl_drop_caches; |
@@ -16,20 +17,23 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) | |||
16 | { | 17 | { |
17 | struct inode *inode, *toput_inode = NULL; | 18 | struct inode *inode, *toput_inode = NULL; |
18 | 19 | ||
19 | spin_lock(&inode_lock); | 20 | spin_lock(&inode_sb_list_lock); |
20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 21 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
21 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) | 22 | spin_lock(&inode->i_lock); |
22 | continue; | 23 | if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || |
23 | if (inode->i_mapping->nrpages == 0) | 24 | (inode->i_mapping->nrpages == 0)) { |
25 | spin_unlock(&inode->i_lock); | ||
24 | continue; | 26 | continue; |
27 | } | ||
25 | __iget(inode); | 28 | __iget(inode); |
26 | spin_unlock(&inode_lock); | 29 | spin_unlock(&inode->i_lock); |
30 | spin_unlock(&inode_sb_list_lock); | ||
27 | invalidate_mapping_pages(inode->i_mapping, 0, -1); | 31 | invalidate_mapping_pages(inode->i_mapping, 0, -1); |
28 | iput(toput_inode); | 32 | iput(toput_inode); |
29 | toput_inode = inode; | 33 | toput_inode = inode; |
30 | spin_lock(&inode_lock); | 34 | spin_lock(&inode_sb_list_lock); |
31 | } | 35 | } |
32 | spin_unlock(&inode_lock); | 36 | spin_unlock(&inode_sb_list_lock); |
33 | iput(toput_inode); | 37 | iput(toput_inode); |
34 | } | 38 | } |
35 | 39 | ||
@@ -45,7 +49,11 @@ static void drop_slab(void) | |||
45 | int drop_caches_sysctl_handler(ctl_table *table, int write, | 49 | int drop_caches_sysctl_handler(ctl_table *table, int write, |
46 | void __user *buffer, size_t *length, loff_t *ppos) | 50 | void __user *buffer, size_t *length, loff_t *ppos) |
47 | { | 51 | { |
48 | proc_dointvec_minmax(table, write, buffer, length, ppos); | 52 | int ret; |
53 | |||
54 | ret = proc_dointvec_minmax(table, write, buffer, length, ppos); | ||
55 | if (ret) | ||
56 | return ret; | ||
49 | if (write) { | 57 | if (write) { |
50 | if (sysctl_drop_caches & 1) | 58 | if (sysctl_drop_caches & 1) |
51 | iterate_supers(drop_pagecache_sb, NULL); | 59 | iterate_supers(drop_pagecache_sb, NULL); |