minix: replace inode uid,gid,mode init with helper
[safe/jmp/linux-2.6] / fs / quota / dquot.c
index 4c2213f..655a4c5 100644 (file)
 
 #include <asm/uaccess.h>
 
-#define __DQUOT_PARANOIA
-
 /*
  * There are three quota SMP locks. dq_list_lock protects all lists with quotas
- * and quota formats, dqstats structure containing statistics about the lists
+ * and quota formats.
  * dq_data_lock protects data from dq_dqb and also mem_dqinfo structures and
  * also guards consistency of dquot->dq_dqb with inode->i_blocks, i_bytes.
  * i_blocks and i_bytes updates itself are guarded by i_lock acquired directly
@@ -134,7 +132,9 @@ static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_state_lock);
 __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_data_lock);
 EXPORT_SYMBOL(dq_data_lock);
 
+#if defined(CONFIG_QUOTA_DEBUG) || defined(CONFIG_PRINT_QUOTA_WARNING)
 static char *quotatypes[] = INITQFNAMES;
+#endif
 static struct quota_format_type *quota_formats;        /* List of registered formats */
 static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES;
 
@@ -228,8 +228,13 @@ static struct hlist_head *dquot_hash;
 
 struct dqstats dqstats;
 EXPORT_SYMBOL(dqstats);
+#ifdef CONFIG_SMP
+struct dqstats *dqstats_pcpu;
+EXPORT_SYMBOL(dqstats_pcpu);
+#endif
 
 static qsize_t inode_get_rsv_space(struct inode *inode);
+static void __dquot_initialize(struct inode *inode, int type);
 
 static inline unsigned int
 hashfn(const struct super_block *sb, unsigned int id, int type)
@@ -274,7 +279,7 @@ static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb,
 static inline void put_dquot_last(struct dquot *dquot)
 {
        list_add_tail(&dquot->dq_free, &free_dquots);
-       dqstats.free_dquots++;
+       dqstats_inc(DQST_FREE_DQUOTS);
 }
 
 static inline void remove_free_dquot(struct dquot *dquot)
@@ -282,7 +287,7 @@ static inline void remove_free_dquot(struct dquot *dquot)
        if (list_empty(&dquot->dq_free))
                return;
        list_del_init(&dquot->dq_free);
-       dqstats.free_dquots--;
+       dqstats_dec(DQST_FREE_DQUOTS);
 }
 
 static inline void put_inuse(struct dquot *dquot)
@@ -290,12 +295,12 @@ static inline void put_inuse(struct dquot *dquot)
        /* We add to the back of inuse list so we don't have to restart
         * when traversing this list and we block */
        list_add_tail(&dquot->dq_inuse, &inuse_list);
-       dqstats.allocated_dquots++;
+       dqstats_inc(DQST_ALLOC_DQUOTS);
 }
 
 static inline void remove_inuse(struct dquot *dquot)
 {
-       dqstats.allocated_dquots--;
+       dqstats_dec(DQST_ALLOC_DQUOTS);
        list_del(&dquot->dq_inuse);
 }
 /*
@@ -318,14 +323,23 @@ static inline int mark_dquot_dirty(struct dquot *dquot)
        return dquot->dq_sb->dq_op->mark_dirty(dquot);
 }
 
+/* Mark dquot dirty in atomic manner, and return it's old dirty flag state */
 int dquot_mark_dquot_dirty(struct dquot *dquot)
 {
+       int ret = 1;
+
+       /* If quota is dirty already, we don't have to acquire dq_list_lock */
+       if (test_bit(DQ_MOD_B, &dquot->dq_flags))
+               return 1;
+
        spin_lock(&dq_list_lock);
-       if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags))
+       if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) {
                list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)->
                                info[dquot->dq_type].dqi_dirty_list);
+               ret = 0;
+       }
        spin_unlock(&dq_list_lock);
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL(dquot_mark_dquot_dirty);
 
@@ -551,8 +565,8 @@ int dquot_scan_active(struct super_block *sb,
                        continue;
                /* Now we have active dquot so we can just increase use count */
                atomic_inc(&dquot->dq_count);
-               dqstats.lookups++;
                spin_unlock(&dq_list_lock);
+               dqstats_inc(DQST_LOOKUPS);
                dqput(old_dquot);
                old_dquot = dquot;
                ret = fn(dquot, priv);
@@ -597,8 +611,8 @@ int vfs_quota_sync(struct super_block *sb, int type, int wait)
                         * holding reference so we can safely just increase
                         * use count */
                        atomic_inc(&dquot->dq_count);
-                       dqstats.lookups++;
                        spin_unlock(&dq_list_lock);
+                       dqstats_inc(DQST_LOOKUPS);
                        sb->dq_op->write_dquot(dquot);
                        dqput(dquot);
                        spin_lock(&dq_list_lock);
@@ -610,9 +624,7 @@ int vfs_quota_sync(struct super_block *sb, int type, int wait)
                if ((cnt == type || type == -1) && sb_has_quota_active(sb, cnt)
                    && info_dirty(&dqopt->info[cnt]))
                        sb->dq_op->write_info(sb, cnt);
-       spin_lock(&dq_list_lock);
-       dqstats.syncs++;
-       spin_unlock(&dq_list_lock);
+       dqstats_inc(DQST_SYNCS);
        mutex_unlock(&dqopt->dqonoff_mutex);
 
        if (!wait || (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE))
@@ -664,6 +676,22 @@ static void prune_dqcache(int count)
        }
 }
 
