block: reorganize queue draining
[linux-2.6-block.git] / block / blk-throttle.c
index f6a794120505668084929afdacd0b5e17f8fca8d..ecba5fcef201f46e5d9741a484b69299cf4fd22c 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/bio.h>
 #include <linux/blktrace_api.h>
 #include "blk-cgroup.h"
+#include "blk.h"
 
 /* Max dispatch from a group in 1 round */
 static int throtl_grp_quantum = 8;
@@ -323,12 +324,8 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data *td)
        /*
         * Need to allocate a group. Allocation of group also needs allocation
         * of per cpu stats which in-turn takes a mutex() and can block. Hence
-        * we need to drop rcu lock and queue_lock before we call alloc
-        *
-        * Take the request queue reference to make sure queue does not
-        * go away once we return from allocation.
+        * we need to drop rcu lock and queue_lock before we call alloc.
         */
-       blk_get_queue(q);
        rcu_read_unlock();
        spin_unlock_irq(q->queue_lock);
 
@@ -338,13 +335,11 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data *td)
         * dead
         */
        if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
-               blk_put_queue(q);
                if (tg)
                        kfree(tg);
 
                return ERR_PTR(-ENODEV);
        }
-       blk_put_queue(q);
 
        /* Group allocated and queue is still alive. take the lock */
        spin_lock_irq(q->queue_lock);
@@ -746,7 +741,7 @@ static bool tg_may_dispatch(struct throtl_data *td, struct throtl_grp *tg,
 static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio)
 {
        bool rw = bio_data_dir(bio);
-       bool sync = bio->bi_rw & REQ_SYNC;
+       bool sync = rw_is_sync(bio->bi_rw);
 
        /* Charge the bio to the group */
        tg->bytes_disp[rw] += bio->bi_size;
@@ -1150,7 +1145,7 @@ int blk_throtl_bio(struct request_queue *q, struct bio **biop)
 
                if (tg_no_rule_group(tg, rw)) {
                        blkiocg_update_dispatch_stats(&tg->blkg, bio->bi_size,
-                                       rw, bio->bi_rw & REQ_SYNC);
+                                       rw, rw_is_sync(bio->bi_rw));
                        rcu_read_unlock();
                        return 0;
                }