blkio: Provide some isolation between groups
authorVivek Goyal <vgoyal@redhat.com>
Thu, 3 Dec 2009 17:59:50 +0000 (12:59 -0500)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 3 Dec 2009 18:28:52 +0000 (19:28 +0100)
o Do not allow following three operations across groups for isolation.
- selection of co-operating queues
- preemtpions across groups
- request merging across groups.

o Async queues are currently global and not per group. Allow preemption of
  an async queue if a sync queue in other group gets backlogged.

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

index 7d345e7..3a62ce9 100644 (file)
@@ -1461,6 +1461,9 @@ static int cfq_allow_merge(struct request_queue *q, struct request *rq,
        struct cfq_io_context *cic;
        struct cfq_queue *cfqq;
 
        struct cfq_io_context *cic;
        struct cfq_queue *cfqq;
 
+       /* Deny merge if bio and rq don't belong to same cfq group */
+       if ((RQ_CFQQ(rq))->cfqg != cfq_get_cfqg(cfqd, 0))
+               return false;
        /*
         * Disallow merge of a sync bio into an async request.
         */
        /*
         * Disallow merge of a sync bio into an async request.
         */
@@ -1698,6 +1701,10 @@ static struct cfq_queue *cfq_close_cooperator(struct cfq_data *cfqd,
        if (!cfqq)
                return NULL;
 
        if (!cfqq)
                return NULL;
 
+       /* If new queue belongs to different cfq_group, don't choose it */
+       if (cur_cfqq->cfqg != cfqq->cfqg)
+               return NULL;
+
        /*
         * It only makes sense to merge sync queues.
         */
        /*
         * It only makes sense to merge sync queues.
         */
@@ -2950,22 +2957,12 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
        if (!cfqq)
                return false;
 
        if (!cfqq)
                return false;
 
-       if (cfq_slice_used(cfqq))
-               return true;
-
        if (cfq_class_idle(new_cfqq))
                return false;
 
        if (cfq_class_idle(cfqq))
                return true;
 
        if (cfq_class_idle(new_cfqq))
                return false;
 
        if (cfq_class_idle(cfqq))
                return true;
 
-       /* Allow preemption only if we are idling on sync-noidle tree */
-       if (cfqd->serving_type == SYNC_NOIDLE_WORKLOAD &&
-           cfqq_type(new_cfqq) == SYNC_NOIDLE_WORKLOAD &&
-           new_cfqq->service_tree->count == 2 &&
-           RB_EMPTY_ROOT(&cfqq->sort_list))
-               return true;
-
        /*
         * if the new request is sync, but the currently running queue is
         * not, let the sync request have priority.
        /*
         * if the new request is sync, but the currently running queue is
         * not, let the sync request have priority.
@@ -2973,6 +2970,19 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
        if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq))
                return true;
 
        if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq))
                return true;
 
+       if (new_cfqq->cfqg != cfqq->cfqg)
+               return false;
+
+       if (cfq_slice_used(cfqq))
+               return true;
+
+       /* Allow preemption only if we are idling on sync-noidle tree */
+       if (cfqd->serving_type == SYNC_NOIDLE_WORKLOAD &&
+           cfqq_type(new_cfqq) == SYNC_NOIDLE_WORKLOAD &&
+           new_cfqq->service_tree->count == 2 &&
+           RB_EMPTY_ROOT(&cfqq->sort_list))
+               return true;
+
        /*
         * So both queues are sync. Let the new request get disk time if
         * it's a metadata request and the current queue is doing regular IO.
        /*
         * So both queues are sync. Let the new request get disk time if
         * it's a metadata request and the current queue is doing regular IO.