+static int dqstats_read(unsigned int type)
+{
+       int count = 0;
+#ifdef CONFIG_SMP
+       int cpu;
+       for_each_possible_cpu(cpu)
+               count += per_cpu_ptr(dqstats_pcpu, cpu)->stat[type];
+       /* Statistics reading is racy, but absolute accuracy isn't required */
+       if (count < 0)
+               count = 0;
+#else
+       count = dqstats.stat[type];
+#endif
+       return count;
+}
+
 /*
  * This is called from kswapd when we think we need some
  * more memory
@@ -676,7 +704,7 @@ static int shrink_dqcache_memory(int nr, gfp_t gfp_mask)
                prune_dqcache(nr);
                spin_unlock(&dq_list_lock);
        }
-       return (dqstats.free_dquots / 100) * sysctl_vfs_cache_pressure;
+       return (dqstats_read(DQST_FREE_DQUOTS)/100) * sysctl_vfs_cache_pressure;
 }
 
 static struct shrinker dqcache_shrinker = {
@@ -694,7 +722,7 @@ void dqput(struct dquot *dquot)
 
        if (!dquot)
                return;
-#ifdef __DQUOT_PARANOIA
+#ifdef CONFIG_QUOTA_DEBUG
        if (!atomic_read(&dquot->dq_count)) {
                printk("VFS: dqput: trying to free free dquot\n");
                printk("VFS: device %s, dquot of %s %d\n",
@@ -704,10 +732,7 @@ void dqput(struct dquot *dquot)
                BUG();
        }
 #endif
-       
-       spin_lock(&dq_list_lock);
-       dqstats.drops++;
-       spin_unlock(&dq_list_lock);
+       dqstats_inc(DQST_DROPS);
 we_slept:
        spin_lock(&dq_list_lock);
        if (atomic_read(&dquot->dq_count) > 1) {
@@ -747,7 +772,7 @@ we_slept:
                goto we_slept;
        }
        atomic_dec(&dquot->dq_count);
-#ifdef __DQUOT_PARANOIA
+#ifdef CONFIG_QUOTA_DEBUG
        /* sanity check */
        BUG_ON(!list_empty(&dquot->dq_free));
 #endif
@@ -824,15 +849,15 @@ we_slept:
                put_inuse(dquot);
                /* hash it first so it can be found */
                insert_dquot_hash(dquot);
-               dqstats.lookups++;
                spin_unlock(&dq_list_lock);
+               dqstats_inc(DQST_LOOKUPS);
        } else {
                if (!atomic_read(&dquot->dq_count))
                        remove_free_dquot(dquot);
                atomic_inc(&dquot->dq_count);
-               dqstats.cache_hits++;
-               dqstats.lookups++;
                spin_unlock(&dq_list_lock);
+               dqstats_inc(DQST_CACHE_HITS);
+               dqstats_inc(DQST_LOOKUPS);
        }
        /* Wait for dq_lock - after this we know that either dquot_release() is
         * already finished or it will be canceled due to dq_count > 1 test */
@@ -844,7 +869,7 @@ we_slept:
                dquot = NULL;
                goto out;
        }
-#ifdef __DQUOT_PARANOIA
+#ifdef CONFIG_QUOTA_DEBUG
        BUG_ON(!dquot->dq_sb);  /* Has somebody invalidated entry under us? */
 #endif
 out:
@@ -873,14 +898,18 @@ static int dqinit_needed(struct inode *inode, int type)
 static void add_dquot_ref(struct super_block *sb, int type)
 {
        struct inode *inode, *old_inode = NULL;
+#ifdef CONFIG_QUOTA_DEBUG
        int reserved = 0;
+#endif
 
        spin_lock(&inode_lock);
        list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
                if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE|I_NEW))
                        continue;
+#ifdef CONFIG_QUOTA_DEBUG
                if (unlikely(inode_get_rsv_space(inode) > 0))
                        reserved = 1;
+#endif
                if (!atomic_read(&inode->i_writecount))
                        continue;
                if (!dqinit_needed(inode, type))
@@ -890,7 +919,7 @@ static void add_dquot_ref(struct super_block *sb, int type)
                spin_unlock(&inode_lock);
 
                iput(old_inode);
