Skip to content

Commit e091eb6

Browse files
htejunJens Axboe
authored andcommitted
hd: clean up request completion paths
hd read/write_intr() functions manually manipulate request to incrementally complete it, which block layer already supports. Simply use block layer completion routines instead of manual partial completion. While at it, clear unnecessary elv_next_request() check at the tail of read_intr(). This also makes read and write_intr() more consistent. [ Impact: cleanup ] Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent f81f2f7 commit e091eb6

1 file changed

Lines changed: 12 additions & 24 deletions

File tree

‎drivers/block/hd.c‎

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -452,32 +452,25 @@ static void read_intr(void)
452452
bad_rw_intr();
453453
hd_request();
454454
return;
455+
455456
ok_to_read:
456457
req = CURRENT;
457458
insw(HD_DATA, req->buffer, 256);
458-
req->sector++;
459-
req->buffer += 512;
460-
req->errors = 0;
461-
i = --req->nr_sectors;
462-
--req->current_nr_sectors;
463459
#ifdef DEBUG
464460
printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
465-
req->rq_disk->disk_name, req->sector, req->nr_sectors,
461+
req->rq_disk->disk_name, req->sector + 1, req->nr_sectors - 1,
466462
req->buffer+512);
467463
#endif
468-
if (req->current_nr_sectors <= 0)
469-
__blk_end_request_cur(req, 0);
470-
if (i > 0) {
464+
if (__blk_end_request(req, 0, 512)) {
471465
SET_HANDLER(&read_intr);
472466
return;
473467
}
468+
474469
(void) inb_p(HD_STATUS);
475470
#if (HD_DELAY > 0)
476471
last_req = read_timer();
477472
#endif
478-
if (elv_next_request(QUEUE))
479-
hd_request();
480-
return;
473+
hd_request();
481474
}
482475

483476
static void write_intr(void)
@@ -499,23 +492,18 @@ static void write_intr(void)
499492
bad_rw_intr();
500493
hd_request();
501494
return;
495+
502496
ok_to_write:
503-
req->sector++;
504-
i = --req->nr_sectors;
505-
--req->current_nr_sectors;
506-
req->buffer += 512;
507-
if (!i || (req->bio && req->current_nr_sectors <= 0))
508-
__blk_end_request_cur(req, 0);
509-
if (i > 0) {
497+
if (__blk_end_request(req, 0, 512)) {
510498
SET_HANDLER(&write_intr);
511499
outsw(HD_DATA, req->buffer, 256);
512-
} else {
500+
return;
501+
}
502+
513503
#if (HD_DELAY > 0)
514-
last_req = read_timer();
504+
last_req = read_timer();
515505
#endif
516-
hd_request();
517-
}
518-
return;
506+
hd_request();
519507
}
520508

521509
static void recal_intr(void)

0 commit comments

Comments
 (0)