Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[linux-drm-fsl-dcu.git] / block / cfq-iosched.c
index 9fc5eafa6c0e6283398aafc4bc6a5c584438f10b..07b706243772e46fe2434248bf0e4fba938fca0a 100644 (file)
@@ -577,27 +577,22 @@ static int cfq_allow_merge(request_queue_t *q, struct request *rq,
        pid_t key;
 
        /*
-        * If bio is async or a write, always allow merge
+        * Disallow merge of a sync bio into an async request.
         */
-       if (!bio_sync(bio) || rw == WRITE)
-               return 1;
-
-       /*
-        * bio is sync. if request is not, disallow.
-        */
-       if (!rq_is_sync(rq))
+       if ((bio_data_dir(bio) == READ || bio_sync(bio)) && !rq_is_sync(rq))
                return 0;
 
        /*
-        * Ok, both bio and request are sync. Allow merge if they are
-        * from the same queue.
+        * Lookup the cfqq that this bio will be queued with. Allow
+        * merge only if rq is queued there.
         */
-       key = cfq_queue_pid(current, rw, 1);
+       key = cfq_queue_pid(current, rw, bio_sync(bio));
        cfqq = cfq_find_cfq_hash(cfqd, key, current->ioprio);
-       if (cfqq != RQ_CFQQ(rq))
-               return 0;
 
-       return 1;
+       if (cfqq == RQ_CFQQ(rq))
+               return 1;
+
+       return 0;
 }
 
 static inline void