-               sb->dq_op->initialize(inode, type);
+               __dquot_initialize(inode, type);
                /* We hold a reference to 'inode' so it couldn't have been
                 * removed from s_inodes list while we dropped the inode_lock.
                 * We cannot iput the inode now as we can be holding the last
@@ -902,11 +931,13 @@ static void add_dquot_ref(struct super_block *sb, int type)
        spin_unlock(&inode_lock);
        iput(old_inode);
 
+#ifdef CONFIG_QUOTA_DEBUG
        if (reserved) {
                printk(KERN_WARNING "VFS (%s): Writes happened before quota"
                        " was turned on thus quota information is probably "
                        "inconsistent. Please run quotacheck(8).\n", sb->s_id);
        }
+#endif
 }
 
 /*
@@ -933,7 +964,7 @@ static int remove_inode_dquot_ref(struct inode *inode, int type,
        inode->i_dquot[type] = NULL;
        if (dquot) {
                if (dqput_blocks(dquot)) {
-#ifdef __DQUOT_PARANOIA
+#ifdef CONFIG_QUOTA_DEBUG
                        if (atomic_read(&dquot->dq_count) != 1)
                                printk(KERN_WARNING "VFS: Adding dquot with dq_count %d to dispose list.\n", atomic_read(&dquot->dq_count));
 #endif
@@ -1180,13 +1211,13 @@ static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype)
        *warntype = QUOTA_NL_NOWARN;
        if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) ||
            test_bit(DQ_FAKE_B, &dquot->dq_flags))
-               return QUOTA_OK;
+               return 0;
 
        if (dquot->dq_dqb.dqb_ihardlimit &&
            newinodes > dquot->dq_dqb.dqb_ihardlimit &&
             !ignore_hardlimit(dquot)) {
                *warntype = QUOTA_NL_IHARDWARN;
-               return NO_QUOTA;
+               return -EDQUOT;
        }
 
        if (dquot->dq_dqb.dqb_isoftlimit &&
@@ -1195,7 +1226,7 @@ static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype)
            get_seconds() >= dquot->dq_dqb.dqb_itime &&
             !ignore_hardlimit(dquot)) {
                *warntype = QUOTA_NL_ISOFTLONGWARN;
-               return NO_QUOTA;
+               return -EDQUOT;
        }
 
        if (dquot->dq_dqb.dqb_isoftlimit &&
@@ -1206,7 +1237,7 @@ static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype)
                    sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace;
        }
 
-       return QUOTA_OK;
+       return 0;
 }
 
 /* needs dq_data_lock */
@@ -1218,7 +1249,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
        *warntype = QUOTA_NL_NOWARN;
        if (!sb_has_quota_limits_enabled(sb, dquot->dq_type) ||
            test_bit(DQ_FAKE_B, &dquot->dq_flags))
-               return QUOTA_OK;
+               return 0;
 
        tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace
                + space;
@@ -1228,7 +1259,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
             !ignore_hardlimit(dquot)) {
                if (!prealloc)
                        *warntype = QUOTA_NL_BHARDWARN;
-               return NO_QUOTA;
+               return -EDQUOT;
        }
 
        if (dquot->dq_dqb.dqb_bsoftlimit &&
@@ -1238,7 +1269,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
             !ignore_hardlimit(dquot)) {
                if (!prealloc)
                        *warntype = QUOTA_NL_BSOFTLONGWARN;
-               return NO_QUOTA;
+               return -EDQUOT;
        }
 
        if (dquot->dq_dqb.dqb_bsoftlimit &&
@@ -1254,10 +1285,10 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
                         * We don't allow preallocation to exceed softlimit so exceeding will
                         * be always printed
                         */
-                       return NO_QUOTA;
+                       return -EDQUOT;
        }
 
-       return QUOTA_OK;
+       return 0;
 }
 
 static int info_idq_free(struct dquot *dquot, qsize_t inodes)
@@ -1293,25 +1324,30 @@ static int info_bdq_free(struct dquot *dquot, qsize_t space)
 }
 
 /*
- *     Initialize quota pointers in inode
- *     We do things in a bit complicated way but by that we avoid calling
- *     dqget() and thus filesystem callbacks under dqptr_sem.
+ * Initialize quota pointers in inode
+ *
+ * We do things in a bit complicated way but by that we avoid calling
+ * dqget() and thus filesystem callbacks under dqptr_sem.
+ *
+ * It is better to call this function outside of any transaction as it
+ * might need a lot of space in journal for dquot structure allocation.
  */
-int dquot_initialize(struct inode *inode, int type)
+static void __dquot_initialize(struct inode *inode, int type)
 {
        unsigned int id = 0;
-       int cnt, ret = 0;
-       struct dquot *got[MAXQUOTAS] = { NULL, NULL };
+       int cnt;
+       struct dquot *got[MAXQUOTAS];
        struct super_block *sb = inode->i_sb;
        qsize_t rsv;
 
        /* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-       if (IS_NOQUOTA(inode))
-               return 0;
+       if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
+               return;
 
        /* First get references to structures we might need. */
        for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
+               got[cnt] = NULL;
                if (type != -1 && cnt != type)
                        continue;
                switch (cnt) {
@@ -1350,14 +1386,18 @@ out_err:
        up_write(&sb_dqopt(sb)->dqptr_sem);
        /* Drop unused references */
        dqput_all(got);
-       return ret;
+}
+
+void dquot_initialize(struct inode *inode)
+{
+       __dquot_initialize(inode, -1);
 }
 EXPORT_SYMBOL(dquot_initialize);
 
 /*
  *     Release all quotas referenced by inode
  */
-int dquot_drop(struct inode *inode)
+static void __dquot_drop(struct inode *inode)
 {
        int cnt;
        struct dquot *put[MAXQUOTAS];
@@ -1369,32 +1409,31 @@ int dquot_drop(struct inode *inode)
        }
        up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
        dqput_all(put);
-       return 0;
 }
-EXPORT_SYMBOL(dquot_drop);
 
-/* Wrapper to remove references to quota structures from inode */
-void vfs_dq_drop(struct inode *inode)
-{
-       /* Here we can get arbitrary inode from clear_inode() so we have
-        * to be careful. OTOH we don't need locking as quota operations
-        * are allowed to change only at mount time */
-       if (!IS_NOQUOTA(inode) && inode->i_sb && inode->i_sb->dq_op
-           && inode->i_sb->dq_op->drop) {
-               int cnt;
-               /* Test before calling to rule out calls from proc and such
-                 * where we are not allowed to block. Note that this is
-                * actually reliable test even without the lock - the caller
-                * must assure that nobody can come after the DQUOT_DROP and
-                * add quota pointers back anyway */
-               for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-                       if (inode->i_dquot[cnt])
-                               break;
-               if (cnt < MAXQUOTAS)
-                       inode->i_sb->dq_op->drop(inode);
-       }
-}
-EXPORT_SYMBOL(vfs_dq_drop);
+void dquot_drop(struct inode *inode)
+{
+       int cnt;
+
+       if (IS_NOQUOTA(inode))
+               return;
+
+       /*
+        * Test before calling to rule out calls from proc and such
+        * where we are not allowed to block. Note that this is
+        * actually reliable test even without the lock - the caller
+        * must assure that nobody can come after the DQUOT_DROP and
+        * add quota pointers back anyway.
+        */
+       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
+               if (inode->i_dquot[cnt])
+                       break;
+       }
+
+       if (cnt < MAXQUOTAS)
+               __dquot_drop(inode);
+}
+EXPORT_SYMBOL(dquot_drop);
 
 /*
  * inode_reserved_space is managed internally by quota, and protected by
@@ -1463,28 +1502,29 @@ static void inode_decr_space(struct inode *inode, qsize_t number, int reserve)
 }
 
 /*
- * Following four functions update i_blocks+i_bytes fields and
- * quota information (together with appropriate checks)
- * NOTE: We absolutely rely on the fact that caller dirties
- * the inode (usually macros in quotaops.h care about this) and
- * holds a handle for the current transaction so that dquot write and
- * inode write go into the same transaction.
+ * This functions updates i_blocks+i_bytes fields and quota information
+ * (together with appropriate checks).
+ *
+ * NOTE: We absolutely rely on the fact that caller dirties the inode
+ * (usually helpers in quotaops.h care about this) and holds a handle for
+ * the current transaction so that dquot write and inode write go into the
+ * same transaction.
  */
 
 /*
  * This operation can block, but only after everything is updated
  */
 int __dquot_alloc_space(struct inode *inode, qsize_t number,
-                       int warn, int reserve)
+               int warn, int reserve)
 {
-       int cnt, ret = QUOTA_OK;
+       int cnt, ret = 0;
        char warntype[MAXQUOTAS];
 
        /*
         * First test before acquiring mutex - solves deadlocks when we
         * re-enter the quota code and are already holding the mutex
         */
-       if (IS_NOQUOTA(inode)) {
+       if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
                inode_incr_space(inode, number, reserve);
                goto out;
        }
@@ -1497,9 +1537,9 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number,
        for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
                if (!inode->i_dquot[cnt])
                        continue;
-               if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt)
-                   == NO_QUOTA) {
-                       ret = NO_QUOTA;
+               ret = check_bdq(inode->i_dquot[cnt], number, !warn,
+                               warntype+cnt);
+               if (ret) {
                        spin_unlock(&dq_data_lock);
                        goto out_flush_warn;
                }
@@ -1524,31 +1564,20 @@ out_flush_warn:
 out:
        return ret;
 }
-
-int dquot_alloc_space(struct inode *inode, qsize_t number, int warn)
-{
-       return __dquot_alloc_space(inode, number, warn, 0);
-}
-EXPORT_SYMBOL(dquot_alloc_space);
-
-int dquot_reserve_space(struct inode *inode, qsize_t number, int warn)
-{
-       return __dquot_alloc_space(inode, number, warn, 1);
-}
-EXPORT_SYMBOL(dquot_reserve_space);
+EXPORT_SYMBOL(__dquot_alloc_space);
 
 /*
  * This operation can block, but only after everything is updated
  */
