diff options
Diffstat (limited to 'fs/drop_caches.c')
-rw-r--r-- | fs/drop_caches.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 59375efcf39d..3e5637fc3779 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c | |||
@@ -14,18 +14,26 @@ int sysctl_drop_caches; | |||
14 | 14 | ||
15 | static void drop_pagecache_sb(struct super_block *sb) | 15 | static void drop_pagecache_sb(struct super_block *sb) |
16 | { | 16 | { |
17 | struct inode *inode; | 17 | struct inode *inode, *toput_inode = NULL; |
18 | 18 | ||
19 | spin_lock(&inode_lock); | 19 | spin_lock(&inode_lock); |
20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
21 | if (inode->i_state & (I_FREEING|I_WILL_FREE)) | 21 | if (inode->i_state & (I_FREEING|I_WILL_FREE)) |
22 | continue; | 22 | continue; |
23 | if (inode->i_mapping->nrpages == 0) | ||
24 | continue; | ||
25 | __iget(inode); | ||
26 | spin_unlock(&inode_lock); | ||
23 | __invalidate_mapping_pages(inode->i_mapping, 0, -1, true); | 27 | __invalidate_mapping_pages(inode->i_mapping, 0, -1, true); |
28 | iput(toput_inode); | ||
29 | toput_inode = inode; | ||
30 | spin_lock(&inode_lock); | ||
24 | } | 31 | } |
25 | spin_unlock(&inode_lock); | 32 | spin_unlock(&inode_lock); |
33 | iput(toput_inode); | ||
26 | } | 34 | } |
27 | 35 | ||
28 | void drop_pagecache(void) | 36 | static void drop_pagecache(void) |
29 | { | 37 | { |
30 | struct super_block *sb; | 38 | struct super_block *sb; |
31 | 39 | ||
@@ -45,7 +53,7 @@ restart: | |||
45 | spin_unlock(&sb_lock); | 53 | spin_unlock(&sb_lock); |
46 | } | 54 | } |
47 | 55 | ||
48 | void drop_slab(void) | 56 | static void drop_slab(void) |
49 | { | 57 | { |
50 | int nr_objects; | 58 | int nr_objects; |
51 | 59 | ||