cfq-iosched: don't delay async queue if it hasn't dispatched at all
authorJens Axboe <jens.axboe@oracle.com>
Sun, 4 Oct 2009 18:36:19 +0000 (20:36 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Sun, 4 Oct 2009 18:36:19 +0000 (20:36 +0200)
We cannot delay for the first dispatch of the async queue if it
hasn't dispatched at all, since that could present a local user
DoS attack vector using an app that just did slow timed sync reads
while filling memory.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
block/cfq-iosched.c

index ebab60c6be9d73cbe7140f3020cd0aef79cc4b3e..9c4b679908f41cf034cdddc79a9bff8bcb1f4e85 100644 (file)
@@ -1345,16 +1345,9 @@ static int cfq_dispatch_requests(struct request_queue *q, int force)
                unsigned long last_sync = jiffies - cfqd->last_end_sync_rq;
                unsigned int depth;
 
-               /*
-                * must wait a bit longer
-                */
-               if (last_sync < cfqd->cfq_slice[1]) {
-                       cfq_schedule_dispatch(cfqd,
-                                               cfqd->cfq_slice[1] - last_sync);
-                       return 0;
-               }
-
                depth = last_sync / cfqd->cfq_slice[1];
+               if (!depth && !cfqq->dispatched)
+                       depth = 1;
                if (depth < max_dispatch)
                        max_dispatch = depth;
        }