From 401a18e92ce32cd0ddfa5738899ca2b8114f2bbf Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 25 Mar 2011 16:57:52 +0100 Subject: block: fix bug with inserting flush requests as sort/merge With the introduction of the on-stack plugging, we would assume that any request being inserted was a normal file system request. As flush/fua requires a special insert mode, this caused problems. Fix this up by checking for this in flush_plug_list() and use the appropriate insert mechanism. Big thanks goes to Markus Tripplesdorf for tirelessly testing patches, and to Sergey Senozhatsky for helping find the real issue. Reported-by: Markus Tripplesdorf Signed-off-by: Jens Axboe --- block/blk-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'block') diff --git a/block/blk-core.c b/block/blk-core.c index 59b5c00..64e96ee 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2702,7 +2702,10 @@ static void flush_plug_list(struct blk_plug *plug) /* * rq is already accounted, so use raw insert */ - __elv_add_request(q, rq, ELEVATOR_INSERT_SORT_MERGE); + if (rq->cmd_flags & (REQ_FLUSH | REQ_FUA)) + __elv_add_request(q, rq, ELEVATOR_INSERT_FLUSH); + else + __elv_add_request(q, rq, ELEVATOR_INSERT_SORT_MERGE); } if (q) { -- cgit v1.1