diff options
author | Christoph Hellwig <hch@lst.de> | 2017-01-27 03:46:29 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-01-27 17:08:35 -0500 |
commit | 82ed4db499b8598f16f8871261bff088d6b0597f (patch) | |
tree | e1cc0a433bf5ae2b9723837291617bdfeeb61816 /drivers/ide/ide-tape.c | |
parent | 8ae94eb65be9425af4d57a4f4cfebfdf03081e93 (diff) |
block: split scsi_request out of struct request
And require all drivers that want to support BLOCK_PC to allocate it
as the first thing of their private data. To support this the legacy
IDE and BSG code is switched to set cmd_size on their queues to let
the block layer allocate the additional space.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 9ecf4e35adcd..f6bc1e2bb035 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -282,7 +282,7 @@ static void idetape_analyze_error(ide_drive_t *drive) | |||
282 | 282 | ||
283 | /* correct remaining bytes to transfer */ | 283 | /* correct remaining bytes to transfer */ |
284 | if (pc->flags & PC_FLAG_DMA_ERROR) | 284 | if (pc->flags & PC_FLAG_DMA_ERROR) |
285 | rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]); | 285 | scsi_req(rq)->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]); |
286 | 286 | ||
287 | /* | 287 | /* |
288 | * If error was the result of a zero-length read or write command, | 288 | * If error was the result of a zero-length read or write command, |
@@ -316,7 +316,7 @@ static void idetape_analyze_error(ide_drive_t *drive) | |||
316 | pc->flags |= PC_FLAG_ABORT; | 316 | pc->flags |= PC_FLAG_ABORT; |
317 | } | 317 | } |
318 | if (!(pc->flags & PC_FLAG_ABORT) && | 318 | if (!(pc->flags & PC_FLAG_ABORT) && |
319 | (blk_rq_bytes(rq) - rq->resid_len)) | 319 | (blk_rq_bytes(rq) - scsi_req(rq)->resid_len)) |
320 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; | 320 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; |
321 | } | 321 | } |
322 | } | 322 | } |
@@ -348,7 +348,7 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
348 | "itself - Aborting request!\n"); | 348 | "itself - Aborting request!\n"); |
349 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | 349 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
350 | unsigned int blocks = | 350 | unsigned int blocks = |
351 | (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size; | 351 | (blk_rq_bytes(rq) - scsi_req(rq)->resid_len) / tape->blk_size; |
352 | 352 | ||
353 | tape->avg_size += blocks * tape->blk_size; | 353 | tape->avg_size += blocks * tape->blk_size; |
354 | 354 | ||
@@ -560,7 +560,7 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape, | |||
560 | pc->flags |= PC_FLAG_WRITING; | 560 | pc->flags |= PC_FLAG_WRITING; |
561 | } | 561 | } |
562 | 562 | ||
563 | memcpy(rq->cmd, pc->c, 12); | 563 | memcpy(scsi_req(rq)->cmd, pc->c, 12); |
564 | } | 564 | } |
565 | 565 | ||
566 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, | 566 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, |
@@ -570,10 +570,11 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
570 | idetape_tape_t *tape = drive->driver_data; | 570 | idetape_tape_t *tape = drive->driver_data; |
571 | struct ide_atapi_pc *pc = NULL; | 571 | struct ide_atapi_pc *pc = NULL; |
572 | struct ide_cmd cmd; | 572 | struct ide_cmd cmd; |
573 | struct scsi_request *req = scsi_req(rq); | ||
573 | u8 stat; | 574 | u8 stat; |
574 | 575 | ||
575 | ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u", | 576 | ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u", |
576 | rq->cmd[0], (unsigned long long)blk_rq_pos(rq), | 577 | req->cmd[0], (unsigned long long)blk_rq_pos(rq), |
577 | blk_rq_sectors(rq)); | 578 | blk_rq_sectors(rq)); |
578 | 579 | ||
579 | BUG_ON(!(rq->cmd_type == REQ_TYPE_DRV_PRIV || | 580 | BUG_ON(!(rq->cmd_type == REQ_TYPE_DRV_PRIV || |
@@ -592,7 +593,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
592 | stat = hwif->tp_ops->read_status(hwif); | 593 | stat = hwif->tp_ops->read_status(hwif); |
593 | 594 | ||
594 | if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 && | 595 | if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 && |
595 | (rq->cmd[13] & REQ_IDETAPE_PC2) == 0) | 596 | (req->cmd[13] & REQ_IDETAPE_PC2) == 0) |
596 | drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; | 597 | drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; |
597 | 598 | ||
598 | if (drive->dev_flags & IDE_DFLAG_POST_RESET) { | 599 | if (drive->dev_flags & IDE_DFLAG_POST_RESET) { |
@@ -609,7 +610,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
609 | } else if (time_after(jiffies, tape->dsc_timeout)) { | 610 | } else if (time_after(jiffies, tape->dsc_timeout)) { |
610 | printk(KERN_ERR "ide-tape: %s: DSC timeout\n", | 611 | printk(KERN_ERR "ide-tape: %s: DSC timeout\n", |
611 | tape->name); | 612 | tape->name); |
612 | if (rq->cmd[13] & REQ_IDETAPE_PC2) { | 613 | if (req->cmd[13] & REQ_IDETAPE_PC2) { |
613 | idetape_media_access_finished(drive); | 614 | idetape_media_access_finished(drive); |
614 | return ide_stopped; | 615 | return ide_stopped; |
615 | } else { | 616 | } else { |
@@ -626,23 +627,23 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
626 | tape->postponed_rq = false; | 627 | tape->postponed_rq = false; |
627 | } | 628 | } |
628 | 629 | ||
629 | if (rq->cmd[13] & REQ_IDETAPE_READ) { | 630 | if (req->cmd[13] & REQ_IDETAPE_READ) { |
630 | pc = &tape->queued_pc; | 631 | pc = &tape->queued_pc; |
631 | ide_tape_create_rw_cmd(tape, pc, rq, READ_6); | 632 | ide_tape_create_rw_cmd(tape, pc, rq, READ_6); |
632 | goto out; | 633 | goto out; |
633 | } | 634 | } |
634 | if (rq->cmd[13] & REQ_IDETAPE_WRITE) { | 635 | if (req->cmd[13] & REQ_IDETAPE_WRITE) { |
635 | pc = &tape->queued_pc; | 636 | pc = &tape->queued_pc; |
636 | ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); | 637 | ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); |
637 | goto out; | 638 | goto out; |
638 | } | 639 | } |
639 | if (rq->cmd[13] & REQ_IDETAPE_PC1) { | 640 | if (req->cmd[13] & REQ_IDETAPE_PC1) { |
640 | pc = (struct ide_atapi_pc *)rq->special; | 641 | pc = (struct ide_atapi_pc *)rq->special; |
641 | rq->cmd[13] &= ~(REQ_IDETAPE_PC1); | 642 | req->cmd[13] &= ~(REQ_IDETAPE_PC1); |
642 | rq->cmd[13] |= REQ_IDETAPE_PC2; | 643 | req->cmd[13] |= REQ_IDETAPE_PC2; |
643 | goto out; | 644 | goto out; |
644 | } | 645 | } |
645 | if (rq->cmd[13] & REQ_IDETAPE_PC2) { | 646 | if (req->cmd[13] & REQ_IDETAPE_PC2) { |
646 | idetape_media_access_finished(drive); | 647 | idetape_media_access_finished(drive); |
647 | return ide_stopped; | 648 | return ide_stopped; |
648 | } | 649 | } |
@@ -853,8 +854,9 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) | |||
853 | BUG_ON(size < 0 || size % tape->blk_size); | 854 | BUG_ON(size < 0 || size % tape->blk_size); |
854 | 855 | ||
855 | rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); | 856 | rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); |
857 | scsi_req_init(rq); | ||
856 | rq->cmd_type = REQ_TYPE_DRV_PRIV; | 858 | rq->cmd_type = REQ_TYPE_DRV_PRIV; |
857 | rq->cmd[13] = cmd; | 859 | scsi_req(rq)->cmd[13] = cmd; |
858 | rq->rq_disk = tape->disk; | 860 | rq->rq_disk = tape->disk; |
859 | rq->__sector = tape->first_frame; | 861 | rq->__sector = tape->first_frame; |
860 | 862 | ||
@@ -868,7 +870,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) | |||
868 | blk_execute_rq(drive->queue, tape->disk, rq, 0); | 870 | blk_execute_rq(drive->queue, tape->disk, rq, 0); |
869 | 871 | ||
870 | /* calculate the number of transferred bytes and update buffer state */ | 872 | /* calculate the number of transferred bytes and update buffer state */ |
871 | size -= rq->resid_len; | 873 | size -= scsi_req(rq)->resid_len; |
872 | tape->cur = tape->buf; | 874 | tape->cur = tape->buf; |
873 | if (cmd == REQ_IDETAPE_READ) | 875 | if (cmd == REQ_IDETAPE_READ) |
874 | tape->valid = size; | 876 | tape->valid = size; |