Skip to content

Commit

Permalink
block: fix request sorting at unplug
Browse files Browse the repository at this point in the history
Comparison function for list_sort() must be anticommutative,
otherwise it is not sorting in ordinary meaning.

But fortunately list_sort() always check ((*cmp)(priv, a, b) <= 0)
it not distinguish negative and zero, so comparison function can
implement only less-or-equal instead of full three-way comparison.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
  • Loading branch information
koct9i authored and Jens Axboe committed Apr 5, 2011
1 parent a63a5cf commit f83e826
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,7 @@ static int plug_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
struct request *rqa = container_of(a, struct request, queuelist);
struct request *rqb = container_of(b, struct request, queuelist);

return !(rqa->q == rqb->q);
return !(rqa->q <= rqb->q);
}

static void flush_plug_list(struct blk_plug *plug)
Expand Down

0 comments on commit f83e826

Please sign in to comment.