aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-05-07 22:54:03 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-05-11 03:52:15 -0400
commita336ca6fe6e0c46b2eef0e520951acb4e6cb2976 (patch)
treec981d2eab7610e0c35d00a567a21250e137291d6 /drivers/block
parent8a12c4a456c7ee261a85c2cbec835601e6aae05a (diff)
ataflop: dequeue and track in-flight request
ataflop has single request in flight. Till now, whenever it needs to access the in-flight request it called elv_next_request(). This patch makes ataflop track the in-flight request directly and dequeue it when processing starts. The added complexity is minimal and this will help future block layer changes. [ Impact: dequeue in-flight request, one elv_next_request() per request ] Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/ataflop.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 234024cda5ec..89a591d9c83b 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -79,9 +79,7 @@
79#undef DEBUG 79#undef DEBUG
80 80
81static struct request_queue *floppy_queue; 81static struct request_queue *floppy_queue;
82 82static struct request *fd_request;
83#define QUEUE (floppy_queue)
84#define CURRENT elv_next_request(floppy_queue)
85 83
86/* Disk types: DD, HD, ED */ 84/* Disk types: DD, HD, ED */
87static struct atari_disk_type { 85static struct atari_disk_type {
@@ -376,6 +374,12 @@ static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0);
376static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0); 374static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0);
377static DEFINE_TIMER(fd_timer, check_change, 0, 0); 375static DEFINE_TIMER(fd_timer, check_change, 0, 0);
378 376
377static void fd_end_request_cur(int err)
378{
379 if (!__blk_end_request_cur(fd_request, err))
380 fd_request = NULL;
381}
382
379static inline void start_motor_off_timer(void) 383static inline void start_motor_off_timer(void)
380{ 384{
381 mod_timer(&motor_off_timer, jiffies + FD_MOTOR_OFF_DELAY); 385 mod_timer(&motor_off_timer, jiffies + FD_MOTOR_OFF_DELAY);
@@ -606,15 +610,15 @@ static void fd_error( void )
606 return; 610 return;
607 } 611 }
608 612
609 if (!CURRENT) 613 if (!fd_request)
610 return; 614 return;
611 615
612 CURRENT->errors++; 616 fd_request->errors++;
613 if (CURRENT->errors >= MAX_ERRORS) { 617 if (fd_request->errors >= MAX_ERRORS) {
614 printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive ); 618 printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive );
615 __blk_end_request_cur(CURRENT, -EIO); 619 fd_end_request_cur(-EIO);
616 } 620 }
617 else if (CURRENT->errors == RECALIBRATE_ERRORS) { 621 else if (fd_request->errors == RECALIBRATE_ERRORS) {
618 printk(KERN_WARNING "fd%d: recalibrating\n", SelectedDrive ); 622 printk(KERN_WARNING "fd%d: recalibrating\n", SelectedDrive );
619 if (SelectedDrive != -1) 623 if (SelectedDrive != -1)
620 SUD.track = -1; 624 SUD.track = -1;
@@ -725,14 +729,14 @@ static void do_fd_action( int drive )
725 if (IS_BUFFERED( drive, ReqSide, ReqTrack )) { 729 if (IS_BUFFERED( drive, ReqSide, ReqTrack )) {
726 if (ReqCmd == READ) { 730 if (ReqCmd == READ) {
727 copy_buffer( SECTOR_BUFFER(ReqSector), ReqData ); 731 copy_buffer( SECTOR_BUFFER(ReqSector), ReqData );
728 if (++ReqCnt < blk_rq_cur_sectors(CURRENT)) { 732 if (++ReqCnt < blk_rq_cur_sectors(fd_request)) {
729 /* read next sector */ 733 /* read next sector */
730 setup_req_params( drive ); 734 setup_req_params( drive );
731 goto repeat; 735 goto repeat;
732 } 736 }
733 else { 737 else {
734 /* all sectors finished */ 738 /* all sectors finished */
735 __blk_end_request_cur(CURRENT, 0); 739 fd_end_request_cur(0);
736 redo_fd_request(); 740 redo_fd_request();
737 return; 741 return;
738 } 742 }
@@ -1130,14 +1134,14 @@ static void fd_rwsec_done1(int status)
1130 } 1134 }
1131 } 1135 }
1132 1136
1133 if (++ReqCnt < blk_rq_cur_sectors(CURRENT)) { 1137 if (++ReqCnt < blk_rq_cur_sectors(fd_request)) {
1134 /* read next sector */ 1138 /* read next sector */
1135 setup_req_params( SelectedDrive ); 1139 setup_req_params( SelectedDrive );
1136 do_fd_action( SelectedDrive ); 1140 do_fd_action( SelectedDrive );
1137 } 1141 }
1138 else { 1142 else {
1139 /* all sectors finished */ 1143 /* all sectors finished */
1140 __blk_end_request_cur(CURRENT, 0); 1144 fd_end_request_cur(0);
1141 redo_fd_request(); 1145 redo_fd_request();
1142 } 1146 }
1143 return; 1147 return;
@@ -1378,7 +1382,7 @@ static void setup_req_params( int drive )
1378 ReqData = ReqBuffer + 512 * ReqCnt; 1382 ReqData = ReqBuffer + 512 * ReqCnt;
1379 1383
1380 if (UseTrackbuffer) 1384 if (UseTrackbuffer)
1381 read_track = (ReqCmd == READ && CURRENT->errors == 0); 1385 read_track = (ReqCmd == READ && fd_request->errors == 0);
1382 else 1386 else
1383 read_track = 0; 1387 read_track = 0;
1384 1388
@@ -1392,25 +1396,28 @@ static void redo_fd_request(void)
1392 int drive, type; 1396 int drive, type;
1393 struct atari_floppy_struct *floppy; 1397 struct atari_floppy_struct *floppy;
1394 1398
1395 DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n", 1399 DPRINT(("redo_fd_request: fd_request=%p dev=%s fd_request->sector=%ld\n",
1396 CURRENT, CURRENT ? CURRENT->rq_disk->disk_name : "", 1400 fd_request, fd_request ? fd_request->rq_disk->disk_name : "",
1397 CURRENT ? blk_rq_pos(CURRENT) : 0 )); 1401 fd_request ? blk_rq_pos(fd_request) : 0 ));
1398 1402
1399 IsFormatting = 0; 1403 IsFormatting = 0;
1400 1404
1401repeat: 1405repeat:
1406 if (!fd_request) {
1407 fd_request = elv_next_request(floppy_queue);
1408 if (!fd_request)
1409 goto the_end;
1410 blkdev_dequeue_request(fd_request);
1411 }
1402 1412
1403 if (!CURRENT) 1413 floppy = fd_request->rq_disk->private_data;
1404 goto the_end;
1405
1406 floppy = CURRENT->rq_disk->private_data;
1407 drive = floppy - unit; 1414 drive = floppy - unit;
1408 type = floppy->type; 1415 type = floppy->type;
1409 1416
1410 if (!UD.connected) { 1417 if (!UD.connected) {
1411 /* drive not connected */ 1418 /* drive not connected */
1412 printk(KERN_ERR "Unknown Device: fd%d\n", drive ); 1419 printk(KERN_ERR "Unknown Device: fd%d\n", drive );
1413 __blk_end_request_cur(CURRENT, -EIO); 1420 fd_end_request_cur(-EIO);
1414 goto repeat; 1421 goto repeat;
1415 } 1422 }
1416 1423
@@ -1426,12 +1433,12 @@ repeat:
1426 /* user supplied disk type */ 1433 /* user supplied disk type */
1427 if (--type >= NUM_DISK_MINORS) { 1434 if (--type >= NUM_DISK_MINORS) {
1428 printk(KERN_WARNING "fd%d: invalid disk format", drive ); 1435 printk(KERN_WARNING "fd%d: invalid disk format", drive );
1429 __blk_end_request_cur(CURRENT, -EIO); 1436 fd_end_request_cur(-EIO);
1430 goto repeat; 1437 goto repeat;
1431 } 1438 }
1432 if (minor2disktype[type].drive_types > DriveType) { 1439 if (minor2disktype[type].drive_types > DriveType) {
1433 printk(KERN_WARNING "fd%d: unsupported disk format", drive ); 1440 printk(KERN_WARNING "fd%d: unsupported disk format", drive );
1434 __blk_end_request_cur(CURRENT, -EIO); 1441 fd_end_request_cur(-EIO);
1435 goto repeat; 1442 goto repeat;
1436 } 1443 }
1437 type = minor2disktype[type].index; 1444 type = minor2disktype[type].index;
@@ -1440,8 +1447,8 @@ repeat:
1440 UD.autoprobe = 0; 1447 UD.autoprobe = 0;
1441 } 1448 }
1442 1449
1443 if (blk_rq_pos(CURRENT) + 1 > UDT->blocks) { 1450 if (blk_rq_pos(fd_request) + 1 > UDT->blocks) {
1444 __blk_end_request_cur(CURRENT, -EIO); 1451 fd_end_request_cur(-EIO);
1445 goto repeat; 1452 goto repeat;
1446 } 1453 }
1447 1454
@@ -1449,9 +1456,9 @@ repeat:
1449 del_timer( &motor_off_timer ); 1456 del_timer( &motor_off_timer );
1450 1457
1451 ReqCnt = 0; 1458 ReqCnt = 0;
1452 ReqCmd = rq_data_dir(CURRENT); 1459 ReqCmd = rq_data_dir(fd_request);
1453 ReqBlock = blk_rq_pos(CURRENT); 1460 ReqBlock = blk_rq_pos(fd_request);
1454 ReqBuffer = CURRENT->buffer; 1461 ReqBuffer = fd_request->buffer;
1455 setup_req_params( drive ); 1462 setup_req_params( drive );
1456 do_fd_action( drive ); 1463 do_fd_action( drive );
1457 1464