-int dquot_alloc_inode(const struct inode *inode, qsize_t number)
+int dquot_alloc_inode(const struct inode *inode)
 {
-       int cnt, ret = NO_QUOTA;
+       int cnt, ret = 0;
        char warntype[MAXQUOTAS];
 
        /* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-       if (IS_NOQUOTA(inode))
-               return QUOTA_OK;
+       if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
+               return 0;
        for (cnt = 0; cnt < MAXQUOTAS; cnt++)
                warntype[cnt] = QUOTA_NL_NOWARN;
        down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1556,20 +1585,20 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number)
        for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
                if (!inode->i_dquot[cnt])
                        continue;
-               if (check_idq(inode->i_dquot[cnt], number, warntype+cnt)
-                   == NO_QUOTA)
+               ret = check_idq(inode->i_dquot[cnt], 1, warntype + cnt);
+               if (ret)
                        goto warn_put_all;
        }
 
        for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
                if (!inode->i_dquot[cnt])
                        continue;
-               dquot_incr_inodes(inode->i_dquot[cnt], number);
+               dquot_incr_inodes(inode->i_dquot[cnt], 1);
        }
-       ret = QUOTA_OK;
+
 warn_put_all:
        spin_unlock(&dq_data_lock);
-       if (ret == QUOTA_OK)
+       if (ret == 0)
                mark_all_dquot_dirty(inode->i_dquot);
        flush_warnings(inode->i_dquot, warntype);
        up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1577,14 +1606,16 @@ warn_put_all:
 }
 EXPORT_SYMBOL(dquot_alloc_inode);
 
-int dquot_claim_space(struct inode *inode, qsize_t number)
+/*
+ * Convert in-memory reserved quotas to real consumed quotas
+ */
+int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
 {
        int cnt;
-       int ret = QUOTA_OK;
 
-       if (IS_NOQUOTA(inode)) {
+       if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
                inode_claim_rsv_space(inode, number);
-               goto out;
+               return 0;
        }
 
        down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1600,24 +1631,23 @@ int dquot_claim_space(struct inode *inode, qsize_t number)
        spin_unlock(&dq_data_lock);
        mark_all_dquot_dirty(inode->i_dquot);
        up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-out:
-       return ret;
+       return 0;
 }
-EXPORT_SYMBOL(dquot_claim_space);
+EXPORT_SYMBOL(dquot_claim_space_nodirty);
 
 /*
  * This operation can block, but only after everything is updated
  */
-int __dquot_free_space(struct inode *inode, qsize_t number, int reserve)
+void __dquot_free_space(struct inode *inode, qsize_t number, int reserve)
 {
        unsigned int cnt;
        char warntype[MAXQUOTAS];
 
        /* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-       if (IS_NOQUOTA(inode)) {
+       if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
                inode_decr_space(inode, number, reserve);
-               return QUOTA_OK;
+               return;
        }
 
        down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1640,93 +1670,67 @@ int __dquot_free_space(struct inode *inode, qsize_t number, int reserve)
 out_unlock:
        flush_warnings(inode->i_dquot, warntype);
        up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-       return QUOTA_OK;
 }
-
-int dquot_free_space(struct inode *inode, qsize_t number)
-{
-       return  __dquot_free_space(inode, number, 0);
-}
-EXPORT_SYMBOL(dquot_free_space);
-
-/*
- * Release reserved quota space
- */
-void dquot_release_reserved_space(struct inode *inode, qsize_t number)
-{
-       __dquot_free_space(inode, number, 1);
-
-}
-EXPORT_SYMBOL(dquot_release_reserved_space);
+EXPORT_SYMBOL(__dquot_free_space);
 
 /*
  * This operation can block, but only after everything is updated
  */
-int dquot_free_inode(const struct inode *inode, qsize_t number)
+void dquot_free_inode(const struct inode *inode)
 {
        unsigned int cnt;
        char warntype[MAXQUOTAS];
 
        /* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-       if (IS_NOQUOTA(inode))
-               return QUOTA_OK;
+       if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
+               return;
 
        down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
        spin_lock(&dq_data_lock);
        for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
                if (!inode->i_dquot[cnt])
                        continue;
-               warntype[cnt] = info_idq_free(inode->i_dquot[cnt], number);
-               dquot_decr_inodes(inode->i_dquot[cnt], number);
+               warntype[cnt] = info_idq_free(inode->i_dquot[cnt], 1);
+               dquot_decr_inodes(inode->i_dquot[cnt], 1);
        }
        spin_unlock(&dq_data_lock);
        mark_all_dquot_dirty(inode->i_dquot);
        flush_warnings(inode->i_dquot, warntype);
        up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-       return QUOTA_OK;
 }
 EXPORT_SYMBOL(dquot_free_inode);
 
 /*
  * Transfer the number of inode and blocks from one diskquota to an other.
+ * On success, dquot references in transfer_to are consumed and references
+ * to original dquots that need to be released are placed there. On failure,
+ * references are kept untouched.
  *
  * This operation can block, but only after everything is updated
  * A transaction must be started when entering this function.
+ *
  */
-int dquot_transfer(struct inode *inode, struct iattr *iattr)
+int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
 {
        qsize_t space, cur_space;
        qsize_t rsv_space = 0;
-       struct dquot *transfer_from[MAXQUOTAS];
-       struct dquot *transfer_to[MAXQUOTAS];
-       int cnt, ret = QUOTA_OK;
-       int chuid = iattr->ia_valid & ATTR_UID && inode->i_uid != iattr->ia_uid,
-           chgid = iattr->ia_valid & ATTR_GID && inode->i_gid != iattr->ia_gid;
+       struct dquot *transfer_from[MAXQUOTAS] = {};
+       int cnt, ret = 0;
        char warntype_to[MAXQUOTAS];
        char warntype_from_inodes[MAXQUOTAS], warntype_from_space[MAXQUOTAS];
 
        /* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
        if (IS_NOQUOTA(inode))
-               return QUOTA_OK;
+               return 0;
        /* Initialize the arrays */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-               transfer_from[cnt] = NULL;
-               transfer_to[cnt] = NULL;
+       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
                warntype_to[cnt] = QUOTA_NL_NOWARN;
-       }
-       if (chuid)
-               transfer_to[USRQUOTA] = dqget(inode->i_sb, iattr->ia_uid,
-                                             USRQUOTA);
-       if (chgid)
-               transfer_to[GRPQUOTA] = dqget(inode->i_sb, iattr->ia_gid,
-                                             GRPQUOTA);
-
        down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
        if (IS_NOQUOTA(inode)) {        /* File without quota accounting? */
                up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
-               goto put_all;
+               return 0;
        }
        spin_lock(&dq_data_lock);
        cur_space = inode_get_bytes(inode);
@@ -1737,9 +1741,11 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
                if (!transfer_to[cnt])
                        continue;
                transfer_from[cnt] = inode->i_dquot[cnt];
-               if (check_idq(transfer_to[cnt], 1, warntype_to + cnt) ==
-                   NO_QUOTA || check_bdq(transfer_to[cnt], space, 0,
-                   warntype_to + cnt) == NO_QUOTA)
+               ret = check_idq(transfer_to[cnt], 1, warntype_to + cnt);
+               if (ret)
+                       goto over_quota;
+               ret = check_bdq(transfer_to[cnt], space, 0, warntype_to + cnt);
+               if (ret)
                        goto over_quota;
        }
 
@@ -1776,39 +1782,43 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
 
        mark_all_dquot_dirty(transfer_from);
        mark_all_dquot_dirty(transfer_to);
-       /* The reference we got is transferred to the inode */
+       /* Pass back references to put */
        for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-               transfer_to[cnt] = NULL;
-warn_put_all:
+               transfer_to[cnt] = transfer_from[cnt];
+warn:
        flush_warnings(transfer_to, warntype_to);
        flush_warnings(transfer_from, warntype_from_inodes);
        flush_warnings(transfer_from, warntype_from_space);
-put_all:
-       dqput_all(transfer_from);
-       dqput_all(transfer_to);
        return ret;
 over_quota:
        spin_unlock(&dq_data_lock);
        up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
-       /* Clear dquot pointers we don't want to dqput() */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-               transfer_from[cnt] = NULL;
-       ret = NO_QUOTA;
-       goto warn_put_all;
+       goto warn;
 }
-EXPORT_SYMBOL(dquot_transfer);
+EXPORT_SYMBOL(__dquot_transfer);
 
-/* Wrapper for transferring ownership of an inode */
-int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
+/* Wrapper for transferring ownership of an inode for uid/gid only
+ * Called from FSXXX_setattr()
+ */
+int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
-       if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) {
-               vfs_dq_init(inode);
-               if (inode->i_sb->dq_op->transfer(inode, iattr) == NO_QUOTA)
-                       return 1;
-       }
-       return 0;
+       struct dquot *transfer_to[MAXQUOTAS] = {};
+       struct super_block *sb = inode->i_sb;
+       int ret;
+
+       if (!sb_any_quota_active(sb) || IS_NOQUOTA(inode))
+               return 0;
+
+       if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid)
+               transfer_to[USRQUOTA] = dqget(sb, iattr->ia_uid, USRQUOTA);
+       if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)
+               transfer_to[GRPQUOTA] = dqget(sb, iattr->ia_uid, GRPQUOTA);
+
+       ret = __dquot_transfer(inode, transfer_to);
+       dqput_all(transfer_to);
+       return ret;
 }
-EXPORT_SYMBOL(vfs_dq_transfer);
+EXPORT_SYMBOL(dquot_transfer);
 
 /*
  * Write info of quota file to disk
@@ -1829,13 +1839,6 @@ EXPORT_SYMBOL(dquot_commit_info);
  * Definitions of diskquota operations.
  */
 const struct dquot_operations dquot_operations = {
-       .initialize     = dquot_initialize,
-       .drop           = dquot_drop,
-       .alloc_space    = dquot_alloc_space,
-       .alloc_inode    = dquot_alloc_inode,
-       .free_space     = dquot_free_space,
-       .free_inode     = dquot_free_inode,
-       .transfer       = dquot_transfer,
        .write_dquot    = dquot_commit,
        .acquire_dquot  = dquot_acquire,
        .release_dquot  = dquot_release,
@@ -1846,6 +1849,20 @@ const struct dquot_operations dquot_operations = {
 };
 
 /*
+ * Generic helper for ->open on filesystems supporting disk quotas.
+ */
+int dquot_file_open(struct inode *inode, struct file *file)
+{
+       int error;
+
+       error = generic_file_open(inode, file);
+       if (!error && (file->f_mode & FMODE_WRITE))
+               dquot_initialize(inode);
+       return error;
+}
+EXPORT_SYMBOL(dquot_file_open);
+
+/*
  * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount)
  */
 int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
@@ -2024,11 +2041,13 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
        }
 
        if (!(dqopt->flags & DQUOT_QUOTA_SYS_FILE)) {
-               /* As we bypass the pagecache we must now flush the inode so
-                * that we see all the changes from userspace... */
-               write_inode_now(inode, 1);
-               /* And now flush the block cache so that kernel sees the
-                * changes */
+               /* As we bypass the pagecache we must now flush all the
+                * dirty data and invalidate caches so that kernel sees
+                * changes from userspace. It is not enough to just flush
+                * the quota file since if blocksize < pagesize, invalidation
+                * of the cache could fail because of other unrelated dirty
+                * data */
+               sync_filesystem(sb);
                invalidate_bdev(sb->s_bdev);
        }
        mutex_lock(&dqopt->dqonoff_mutex);
@@ -2050,7 +2069,7 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
                 * When S_NOQUOTA is set, remove dquot references as no more
                 * references can be added
                 */
-               sb->dq_op->drop(inode);
+               __dquot_drop(inode);
        }
 
        error = -EIO;
@@ -2272,25 +2291,30 @@ static inline qsize_t stoqb(qsize_t space)
 }
 
 /* Generic routine for getting common part of quota structure */
-static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di)
+static void do_get_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
 {
        struct mem_dqblk *dm = &dquot->dq_dqb;
 
+       memset(di, 0, sizeof(*di));
+       di->d_version = FS_DQUOT_VERSION;
+       di->d_flags = dquot->dq_type == USRQUOTA ?
+                       XFS_USER_QUOTA : XFS_GROUP_QUOTA;
+       di->d_id = dquot->dq_id;
+
        spin_lock(&dq_data_lock);
-       di->dqb_bhardlimit = stoqb(dm->dqb_bhardlimit);
-       di->dqb_bsoftlimit = stoqb(dm->dqb_bsoftlimit);
-       di->dqb_curspace = dm->dqb_curspace + dm->dqb_rsvspace;
-       di->dqb_ihardlimit = dm->dqb_ihardlimit;
-       di->dqb_isoftlimit = dm->dqb_isoftlimit;
-       di->dqb_curinodes = dm->dqb_curinodes;
-       di->dqb_btime = dm->dqb_btime;
-       di->dqb_itime = dm->dqb_itime;
-       di->dqb_valid = QIF_ALL;
+       di->d_blk_hardlimit = stoqb(dm->dqb_bhardlimit);
+       di->d_blk_softlimit = stoqb(dm->dqb_bsoftlimit);
+       di->d_ino_hardlimit = dm->dqb_ihardlimit;
+       di->d_ino_softlimit = dm->dqb_isoftlimit;
+       di->d_bcount = dm->dqb_curspace + dm->dqb_rsvspace;
+       di->d_icount = dm->dqb_curinodes;
+       di->d_btimer = dm->dqb_btime;
+       di->d_itimer = dm->dqb_itime;
        spin_unlock(&dq_data_lock);
 }
 
 int vfs_get_dqblk(struct super_block *sb, int type, qid_t id,
-                 struct if_dqblk *di)
+                 struct fs_disk_quota *di)
 {
        struct dquot *dquot;
 
@@ -2304,53 +2328,72 @@ int vfs_get_dqblk(struct super_block *sb, int type, qid_t id,
 }
 EXPORT_SYMBOL(vfs_get_dqblk);
 
+#define VFS_FS_DQ_MASK \
+       (FS_DQ_BCOUNT | FS_DQ_BSOFT | FS_DQ_BHARD | \
+        FS_DQ_ICOUNT | FS_DQ_ISOFT | FS_DQ_IHARD | \
+        FS_DQ_BTIMER | FS_DQ_ITIMER)
+
 /* Generic routine for setting common part of quota structure */
-static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
+static int do_set_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
 {
        struct mem_dqblk *dm = &dquot->dq_dqb;
        int check_blim = 0, check_ilim = 0;
        struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type];
 
-       if ((di->dqb_valid & QIF_BLIMITS &&
-            (di->dqb_bhardlimit > dqi->dqi_maxblimit ||
-             di->dqb_bsoftlimit > dqi->dqi_maxblimit)) ||
-           (di->dqb_valid & QIF_ILIMITS &&
-            (di->dqb_ihardlimit > dqi->dqi_maxilimit ||
-             di->dqb_isoftlimit > dqi->dqi_maxilimit)))
+       if (di->d_fieldmask & ~VFS_FS_DQ_MASK)
+               return -EINVAL;
+
+       if (((di->d_fieldmask & FS_DQ_BSOFT) &&
+            (di->d_blk_softlimit > dqi->dqi_maxblimit)) ||
+           ((di->d_fieldmask & FS_DQ_BHARD) &&
+            (di->d_blk_hardlimit > dqi->dqi_maxblimit)) ||
+           ((di->d_fieldmask & FS_DQ_ISOFT) &&
+            (di->d_ino_softlimit > dqi->dqi_maxilimit)) ||
+           ((di->d_fieldmask & FS_DQ_IHARD) &&
+            (di->d_ino_hardlimit > dqi->dqi_maxilimit)))
                return -ERANGE;
 
        spin_lock(&dq_data_lock);
-       if (di->dqb_valid & QIF_SPACE) {
-               dm->dqb_curspace = di->dqb_curspace - dm->dqb_rsvspace;
+       if (di->d_fieldmask & FS_DQ_BCOUNT) {
+               dm->dqb_curspace = di->d_bcount - dm->dqb_rsvspace;
                check_blim = 1;
-               __set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
+               set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
        }
-       if (di->dqb_valid & QIF_BLIMITS) {
-               dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
-               dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
+
+       if (di->d_fieldmask & FS_DQ_BSOFT)
+               dm->dqb_bsoftlimit = qbtos(di->d_blk_softlimit);
+       if (di->d_fieldmask & FS_DQ_BHARD)
+               dm->dqb_bhardlimit = qbtos(di->d_blk_hardlimit);
+       if (di->d_fieldmask & (FS_DQ_BSOFT | FS_DQ_BHARD)) {
                check_blim = 1;
-               __set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
+               set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
        }
-       if (di->dqb_valid & QIF_INODES) {
-               dm->dqb_curinodes = di->dqb_curinodes;
+
+       if (di->d_fieldmask & FS_DQ_ICOUNT) {
+               dm->dqb_curinodes = di->d_icount;
                check_ilim = 1;
-               __set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
+               set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
        }
-       if (di->dqb_valid & QIF_ILIMITS) {
-               dm->dqb_isoftlimit = di->dqb_isoftlimit;
-               dm->dqb_ihardlimit = di->dqb_ihardlimit;
+
+       if (di->d_fieldmask & FS_DQ_ISOFT)
+               dm->dqb_isoftlimit = di->d_ino_softlimit;
+       if (di->d_fieldmask & FS_DQ_IHARD)
+               dm->dqb_ihardlimit = di->d_ino_hardlimit;
+       if (di->d_fieldmask & (FS_DQ_ISOFT | FS_DQ_IHARD)) {
                check_ilim = 1;
-               __set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
+               set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
        }
-       if (di->dqb_valid & QIF_BTIME) {
-               dm->dqb_btime = di->dqb_btime;
+
+       if (di->d_fieldmask & FS_DQ_BTIMER) {
+               dm->dqb_btime = di->d_btimer;
                check_blim = 1;
-               __set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
+               set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
        }
-       if (di->dqb_valid & QIF_ITIME) {
-               dm->dqb_itime = di->dqb_itime;
+
+       if (di->d_fieldmask & FS_DQ_ITIMER) {
+               dm->dqb_itime = di->d_itimer;
                check_ilim = 1;
-               __set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
+               set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
        }
 
        if (check_blim) {
@@ -2358,7 +2401,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
                    dm->dqb_curspace < dm->dqb_bsoftlimit) {
                        dm->dqb_btime = 0;
                        clear_bit(DQ_BLKS_B, &dquot->dq_flags);
-               } else if (!(di->dqb_valid & QIF_BTIME))
+               } else if (!(di->d_fieldmask & FS_DQ_BTIMER))
                        /* Set grace only if user hasn't provided his own... */
                        dm->dqb_btime = get_seconds() + dqi->dqi_bgrace;
        }
@@ -2367,7 +2410,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
                    dm->dqb_curinodes < dm->dqb_isoftlimit) {
                        dm->dqb_itime = 0;
                        clear_bit(DQ_INODES_B, &dquot->dq_flags);
-               } else if (!(di->dqb_valid & QIF_ITIME))
+               } else if (!(di->d_fieldmask & FS_DQ_ITIMER))
                        /* Set grace only if user hasn't provided his own... */
                        dm->dqb_itime = get_seconds() + dqi->dqi_igrace;
        }
@@ -2383,7 +2426,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
 }
 
 int vfs_set_dqblk(struct super_block *sb, int type, qid_t id,
-                 struct if_dqblk *di)
+                 struct fs_disk_quota *di)
 {
        struct dquot *dquot;
        int rc;
@@ -2462,62 +2505,74 @@ const struct quotactl_ops vfs_quotactl_ops = {
        .set_dqblk      = vfs_set_dqblk
 };
 
+
+static int do_proc_dqstats(struct ctl_table *table, int write,
+                    void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+#ifdef CONFIG_SMP
+       /* Update global table */
+       unsigned int type = (int *)table->data - dqstats.stat;
+       dqstats.stat[type] = dqstats_read(type);
+#endif
+       return proc_dointvec(table, write, buffer, lenp, ppos);
+}
+
 static ctl_table fs_dqstats_table[] = {
        {
                .procname       = "lookups",
-               .data           = &dqstats.lookups,
+               .data           = &dqstats.stat[DQST_LOOKUPS],
                .maxlen         = sizeof(int),
                .mode           = 0444,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = do_proc_dqstats,
        },
        {
                .procname       = "drops",
-               .data           = &dqstats.drops,
+               .data           = &dqstats.stat[DQST_DROPS],
                .maxlen         = sizeof(int),
                .mode           = 0444,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = do_proc_dqstats,
        },
        {
                .procname       = "reads",
-               .data           = &dqstats.reads,
+               .data           = &dqstats.stat[DQST_READS],
                .maxlen         = sizeof(int),
                .mode           = 0444,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = do_proc_dqstats,
        },
        {
                .procname       = "writes",
-               .data           = &dqstats.writes,
+               .data           = &dqstats.stat[DQST_WRITES],
                .maxlen         = sizeof(int),
                .mode           = 0444,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = do_proc_dqstats,
        },
        {
                .procname       = "cache_hits",
-               .data           = &dqstats.cache_hits,
+               .data           = &dqstats.stat[DQST_CACHE_HITS],
                .maxlen         = sizeof(int),
                .mode           = 0444,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = do_proc_dqstats,
        },
        {
                .procname       = "allocated_dquots",
-               .data           = &dqstats.allocated_dquots,
+               .data           = &dqstats.stat[DQST_ALLOC_DQUOTS],
                .maxlen         = sizeof(int),
                .mode           = 0444,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = do_proc_dqstats,
        },
        {
                .procname       = "free_dquots",
-               .data           = &dqstats.free_dquots,
+               .data           = &dqstats.stat[DQST_FREE_DQUOTS],
                .maxlen         = sizeof(int),
                .mode           = 0444,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = do_proc_dqstats,
        },
        {
                .procname       = "syncs",
-               .data           = &dqstats.syncs,
+               .data           = &dqstats.stat[DQST_SYNCS],
                .maxlen         = sizeof(int),
                .mode           = 0444,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = do_proc_dqstats,
        },
 #ifdef CONFIG_PRINT_QUOTA_WARNING
        {
@@ -2569,6 +2624,13 @@ static int __init dquot_init(void)
        if (!dquot_hash)
                panic("Cannot create dquot hash table");
 
+#ifdef CONFIG_SMP
+       dqstats_pcpu = alloc_percpu(struct dqstats);
+       if (!dqstats_pcpu)
+               panic("Cannot create dquot stats table");
+#endif
+       memset(&dqstats, 0, sizeof(struct dqstats));
+
        /* Find power-of-two hlist_heads which can fit into allocation */
        nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head);
        dq_hash_bits = 0;