aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-05-07 22:54:04 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-05-11 03:52:15 -0400
commitf4bd4b90bfa86e867111aa182895cb5ac203aa7a (patch)
tree266012f2dca07677b93e1c545f42fd1ede3d9d3d /drivers/block
parenta336ca6fe6e0c46b2eef0e520951acb4e6cb2976 (diff)
swim3: dequeue in-flight request
swim3 has at most single request in flight and already tracks it using fd_req. Convert it to dequeuing model by updating request fetching and wrapping completion function. [ Impact: dequeue in-flight 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/swim3.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index c1b9a4dc11ba..f48c6dd47e04 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -251,6 +251,20 @@ static int floppy_release(struct gendisk *disk, fmode_t mode);
251static int floppy_check_change(struct gendisk *disk); 251static int floppy_check_change(struct gendisk *disk);
252static int floppy_revalidate(struct gendisk *disk); 252static int floppy_revalidate(struct gendisk *disk);
253 253
254static bool swim3_end_request(int err, unsigned int nr_bytes)
255{
256 if (__blk_end_request(fd_req, err, nr_bytes))
257 return true;
258
259 fd_req = NULL;
260 return false;
261}
262
263static bool swim3_end_request_cur(int err)
264{
265 return swim3_end_request(err, blk_rq_cur_bytes(fd_req));
266}
267
254static void swim3_select(struct floppy_state *fs, int sel) 268static void swim3_select(struct floppy_state *fs, int sel)
255{ 269{
256 struct swim3 __iomem *sw = fs->swim3; 270 struct swim3 __iomem *sw = fs->swim3;
@@ -310,7 +324,14 @@ static void start_request(struct floppy_state *fs)
310 wake_up(&fs->wait); 324 wake_up(&fs->wait);
311 return; 325 return;
312 } 326 }
313 while (fs->state == idle && (req = elv_next_request(swim3_queue))) { 327 while (fs->state == idle) {
328 if (!fd_req) {
329 fd_req = elv_next_request(swim3_queue);
330 if (!fd_req)
331 break;
332 blkdev_dequeue_request(fd_req);
333 }
334 req = fd_req;
314#if 0 335#if 0
315 printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%u buf=%p\n", 336 printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%u buf=%p\n",
316 req->rq_disk->disk_name, req->cmd, 337 req->rq_disk->disk_name, req->cmd,
@@ -320,11 +341,11 @@ static void start_request(struct floppy_state *fs)
320#endif 341#endif
321 342
322 if (blk_rq_pos(req) >= fs->total_secs) { 343 if (blk_rq_pos(req) >= fs->total_secs) {
323 __blk_end_request_cur(req, -EIO); 344 swim3_end_request_cur(-EIO);
324 continue; 345 continue;
325 } 346 }
326 if (fs->ejected) { 347 if (fs->ejected) {
327 __blk_end_request_cur(req, -EIO); 348 swim3_end_request_cur(-EIO);
328 continue; 349 continue;
329 } 350 }
330 351
@@ -332,7 +353,7 @@ static void start_request(struct floppy_state *fs)
332 if (fs->write_prot < 0) 353 if (fs->write_prot < 0)
333 fs->write_prot = swim3_readbit(fs, WRITE_PROT); 354 fs->write_prot = swim3_readbit(fs, WRITE_PROT);
334 if (fs->write_prot) { 355 if (fs->write_prot) {
335 __blk_end_request_cur(req, -EIO); 356 swim3_end_request_cur(-EIO);
336 continue; 357 continue;
337 } 358 }
338 } 359 }
@@ -505,7 +526,7 @@ static void act(struct floppy_state *fs)
505 case do_transfer: 526 case do_transfer:
506 if (fs->cur_cyl != fs->req_cyl) { 527 if (fs->cur_cyl != fs->req_cyl) {
507 if (fs->retries > 5) { 528 if (fs->retries > 5) {
508 __blk_end_request_cur(fd_req, -EIO); 529 swim3_end_request_cur(-EIO);
509 fs->state = idle; 530 fs->state = idle;
510 return; 531 return;
511 } 532 }
@@ -537,7 +558,7 @@ static void scan_timeout(unsigned long data)
537 out_8(&sw->intr_enable, 0); 558 out_8(&sw->intr_enable, 0);
538 fs->cur_cyl = -1; 559 fs->cur_cyl = -1;
539 if (fs->retries > 5) { 560 if (fs->retries > 5) {
540 __blk_end_request_cur(fd_req, -EIO); 561 swim3_end_request_cur(-EIO);
541 fs->state = idle; 562 fs->state = idle;
542 start_request(fs); 563 start_request(fs);
543 } else { 564 } else {
@@ -556,7 +577,7 @@ static void seek_timeout(unsigned long data)
556 out_8(&sw->select, RELAX); 577 out_8(&sw->select, RELAX);
557 out_8(&sw->intr_enable, 0); 578 out_8(&sw->intr_enable, 0);
558 printk(KERN_ERR "swim3: seek timeout\n"); 579 printk(KERN_ERR "swim3: seek timeout\n");
559 __blk_end_request_cur(fd_req, -EIO); 580 swim3_end_request_cur(-EIO);
560 fs->state = idle; 581 fs->state = idle;
561 start_request(fs); 582 start_request(fs);
562} 583}
@@ -580,7 +601,7 @@ static void settle_timeout(unsigned long data)
580 return; 601 return;
581 } 602 }
582 printk(KERN_ERR "swim3: seek settle timeout\n"); 603 printk(KERN_ERR "swim3: seek settle timeout\n");
583 __blk_end_request_cur(fd_req, -EIO); 604 swim3_end_request_cur(-EIO);
584 fs->state = idle; 605 fs->state = idle;
585 start_request(fs); 606 start_request(fs);
586} 607}
@@ -603,7 +624,7 @@ static void xfer_timeout(unsigned long data)
603 printk(KERN_ERR "swim3: timeout %sing sector %ld\n", 624 printk(KERN_ERR "swim3: timeout %sing sector %ld\n",
604 (rq_data_dir(fd_req)==WRITE? "writ": "read"), 625 (rq_data_dir(fd_req)==WRITE? "writ": "read"),
605 (long)blk_rq_pos(fd_req)); 626 (long)blk_rq_pos(fd_req));
606 __blk_end_request_cur(fd_req, -EIO); 627 swim3_end_request_cur(-EIO);
607 fs->state = idle; 628 fs->state = idle;
608 start_request(fs); 629 start_request(fs);
609} 630}
@@ -634,7 +655,7 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
634 printk(KERN_ERR "swim3: seen sector but cyl=ff?\n"); 655 printk(KERN_ERR "swim3: seen sector but cyl=ff?\n");
635 fs->cur_cyl = -1; 656 fs->cur_cyl = -1;
636 if (fs->retries > 5) { 657 if (fs->retries > 5) {
637 __blk_end_request_cur(fd_req, -EIO); 658 swim3_end_request_cur(-EIO);
638 fs->state = idle; 659 fs->state = idle;
639 start_request(fs); 660 start_request(fs);
640 } else { 661 } else {
@@ -717,7 +738,7 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
717 printk("swim3: error %sing block %ld (err=%x)\n", 738 printk("swim3: error %sing block %ld (err=%x)\n",
718 rq_data_dir(fd_req) == WRITE? "writ": "read", 739 rq_data_dir(fd_req) == WRITE? "writ": "read",
719 (long)blk_rq_pos(fd_req), err); 740 (long)blk_rq_pos(fd_req), err);
720 __blk_end_request_cur(fd_req, -EIO); 741 swim3_end_request_cur(-EIO);
721 fs->state = idle; 742 fs->state = idle;
722 } 743 }
723 } else { 744 } else {
@@ -726,12 +747,12 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
726 printk(KERN_ERR "swim3: fd dma: stat=%x resid=%d\n", stat, resid); 747 printk(KERN_ERR "swim3: fd dma: stat=%x resid=%d\n", stat, resid);
727 printk(KERN_ERR " state=%d, dir=%x, intr=%x, err=%x\n", 748 printk(KERN_ERR " state=%d, dir=%x, intr=%x, err=%x\n",
728 fs->state, rq_data_dir(fd_req), intr, err); 749 fs->state, rq_data_dir(fd_req), intr, err);
729 __blk_end_request_cur(fd_req, -EIO); 750 swim3_end_request_cur(-EIO);
730 fs->state = idle; 751 fs->state = idle;
731 start_request(fs); 752 start_request(fs);
732 break; 753 break;
733 } 754 }
734 if (__blk_end_request(fd_req, 0, fs->scount << 9)) { 755 if (swim3_end_request(0, fs->scount << 9)) {
735 fs->req_sector += fs->scount; 756 fs->req_sector += fs->scount;
736 if (fs->req_sector > fs->secpertrack) { 757 if (fs->req_sector > fs->secpertrack) {
737 fs->req_sector -= fs->secpertrack; 758 fs->req_sector -= fs->secpertrack;