aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDmitry Monakhov <dmonakhov@openvz.org>2010-04-26 12:03:33 -0400
committerJan Kara <jack@suse.cz>2010-05-21 13:30:41 -0400
commitdde9588853b1bde542eab247f8838c472806688f (patch)
tree9f9c68bf63120056517bbfce78b75e6820cc4c4b /include
parentda8d1ba22fa1fd0c0e541a43d75ebb062589b14b (diff)
quota: Make quota stat accounting lockless.
Quota stats is mostly writable data structure. Let's alloc percpu bucket for each value. NOTE: dqstats_read() function is racy against dqstats_{inc,dec} and may return inconsistent value. But this is ok since absolute accuracy is not required. Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'include')
-rw-r--r--include/linux/quota.h42
1 files changed, 34 insertions, 8 deletions
diff --git a/include/linux/quota.h b/include/linux/quota.h
index b462916b2a0a..cdfde10481b7 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -174,6 +174,8 @@ enum {
174#include <linux/rwsem.h> 174#include <linux/rwsem.h>
175#include <linux/spinlock.h> 175#include <linux/spinlock.h>
176#include <linux/wait.h> 176#include <linux/wait.h>
177#include <linux/percpu.h>
178#include <linux/smp.h>
177 179
178#include <linux/dqblk_xfs.h> 180#include <linux/dqblk_xfs.h>
179#include <linux/dqblk_v1.h> 181#include <linux/dqblk_v1.h>
@@ -238,19 +240,43 @@ static inline int info_dirty(struct mem_dqinfo *info)
238 return test_bit(DQF_INFO_DIRTY_B, &info->dqi_flags); 240 return test_bit(DQF_INFO_DIRTY_B, &info->dqi_flags);
239} 241}
240 242
243enum {
244 DQST_LOOKUPS,
245 DQST_DROPS,
246 DQST_READS,
247 DQST_WRITES,
248 DQST_CACHE_HITS,
249 DQST_ALLOC_DQUOTS,
250 DQST_FREE_DQUOTS,
251 DQST_SYNCS,
252 _DQST_DQSTAT_LAST
253};
254
241struct dqstats { 255struct dqstats {
242 int lookups; 256 int stat[_DQST_DQSTAT_LAST];
243 int drops;
244 int reads;
245 int writes;
246 int cache_hits;
247 int allocated_dquots;
248 int free_dquots;
249 int syncs;
250}; 257};
251 258
259extern struct dqstats *dqstats_pcpu;
252extern struct dqstats dqstats; 260extern struct dqstats dqstats;
253 261
262static inline void dqstats_inc(unsigned int type)
263{
264#ifdef CONFIG_SMP
265 per_cpu_ptr(dqstats_pcpu, smp_processor_id())->stat[type]++;
266#else
267 dqstats.stat[type]++;
268#endif
269}
270
271static inline void dqstats_dec(unsigned int type)
272{
273#ifdef CONFIG_SMP
274 per_cpu_ptr(dqstats_pcpu, smp_processor_id())->stat[type]--;
275#else
276 dqstats.stat[type]--;
277#endif
278}
279
254#define DQ_MOD_B 0 /* dquot modified since read */ 280#define DQ_MOD_B 0 /* dquot modified since read */
255#define DQ_BLKS_B 1 /* uid/gid has been warned about blk limit */ 281#define DQ_BLKS_B 1 /* uid/gid has been warned about blk limit */
256#define DQ_INODES_B 2 /* uid/gid has been warned about inode limit */ 282#define DQ_INODES_B 2 /* uid/gid has been warned about inode limit */