Commit 9e31bebe authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

amiflop: dequeue in-flight request

Request processing in amiflop is done sequentially in
redo_fd_request() proper and redo_fd_request() can easily be converted
to track in-flight request.  Remove CURRENT, track in-flight request
directly and dequeue it when processing starts.

[ 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 10e1e629
...@@ -112,8 +112,6 @@ module_param(fd_def_df0, ulong, 0); ...@@ -112,8 +112,6 @@ module_param(fd_def_df0, ulong, 0);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static struct request_queue *floppy_queue; static struct request_queue *floppy_queue;
#define QUEUE (floppy_queue)
#define CURRENT elv_next_request(floppy_queue)
/* /*
* Macros * Macros
...@@ -1335,59 +1333,61 @@ static int get_track(int drive, int track) ...@@ -1335,59 +1333,61 @@ static int get_track(int drive, int track)
static void redo_fd_request(void) static void redo_fd_request(void)
{ {
struct request *rq;
unsigned int cnt, block, track, sector; unsigned int cnt, block, track, sector;
int drive; int drive;
struct amiga_floppy_struct *floppy; struct amiga_floppy_struct *floppy;
char *data; char *data;
unsigned long flags; unsigned long flags;
int err;
repeat: next_req:
if (!CURRENT) { rq = elv_next_request(floppy_queue);
if (!rq) {
/* Nothing left to do */ /* Nothing left to do */
return; return;
} }
blkdev_dequeue_request(rq);
floppy = CURRENT->rq_disk->private_data; floppy = rq->rq_disk->private_data;
drive = floppy - unit; drive = floppy - unit;
next_segment:
/* Here someone could investigate to be more efficient */ /* Here someone could investigate to be more efficient */
for (cnt = 0; cnt < blk_rq_cur_sectors(CURRENT); cnt++) { for (cnt = 0, err = 0; cnt < blk_rq_cur_sectors(rq); cnt++) {
#ifdef DEBUG #ifdef DEBUG
printk("fd: sector %ld + %d requested for %s\n", printk("fd: sector %ld + %d requested for %s\n",
blk_rq_pos(CURRENT), cnt, blk_rq_pos(rq), cnt,
(rq_data_dir(CURRENT) == READ) ? "read" : "write"); (rq_data_dir(rq) == READ) ? "read" : "write");
#endif #endif
block = blk_rq_pos(CURRENT) + cnt; block = blk_rq_pos(rq) + cnt;
if ((int)block > floppy->blocks) { if ((int)block > floppy->blocks) {
__blk_end_request_cur(CURRENT, -EIO); err = -EIO;
goto repeat; break;
} }
track = block / (floppy->dtype->sects * floppy->type->sect_mult); track = block / (floppy->dtype->sects * floppy->type->sect_mult);
sector = block % (floppy->dtype->sects * floppy->type->sect_mult); sector = block % (floppy->dtype->sects * floppy->type->sect_mult);
data = CURRENT->buffer + 512 * cnt; data = rq->buffer + 512 * cnt;
#ifdef DEBUG #ifdef DEBUG
printk("access to track %d, sector %d, with buffer at " printk("access to track %d, sector %d, with buffer at "
"0x%08lx\n", track, sector, data); "0x%08lx\n", track, sector, data);
#endif #endif
if (get_track(drive, track) == -1) { if (get_track(drive, track) == -1) {
__blk_end_request_cur(CURRENT, -EIO); err = -EIO;
goto repeat; break;
} }
switch (rq_data_dir(CURRENT)) { if (rq_data_dir(rq) == READ) {
case READ:
memcpy(data, floppy->trackbuf + sector * 512, 512); memcpy(data, floppy->trackbuf + sector * 512, 512);
break; } else {
case WRITE:
memcpy(floppy->trackbuf + sector * 512, data, 512); memcpy(floppy->trackbuf + sector * 512, data, 512);
/* keep the drive spinning while writes are scheduled */ /* keep the drive spinning while writes are scheduled */
if (!fd_motor_on(drive)) { if (!fd_motor_on(drive)) {
__blk_end_request_cur(CURRENT, -EIO); err = -EIO;
goto repeat; break;
} }
/* /*
* setup a callback to write the track buffer * setup a callback to write the track buffer
...@@ -1399,12 +1399,12 @@ static void redo_fd_request(void) ...@@ -1399,12 +1399,12 @@ static void redo_fd_request(void)
/* reset the timer */ /* reset the timer */
mod_timer (flush_track_timer + drive, jiffies + 1); mod_timer (flush_track_timer + drive, jiffies + 1);
local_irq_restore(flags); local_irq_restore(flags);
break;
} }
} }
__blk_end_request_cur(CURRENT, 0); if (__blk_end_request_cur(rq, err))
goto repeat; goto next_segment;
goto next_req;
} }
static void do_fd_request(struct request_queue * q) static void do_fd_request(struct request_queue * q)
......
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