diff options
author | Tejun Heo <htejun@gmail.com> | 2006-02-08 04:01:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-08 10:52:58 -0500 |
commit | 30e9656cc340035e102fea46e1908689494b042d (patch) | |
tree | 5fc623ccad5a1f5b09ebc4b7e8d7c6bec8e485ac | |
parent | e5ea0a9fca5612808839dd4bcc41c46fc02451f9 (diff) |
[PATCH] block: implement elv_insert and use it (fix ordcolor flipping bug)
q->ordcolor must only be flipped on initial queueing of a hardbarrier
request.
Constructing ordered sequence and requeueing used to pass through
__elv_add_request() which flips q->ordcolor when it sees a barrier
request.
This patch separates out elv_insert() from __elv_add_request() and uses
elv_insert() when constructing ordered sequence and requeueing.
elv_insert() inserts the given request at the specified position and
does nothing else.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Acked-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | block/elevator.c | 70 | ||||
-rw-r--r-- | block/ll_rw_blk.c | 4 | ||||
-rw-r--r-- | include/linux/elevator.h | 1 |
3 files changed, 41 insertions, 34 deletions
diff --git a/block/elevator.c b/block/elevator.c index 2fc269f69726..24b702d649a9 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -293,7 +293,7 @@ void elv_requeue_request(request_queue_t *q, struct request *rq) | |||
293 | 293 | ||
294 | rq->flags &= ~REQ_STARTED; | 294 | rq->flags &= ~REQ_STARTED; |
295 | 295 | ||
296 | __elv_add_request(q, rq, ELEVATOR_INSERT_REQUEUE, 0); | 296 | elv_insert(q, rq, ELEVATOR_INSERT_REQUEUE); |
297 | } | 297 | } |
298 | 298 | ||
299 | static void elv_drain_elevator(request_queue_t *q) | 299 | static void elv_drain_elevator(request_queue_t *q) |
@@ -310,41 +310,11 @@ static void elv_drain_elevator(request_queue_t *q) | |||
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | void __elv_add_request(request_queue_t *q, struct request *rq, int where, | 313 | void elv_insert(request_queue_t *q, struct request *rq, int where) |
314 | int plug) | ||
315 | { | 314 | { |
316 | struct list_head *pos; | 315 | struct list_head *pos; |
317 | unsigned ordseq; | 316 | unsigned ordseq; |
318 | 317 | ||
319 | if (q->ordcolor) | ||
320 | rq->flags |= REQ_ORDERED_COLOR; | ||
321 | |||
322 | if (rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)) { | ||
323 | /* | ||
324 | * toggle ordered color | ||
325 | */ | ||
326 | if (blk_barrier_rq(rq)) | ||
327 | q->ordcolor ^= 1; | ||
328 | |||
329 | /* | ||
330 | * barriers implicitly indicate back insertion | ||
331 | */ | ||
332 | if (where == ELEVATOR_INSERT_SORT) | ||
333 | where = ELEVATOR_INSERT_BACK; | ||
334 | |||
335 | /* | ||
336 | * this request is scheduling boundary, update end_sector | ||
337 | */ | ||
338 | if (blk_fs_request(rq)) { | ||
339 | q->end_sector = rq_end_sector(rq); | ||
340 | q->boundary_rq = rq; | ||
341 | } | ||
342 | } else if (!(rq->flags & REQ_ELVPRIV) && where == ELEVATOR_INSERT_SORT) | ||
343 | where = ELEVATOR_INSERT_BACK; | ||
344 | |||
345 | if (plug) | ||
346 | blk_plug_device(q); | ||
347 | |||
348 | rq->q = q; | 318 | rq->q = q; |
349 | 319 | ||
350 | switch (where) { | 320 | switch (where) { |
@@ -425,6 +395,42 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where, | |||
425 | } | 395 | } |
426 | } | 396 | } |
427 | 397 | ||
398 | void __elv_add_request(request_queue_t *q, struct request *rq, int where, | ||
399 | int plug) | ||
400 | { | ||
401 | if (q->ordcolor) | ||
402 | rq->flags |= REQ_ORDERED_COLOR; | ||
403 | |||
404 | if (rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)) { | ||
405 | /* | ||
406 | * toggle ordered color | ||
407 | */ | ||
408 | if (blk_barrier_rq(rq)) | ||
409 | q->ordcolor ^= 1; | ||
410 | |||
411 | /* | ||
412 | * barriers implicitly indicate back insertion | ||
413 | */ | ||
414 | if (where == ELEVATOR_INSERT_SORT) | ||
415 | where = ELEVATOR_INSERT_BACK; | ||
416 | |||
417 | /* | ||
418 | * this request is scheduling boundary, update | ||
419 | * end_sector | ||
420 | */ | ||
421 | if (blk_fs_request(rq)) { | ||
422 | q->end_sector = rq_end_sector(rq); | ||
423 | q->boundary_rq = rq; | ||
424 | } | ||
425 | } else if (!(rq->flags & REQ_ELVPRIV) && where == ELEVATOR_INSERT_SORT) | ||
426 | where = ELEVATOR_INSERT_BACK; | ||
427 | |||
428 | if (plug) | ||
429 | blk_plug_device(q); | ||
430 | |||
431 | elv_insert(q, rq, where); | ||
432 | } | ||
433 | |||
428 | void elv_add_request(request_queue_t *q, struct request *rq, int where, | 434 | void elv_add_request(request_queue_t *q, struct request *rq, int where, |
429 | int plug) | 435 | int plug) |
430 | { | 436 | { |
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index ee5ed98db4cd..03d9c82b0fe7 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c | |||
@@ -454,7 +454,7 @@ static void queue_flush(request_queue_t *q, unsigned which) | |||
454 | rq->end_io = end_io; | 454 | rq->end_io = end_io; |
455 | q->prepare_flush_fn(q, rq); | 455 | q->prepare_flush_fn(q, rq); |
456 | 456 | ||
457 | __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); | 457 | elv_insert(q, rq, ELEVATOR_INSERT_FRONT); |
458 | } | 458 | } |
459 | 459 | ||
460 | static inline struct request *start_ordered(request_queue_t *q, | 460 | static inline struct request *start_ordered(request_queue_t *q, |
@@ -490,7 +490,7 @@ static inline struct request *start_ordered(request_queue_t *q, | |||
490 | else | 490 | else |
491 | q->ordseq |= QUEUE_ORDSEQ_POSTFLUSH; | 491 | q->ordseq |= QUEUE_ORDSEQ_POSTFLUSH; |
492 | 492 | ||
493 | __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); | 493 | elv_insert(q, rq, ELEVATOR_INSERT_FRONT); |
494 | 494 | ||
495 | if (q->ordered & QUEUE_ORDERED_PREFLUSH) { | 495 | if (q->ordered & QUEUE_ORDERED_PREFLUSH) { |
496 | queue_flush(q, QUEUE_ORDERED_PREFLUSH); | 496 | queue_flush(q, QUEUE_ORDERED_PREFLUSH); |
diff --git a/include/linux/elevator.h b/include/linux/elevator.h index 23fe746a1d51..18cf1f3e1184 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h | |||
@@ -82,6 +82,7 @@ struct elevator_queue | |||
82 | extern void elv_dispatch_sort(request_queue_t *, struct request *); | 82 | extern void elv_dispatch_sort(request_queue_t *, struct request *); |
83 | extern void elv_add_request(request_queue_t *, struct request *, int, int); | 83 | extern void elv_add_request(request_queue_t *, struct request *, int, int); |
84 | extern void __elv_add_request(request_queue_t *, struct request *, int, int); | 84 | extern void __elv_add_request(request_queue_t *, struct request *, int, int); |
85 | extern void elv_insert(request_queue_t *, struct request *, int); | ||
85 | extern int elv_merge(request_queue_t *, struct request **, struct bio *); | 86 | extern int elv_merge(request_queue_t *, struct request **, struct bio *); |
86 | extern void elv_merge_requests(request_queue_t *, struct request *, | 87 | extern void elv_merge_requests(request_queue_t *, struct request *, |
87 | struct request *); | 88 | struct request *); |