aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/inode.c b/fs/inode.c
index efc43979709f..5a0a898f55d1 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -102,13 +102,17 @@ static DECLARE_RWSEM(iprune_sem);
102 */ 102 */
103struct inodes_stat_t inodes_stat; 103struct inodes_stat_t inodes_stat;
104 104
105static struct percpu_counter nr_inodes __cacheline_aligned_in_smp; 105static DEFINE_PER_CPU(unsigned int, nr_inodes);
106 106
107static struct kmem_cache *inode_cachep __read_mostly; 107static struct kmem_cache *inode_cachep __read_mostly;
108 108
109static inline int get_nr_inodes(void) 109static int get_nr_inodes(void)
110{ 110{
111 return percpu_counter_sum_positive(&nr_inodes); 111 int i;
112 int sum = 0;
113 for_each_possible_cpu(i)
114 sum += per_cpu(nr_inodes, i);
115 return sum < 0 ? 0 : sum;
112} 116}
113 117
114static inline int get_nr_inodes_unused(void) 118static inline int get_nr_inodes_unused(void)
@@ -118,9 +122,9 @@ static inline int get_nr_inodes_unused(void)
118 122
119int get_nr_dirty_inodes(void) 123int get_nr_dirty_inodes(void)
120{ 124{
125 /* not actually dirty inodes, but a wild approximation */
121 int nr_dirty = get_nr_inodes() - get_nr_inodes_unused(); 126 int nr_dirty = get_nr_inodes() - get_nr_inodes_unused();
122 return nr_dirty > 0 ? nr_dirty : 0; 127 return nr_dirty > 0 ? nr_dirty : 0;
123
124} 128}
125 129
126/* 130/*
@@ -222,7 +226,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
222 inode->i_fsnotify_mask = 0; 226 inode->i_fsnotify_mask = 0;
223#endif 227#endif
224 228
225 percpu_counter_inc(&nr_inodes); 229 this_cpu_inc(nr_inodes);
226 230
227 return 0; 231 return 0;
228out: 232out:
@@ -264,7 +268,7 @@ void __destroy_inode(struct inode *inode)
264 if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED) 268 if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED)
265 posix_acl_release(inode->i_default_acl); 269 posix_acl_release(inode->i_default_acl);
266#endif 270#endif
267 percpu_counter_dec(&nr_inodes); 271 this_cpu_dec(nr_inodes);
268} 272}
269EXPORT_SYMBOL(__destroy_inode); 273EXPORT_SYMBOL(__destroy_inode);
270 274
@@ -1646,7 +1650,6 @@ void __init inode_init(void)
1646 SLAB_MEM_SPREAD), 1650 SLAB_MEM_SPREAD),
1647 init_once); 1651 init_once);
1648 register_shrinker(&icache_shrinker); 1652 register_shrinker(&icache_shrinker);
1649 percpu_counter_init(&nr_inodes, 0);
1650 1653
1651 /* Hash may have been set up in inode_init_early */ 1654 /* Hash may have been set up in inode_init_early */
1652 if (!hashdist) 1655 if (!hashdist)