quota: Make quota stat accounting lockless.
[safe/jmp/linux-2.6] / include / linux / quota.h
index b462916..cdfde10 100644 (file)
@@ -174,6 +174,8 @@ enum {
 #include <linux/rwsem.h>
 #include <linux/spinlock.h>
 #include <linux/wait.h>
+#include <linux/percpu.h>
+#include <linux/smp.h>
 
 #include <linux/dqblk_xfs.h>
 #include <linux/dqblk_v1.h>
@@ -238,19 +240,43 @@ static inline int info_dirty(struct mem_dqinfo *info)
        return test_bit(DQF_INFO_DIRTY_B, &info->dqi_flags);
 }
 
+enum {
+       DQST_LOOKUPS,
+       DQST_DROPS,
+       DQST_READS,
+       DQST_WRITES,
+       DQST_CACHE_HITS,
+       DQST_ALLOC_DQUOTS,
+       DQST_FREE_DQUOTS,
+       DQST_SYNCS,
+       _DQST_DQSTAT_LAST
+};
+
 struct dqstats {
-       int lookups;
-       int drops;
-       int reads;
-       int writes;
-       int cache_hits;
-       int allocated_dquots;
-       int free_dquots;
-       int syncs;
+       int stat[_DQST_DQSTAT_LAST];
 };
 
+extern struct dqstats *dqstats_pcpu;
 extern struct dqstats dqstats;
 
+static inline void dqstats_inc(unsigned int type)
+{
+#ifdef CONFIG_SMP
+       per_cpu_ptr(dqstats_pcpu, smp_processor_id())->stat[type]++;
+#else
+       dqstats.stat[type]++;
+#endif
+}
+
+static inline void dqstats_dec(unsigned int type)
+{
+#ifdef CONFIG_SMP
+       per_cpu_ptr(dqstats_pcpu, smp_processor_id())->stat[type]--;
+#else
+       dqstats.stat[type]--;
+#endif
+}
+
 #define DQ_MOD_B       0       /* dquot modified since read */
 #define DQ_BLKS_B      1       /* uid/gid has been warned about blk limit */
 #define DQ_INODES_B    2       /* uid/gid has been warned about inode limit */