diff options
Diffstat (limited to 'fs/inode.c')
-rw-r--r-- | fs/inode.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/inode.c b/fs/inode.c index 76494983644d..ea96254bd490 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -106,7 +106,10 @@ static DECLARE_RWSEM(iprune_sem); /* * Statistics gathering.. */ -struct inodes_stat_t inodes_stat; +struct inodes_stat_t inodes_stat = { + .nr_inodes = ATOMIC_INIT(0), + .nr_unused = ATOMIC_INIT(0), +}; static struct kmem_cache *inode_cachep __read_mostly; @@ -300,7 +303,7 @@ void __iget(struct inode *inode) list_move(&inode->i_list, &inode_in_use); spin_unlock(&wb_inode_list_lock); } - inodes_stat.nr_unused--; + atomic_dec(&inodes_stat.nr_unused); } /** @@ -365,9 +368,7 @@ static void dispose_list(struct list_head *head) destroy_inode(inode); nr_disposed++; } - spin_lock(&inode_lock); - inodes_stat.nr_inodes -= nr_disposed; - spin_unlock(&inode_lock); + atomic_sub(nr_disposed, &inodes_stat.nr_inodes); } /* @@ -416,7 +417,7 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose) busy = 1; } /* only unused inodes may be cached with i_count zero */ - inodes_stat.nr_unused -= count; + atomic_sub(count, &inodes_stat.nr_unused); return busy; } @@ -534,7 +535,7 @@ again2: spin_unlock(&inode->i_lock); nr_pruned++; } - inodes_stat.nr_unused -= nr_pruned; + atomic_sub(nr_pruned, &inodes_stat.nr_unused); if (current_is_kswapd()) __count_vm_events(KSWAPD_INODESTEAL, reap); else @@ -567,7 +568,8 @@ static int shrink_icache_memory(int nr, gfp_t gfp_mask) return -1; prune_icache(nr); } - return (inodes_stat.nr_unused / 100) * sysctl_vfs_cache_pressure; + return (atomic_read(&inodes_stat.nr_unused) / 100) * + sysctl_vfs_cache_pressure; } static struct shrinker icache_shrinker = { @@ -660,7 +662,7 @@ static inline void __inode_add_to_lists(struct super_block *sb, struct hlist_head *head, struct inode *inode) { - inodes_stat.nr_inodes++; + atomic_inc(&inodes_stat.nr_inodes); spin_lock(&sb_inode_list_lock); list_add(&inode->i_sb_list, &sb->s_inodes); spin_unlock(&sb_inode_list_lock); @@ -1304,8 +1306,8 @@ void generic_delete_inode(struct inode *inode) WARN_ON(inode->i_state & I_NEW); inode->i_state |= I_FREEING; spin_unlock(&inode->i_lock); - inodes_stat.nr_inodes--; spin_unlock(&inode_lock); + atomic_dec(&inodes_stat.nr_inodes); security_inode_delete(inode); @@ -1352,7 +1354,7 @@ int generic_detach_inode(struct inode *inode) list_move(&inode->i_list, &inode_unused); spin_unlock(&wb_inode_list_lock); } - inodes_stat.nr_unused++; + atomic_inc(&inodes_stat.nr_unused); if (sb->s_flags & MS_ACTIVE) { spin_unlock(&inode->i_lock); spin_unlock(&sb_inode_list_lock); @@ -1370,7 +1372,7 @@ int generic_detach_inode(struct inode *inode) spin_lock(&inode->i_lock); WARN_ON(inode->i_state & I_NEW); inode->i_state &= ~I_WILL_FREE; - inodes_stat.nr_unused--; + atomic_dec(&inodes_stat.nr_unused); spin_lock(&inode_hash_lock); hlist_del_init(&inode->i_hash); spin_unlock(&inode_hash_lock); @@ -1382,9 +1384,9 @@ int generic_detach_inode(struct inode *inode) spin_unlock(&sb_inode_list_lock); WARN_ON(inode->i_state & I_NEW); inode->i_state |= I_FREEING; - inodes_stat.nr_inodes--; spin_unlock(&inode->i_lock); spin_unlock(&inode_lock); + atomic_dec(&inodes_stat.nr_inodes); return 1; } EXPORT_SYMBOL_GPL(generic_detach_inode); |