Commit fb3ac7f6 authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

z2ram: dequeue in-flight request

z2ram processes requests one-by-one synchronously and can be easily
converted to dequeueing model.  Convert it.

[ Impact: dequeue in-flight request ]
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 6b0bf407
...@@ -70,15 +70,21 @@ static struct gendisk *z2ram_gendisk; ...@@ -70,15 +70,21 @@ static struct gendisk *z2ram_gendisk;
static void do_z2_request(struct request_queue *q) static void do_z2_request(struct request_queue *q)
{ {
struct request *req; struct request *req;
while ((req = elv_next_request(q)) != NULL) {
req = elv_next_request(q);
if (req)
blkdev_dequeue_request(req);
while (req) {
unsigned long start = blk_rq_pos(req) << 9; unsigned long start = blk_rq_pos(req) << 9;
unsigned long len = blk_rq_cur_bytes(req); unsigned long len = blk_rq_cur_bytes(req);
int err = 0;
if (start + len > z2ram_size) { if (start + len > z2ram_size) {
printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n", printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n",
blk_rq_pos(req), blk_rq_cur_sectors(req)); blk_rq_pos(req), blk_rq_cur_sectors(req));
__blk_end_request_cur(req, -EIO); err = -EIO;
continue; goto done;
} }
while (len) { while (len) {
unsigned long addr = start & Z2RAM_CHUNKMASK; unsigned long addr = start & Z2RAM_CHUNKMASK;
...@@ -93,7 +99,12 @@ static void do_z2_request(struct request_queue *q) ...@@ -93,7 +99,12 @@ static void do_z2_request(struct request_queue *q)
start += size; start += size;
len -= size; len -= size;
} }
__blk_end_request_cur(req, 0); done:
if (!__blk_end_request_cur(req, err)) {
req = elv_next_request(q);
if (req)
blkdev_dequeue_request(req);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment