public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cfq: wrong sync writes detection
@ 2006-12-11 15:45 Vasily Tarasov
  2006-12-11 16:08 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Vasily Tarasov @ 2006-12-11 15:45 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Linux Kernel Mailing List, Kirill Korotaev,
	OpenVZ Developers List

CFQ I/O scheduler does the following actions to
find out whether the request is sync:

rw = rq_data_dir(rq); => possible values for rw are 0 or 1

static inline pid_t cfq_queue_pid(struct task_struct *task, int rw)
{
        if (rw == READ || rw == WRITE_SYNC) => second condition is always false
                return task->pid;

        return CFQ_KEY_ASYNC;
}

The following patch fixes the bug by adding sync parameter,
wich is obtained through bio_sync macros.

Signed-off-by: Vasily Tarasov <vtaras@openvz.org>

--

--- ./block/cfq-iosched.c.syncwrite	2006-09-20 07:42:06.000000000 +0400
+++ ./block/cfq-iosched.c	2006-12-11 07:23:03.000000000 +0300
@@ -324,9 +324,9 @@ static int cfq_queue_empty(request_queue
 	return !cfqd->busy_queues;
 }
 
-static inline pid_t cfq_queue_pid(struct task_struct *task, int rw)
+static inline pid_t cfq_queue_pid(struct task_struct *task, int rw, int sync)
 {
-	if (rw == READ || rw == WRITE_SYNC)
+	if (rw == READ || sync)
 		return task->pid;
 
 	return CFQ_KEY_ASYNC;
@@ -621,7 +621,7 @@ static struct request *
 cfq_find_rq_fmerge(struct cfq_data *cfqd, struct bio *bio)
 {
 	struct task_struct *tsk = current;
-	pid_t key = cfq_queue_pid(tsk, bio_data_dir(bio));
+	pid_t key = cfq_queue_pid(tsk, bio_data_dir(bio), bio_sync(bio));
 	struct cfq_queue *cfqq;
 	struct rb_node *n;
 	sector_t sector;
@@ -1958,7 +1958,8 @@ static int cfq_may_queue(request_queue_t
 	 * so just lookup a possibly existing queue, or return 'may queue'
 	 * if that fails
 	 */
-	cfqq = cfq_find_cfq_hash(cfqd, cfq_queue_pid(tsk, rw), tsk->ioprio);
+	cfqq = cfq_find_cfq_hash(cfqd, cfq_queue_pid(tsk, rw,
+					bio_sync(bio)), tsk->ioprio);
 	if (cfqq) {
 		cfq_init_prio_data(cfqq);
 		cfq_prio_boost(cfqq);
@@ -2020,7 +2021,7 @@ cfq_set_request(request_queue_t *q, stru
 	struct task_struct *tsk = current;
 	struct cfq_io_context *cic;
 	const int rw = rq_data_dir(rq);
-	pid_t key = cfq_queue_pid(tsk, rw);
+	pid_t key = cfq_queue_pid(tsk, rw, bio_sync(bio));
 	struct cfq_queue *cfqq;
 	struct cfq_rq *crq;
 	unsigned long flags;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-12-11 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-11 15:45 [PATCH] cfq: wrong sync writes detection Vasily Tarasov
2006-12-11 16:08 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox