diff options
author | Tejun Heo <tj@kernel.org> | 2009-05-07 22:54:08 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-05-11 03:52:16 -0400 |
commit | 9e31bebee2d8b5f8abe9677f2a29b90cba848657 (patch) | |
tree | b9c159c187411db33a5d6169c520f31551f78ad8 | |
parent | 10e1e629b386aef97bf66de6ef28d450bec06ee3 (diff) |
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: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | drivers/block/amiflop.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index e4a14b94828e..80a68b2e0451 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c | |||
@@ -112,8 +112,6 @@ module_param(fd_def_df0, ulong, 0); | |||
112 | MODULE_LICENSE("GPL"); | 112 | MODULE_LICENSE("GPL"); |
113 | 113 | ||
114 | static struct request_queue *floppy_queue; | 114 | static struct request_queue *floppy_queue; |
115 | #define QUEUE (floppy_queue) | ||
116 | #define CURRENT elv_next_request(floppy_queue) | ||
117 | 115 | ||
118 | /* | 116 | /* |
119 | * Macros | 117 | * Macros |
@@ -1335,59 +1333,61 @@ static int get_track(int drive, int track) | |||
1335 | 1333 | ||
1336 | static void redo_fd_request(void) | 1334 | static void redo_fd_request(void) |
1337 | { | 1335 | { |
1336 | struct request *rq; | ||
1338 | unsigned int cnt, block, track, sector; | 1337 | unsigned int cnt, block, track, sector; |
1339 | int drive; | 1338 | int drive; |
1340 | struct amiga_floppy_struct *floppy; | 1339 | struct amiga_floppy_struct *floppy; |
1341 | char *data; | 1340 | char *data; |
1342 | unsigned long flags; | 1341 | unsigned long flags; |
1342 | int err; | ||
1343 | 1343 | ||
1344 | repeat: | 1344 | next_req: |
1345 | if (!CURRENT) { | 1345 | rq = elv_next_request(floppy_queue); |
1346 | if (!rq) { | ||
1346 | /* Nothing left to do */ | 1347 | /* Nothing left to do */ |
1347 | return; | 1348 | return; |
1348 | } | 1349 | } |
1350 | blkdev_dequeue_request(rq); | ||
1349 | 1351 | ||
1350 | floppy = CURRENT->rq_disk->private_data; | 1352 | floppy = rq->rq_disk->private_data; |
1351 | drive = floppy - unit; | 1353 | drive = floppy - unit; |
1352 | 1354 | ||
1355 | next_segment: | ||
1353 | /* Here someone could investigate to be more efficient */ | 1356 | /* Here someone could investigate to be more efficient */ |
1354 | for (cnt = 0; cnt < blk_rq_cur_sectors(CURRENT); cnt++) { | 1357 | for (cnt = 0, err = 0; cnt < blk_rq_cur_sectors(rq); cnt++) { |
1355 | #ifdef DEBUG | 1358 | #ifdef DEBUG |
1356 | printk("fd: sector %ld + %d requested for %s\n", | 1359 | printk("fd: sector %ld + %d requested for %s\n", |
1357 | blk_rq_pos(CURRENT), cnt, | 1360 | blk_rq_pos(rq), cnt, |
1358 | (rq_data_dir(CURRENT) == READ) ? "read" : "write"); | 1361 | (rq_data_dir(rq) == READ) ? "read" : "write"); |
1359 | #endif | 1362 | #endif |
1360 | block = blk_rq_pos(CURRENT) + cnt; | 1363 | block = blk_rq_pos(rq) + cnt; |
1361 | if ((int)block > floppy->blocks) { | 1364 | if ((int)block > floppy->blocks) { |
1362 | __blk_end_request_cur(CURRENT, -EIO); | 1365 | err = -EIO; |
1363 | goto repeat; | 1366 | break; |
1364 | } | 1367 | } |
1365 | 1368 | ||
1366 | track = block / (floppy->dtype->sects * floppy->type->sect_mult); | 1369 | track = block / (floppy->dtype->sects * floppy->type->sect_mult); |
1367 | sector = block % (floppy->dtype->sects * floppy->type->sect_mult); | 1370 | sector = block % (floppy->dtype->sects * floppy->type->sect_mult); |
1368 | data = CURRENT->buffer + 512 * cnt; | 1371 | data = rq->buffer + 512 * cnt; |
1369 | #ifdef DEBUG | 1372 | #ifdef DEBUG |
1370 | printk("access to track %d, sector %d, with buffer at " | 1373 | printk("access to track %d, sector %d, with buffer at " |
1371 | "0x%08lx\n", track, sector, data); | 1374 | "0x%08lx\n", track, sector, data); |
1372 | #endif | 1375 | #endif |
1373 | 1376 | ||
1374 | if (get_track(drive, track) == -1) { | 1377 | if (get_track(drive, track) == -1) { |
1375 | __blk_end_request_cur(CURRENT, -EIO); | 1378 | err = -EIO; |
1376 | goto repeat; | 1379 | break; |
1377 | } | 1380 | } |
1378 | 1381 | ||
1379 | switch (rq_data_dir(CURRENT)) { | 1382 | if (rq_data_dir(rq) == READ) { |
1380 | case READ: | ||
1381 | memcpy(data, floppy->trackbuf + sector * 512, 512); | 1383 | memcpy(data, floppy->trackbuf + sector * 512, 512); |
1382 | break; | 1384 | } else { |
1383 | |||
1384 | case WRITE: | ||
1385 | memcpy(floppy->trackbuf + sector * 512, data, 512); | 1385 | memcpy(floppy->trackbuf + sector * 512, data, 512); |
1386 | 1386 | ||
1387 | /* keep the drive spinning while writes are scheduled */ | 1387 | /* keep the drive spinning while writes are scheduled */ |
1388 | if (!fd_motor_on(drive)) { | 1388 | if (!fd_motor_on(drive)) { |
1389 | __blk_end_request_cur(CURRENT, -EIO); | 1389 | err = -EIO; |
1390 | goto repeat; | 1390 | break; |
1391 | } | 1391 | } |
1392 | /* | 1392 | /* |
1393 | * setup a callback to write the track buffer | 1393 | * setup a callback to write the track buffer |
@@ -1399,12 +1399,12 @@ static void redo_fd_request(void) | |||
1399 | /* reset the timer */ | 1399 | /* reset the timer */ |
1400 | mod_timer (flush_track_timer + drive, jiffies + 1); | 1400 | mod_timer (flush_track_timer + drive, jiffies + 1); |
1401 | local_irq_restore(flags); | 1401 | local_irq_restore(flags); |
1402 | break; | ||
1403 | } | 1402 | } |
1404 | } | 1403 | } |
1405 | 1404 | ||
1406 | __blk_end_request_cur(CURRENT, 0); | 1405 | if (__blk_end_request_cur(rq, err)) |
1407 | goto repeat; | 1406 | goto next_segment; |
1407 | goto next_req; | ||
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | static void do_fd_request(struct request_queue * q) | 1410 | static void do_fd_request(struct request_queue * q) |