提交 06b0608e 编写于 作者: T Tejun Heo 提交者: Jens Axboe

swim: dequeue in-flight request

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

[ Impact: dequeue in-flight request ]
Signed-off-by: NTejun Heo <tj@kernel.org>
Cc: Laurent Vivier <Laurent@lvivier.info>
Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
上级 9e31bebe
...@@ -514,7 +514,7 @@ static int floppy_read_sectors(struct floppy_state *fs, ...@@ -514,7 +514,7 @@ static int floppy_read_sectors(struct floppy_state *fs,
ret = swim_read_sector(fs, side, track, sector, ret = swim_read_sector(fs, side, track, sector,
buffer); buffer);
if (try-- == 0) if (try-- == 0)
return -1; return -EIO;
} while (ret != 512); } while (ret != 512);
buffer += ret; buffer += ret;
...@@ -528,38 +528,37 @@ static void redo_fd_request(struct request_queue *q) ...@@ -528,38 +528,37 @@ static void redo_fd_request(struct request_queue *q)
struct request *req; struct request *req;
struct floppy_state *fs; struct floppy_state *fs;
while ((req = elv_next_request(q))) { req = elv_next_request(q);
if (req)
blkdev_dequeue_request(req);
while (req) {
int err = -EIO;
fs = req->rq_disk->private_data; fs = req->rq_disk->private_data;
if (blk_rq_pos(req) >= fs->total_secs) { if (blk_rq_pos(req) >= fs->total_secs)
__blk_end_request_cur(req, -EIO); goto done;
continue; if (!fs->disk_in)
} goto done;
if (!fs->disk_in) { if (rq_data_dir(req) == WRITE && fs->write_protected)
__blk_end_request_cur(req, -EIO); goto done;
continue;
}
if (rq_data_dir(req) == WRITE) {
if (fs->write_protected) {
__blk_end_request_cur(req, -EIO);
continue;
}
}
switch (rq_data_dir(req)) { switch (rq_data_dir(req)) {
case WRITE: case WRITE:
/* NOT IMPLEMENTED */ /* NOT IMPLEMENTED */
__blk_end_request_cur(req, -EIO);
break; break;
case READ: case READ:
if (floppy_read_sectors(fs, blk_rq_pos(req), err = floppy_read_sectors(fs, blk_rq_pos(req),
blk_rq_cur_sectors(req), blk_rq_cur_sectors(req),
req->buffer)) { req->buffer);
__blk_end_request_cur(req, -EIO);
continue;
}
__blk_end_request_cur(req, 0);
break; break;
} }
done:
if (!__blk_end_request_cur(req, err)) {
req = elv_next_request(q);
if (req)
blkdev_dequeue_request(req);
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册