quota: Remove dq_wait_unused from dquot
[sfrench/cifs-2.6.git] / fs / quota / dquot.c
index 0393581fe1a3aefa2851862b4fbd189ec4c389b9..361a2a6f13e102b67b7aca3cc099ad0c7aa28a4c 100644 (file)
@@ -126,6 +126,8 @@ __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_data_lock);
 EXPORT_SYMBOL(dq_data_lock);
 DEFINE_STATIC_SRCU(dquot_srcu);
 
+static DECLARE_WAIT_QUEUE_HEAD(dquot_ref_wq);
+
 void __quota_error(struct super_block *sb, const char *func,
                   const char *fmt, ...)
 {
@@ -381,12 +383,15 @@ static inline void dqput_all(struct dquot **dquot)
                dqput(dquot[cnt]);
 }
 
-/* This function needs dq_list_lock */
 static inline int clear_dquot_dirty(struct dquot *dquot)
 {
-       if (!test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags))
+       spin_lock(&dq_list_lock);
+       if (!test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags)) {
+               spin_unlock(&dq_list_lock);
                return 0;
+       }
        list_del_init(&dquot->dq_dirty);
+       spin_unlock(&dq_list_lock);
        return 1;
 }
 
@@ -451,12 +456,8 @@ int dquot_commit(struct dquot *dquot)
        struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
 
        mutex_lock(&dquot->dq_lock);
-       spin_lock(&dq_list_lock);
-       if (!clear_dquot_dirty(dquot)) {
-               spin_unlock(&dq_list_lock);
+       if (!clear_dquot_dirty(dquot))
                goto out_lock;
-       }
-       spin_unlock(&dq_list_lock);
        /* Inactive dquot can be only if there was error during read/init
         * => we have better not writing it */
        if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
@@ -528,22 +529,18 @@ restart:
                        continue;
                /* Wait for dquot users */
                if (atomic_read(&dquot->dq_count)) {
-                       DEFINE_WAIT(wait);
-
                        dqgrab(dquot);
-                       prepare_to_wait(&dquot->dq_wait_unused, &wait,
-                                       TASK_UNINTERRUPTIBLE);
                        spin_unlock(&dq_list_lock);
-                       /* Once dqput() wakes us up, we know it's time to free
+                       /*
+                        * Once dqput() wakes us up, we know it's time to free
                         * the dquot.
                         * IMPORTANT: we rely on the fact that there is always
                         * at most one process waiting for dquot to free.
                         * Otherwise dq_count would be > 1 and we would never
                         * wake up.
                         */
-                       if (atomic_read(&dquot->dq_count) > 1)
-                               schedule();
-                       finish_wait(&dquot->dq_wait_unused, &wait);
+                       wait_event(dquot_ref_wq,
+                                  atomic_read(&dquot->dq_count) == 1);
                        dqput(dquot);
                        /* At this moment dquot() need not exist (it could be
                         * reclaimed by prune_dqcache(). Hence we must
@@ -755,7 +752,7 @@ we_slept:
                /* Releasing dquot during quotaoff phase? */
                if (!sb_has_quota_active(dquot->dq_sb, dquot->dq_id.type) &&
                    atomic_read(&dquot->dq_count) == 1)
-                       wake_up(&dquot->dq_wait_unused);
+                       wake_up(&dquot_ref_wq);
                spin_unlock(&dq_list_lock);
                return;
        }
@@ -772,9 +769,7 @@ we_slept:
                         * We clear dirty bit anyway, so that we avoid
                         * infinite loop here
                         */
-                       spin_lock(&dq_list_lock);
                        clear_dquot_dirty(dquot);
-                       spin_unlock(&dq_list_lock);
                }
                goto we_slept;
        }
@@ -812,7 +807,6 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
        INIT_LIST_HEAD(&dquot->dq_inuse);
        INIT_HLIST_NODE(&dquot->dq_hash);
        INIT_LIST_HEAD(&dquot->dq_dirty);
-       init_waitqueue_head(&dquot->dq_wait_unused);
        dquot->dq_sb = sb;
        dquot->dq_id = make_kqid_invalid(type);
        atomic_set(&dquot->dq_count, 1);