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>
Este cometimento está contido em:

cometido por
Jens Axboe

ascendente
8ae94eb65b
cometimento
82ed4db499
@@ -282,7 +282,7 @@ static void idetape_analyze_error(ide_drive_t *drive)
|
||||
|
||||
/* correct remaining bytes to transfer */
|
||||
if (pc->flags & PC_FLAG_DMA_ERROR)
|
||||
rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]);
|
||||
scsi_req(rq)->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]);
|
||||
|
||||
/*
|
||||
* 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)
|
||||
pc->flags |= PC_FLAG_ABORT;
|
||||
}
|
||||
if (!(pc->flags & PC_FLAG_ABORT) &&
|
||||
(blk_rq_bytes(rq) - rq->resid_len))
|
||||
(blk_rq_bytes(rq) - scsi_req(rq)->resid_len))
|
||||
pc->retries = IDETAPE_MAX_PC_RETRIES + 1;
|
||||
}
|
||||
}
|
||||
@@ -348,7 +348,7 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
|
||||
"itself - Aborting request!\n");
|
||||
} else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
|
||||
unsigned int blocks =
|
||||
(blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size;
|
||||
(blk_rq_bytes(rq) - scsi_req(rq)->resid_len) / tape->blk_size;
|
||||
|
||||
tape->avg_size += blocks * tape->blk_size;
|
||||
|
||||
@@ -560,7 +560,7 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape,
|
||||
pc->flags |= PC_FLAG_WRITING;
|
||||
}
|
||||
|
||||
memcpy(rq->cmd, pc->c, 12);
|
||||
memcpy(scsi_req(rq)->cmd, pc->c, 12);
|
||||
}
|
||||
|
||||
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,
|
||||
idetape_tape_t *tape = drive->driver_data;
|
||||
struct ide_atapi_pc *pc = NULL;
|
||||
struct ide_cmd cmd;
|
||||
struct scsi_request *req = scsi_req(rq);
|
||||
u8 stat;
|
||||
|
||||
ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u",
|
||||
rq->cmd[0], (unsigned long long)blk_rq_pos(rq),
|
||||
req->cmd[0], (unsigned long long)blk_rq_pos(rq),
|
||||
blk_rq_sectors(rq));
|
||||
|
||||
BUG_ON(!(rq->cmd_type == REQ_TYPE_DRV_PRIV ||
|
||||
@@ -592,7 +593,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
|
||||
stat = hwif->tp_ops->read_status(hwif);
|
||||
|
||||
if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 &&
|
||||
(rq->cmd[13] & REQ_IDETAPE_PC2) == 0)
|
||||
(req->cmd[13] & REQ_IDETAPE_PC2) == 0)
|
||||
drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC;
|
||||
|
||||
if (drive->dev_flags & IDE_DFLAG_POST_RESET) {
|
||||
@@ -609,7 +610,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
|
||||
} else if (time_after(jiffies, tape->dsc_timeout)) {
|
||||
printk(KERN_ERR "ide-tape: %s: DSC timeout\n",
|
||||
tape->name);
|
||||
if (rq->cmd[13] & REQ_IDETAPE_PC2) {
|
||||
if (req->cmd[13] & REQ_IDETAPE_PC2) {
|
||||
idetape_media_access_finished(drive);
|
||||
return ide_stopped;
|
||||
} else {
|
||||
@@ -626,23 +627,23 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
|
||||
tape->postponed_rq = false;
|
||||
}
|
||||
|
||||
if (rq->cmd[13] & REQ_IDETAPE_READ) {
|
||||
if (req->cmd[13] & REQ_IDETAPE_READ) {
|
||||
pc = &tape->queued_pc;
|
||||
ide_tape_create_rw_cmd(tape, pc, rq, READ_6);
|
||||
goto out;
|
||||
}
|
||||
if (rq->cmd[13] & REQ_IDETAPE_WRITE) {
|
||||
if (req->cmd[13] & REQ_IDETAPE_WRITE) {
|
||||
pc = &tape->queued_pc;
|
||||
ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6);
|
||||
goto out;
|
||||
}
|
||||
if (rq->cmd[13] & REQ_IDETAPE_PC1) {
|
||||
if (req->cmd[13] & REQ_IDETAPE_PC1) {
|
||||
pc = (struct ide_atapi_pc *)rq->special;
|
||||
rq->cmd[13] &= ~(REQ_IDETAPE_PC1);
|
||||
rq->cmd[13] |= REQ_IDETAPE_PC2;
|
||||
req->cmd[13] &= ~(REQ_IDETAPE_PC1);
|
||||
req->cmd[13] |= REQ_IDETAPE_PC2;
|
||||
goto out;
|
||||
}
|
||||
if (rq->cmd[13] & REQ_IDETAPE_PC2) {
|
||||
if (req->cmd[13] & REQ_IDETAPE_PC2) {
|
||||
idetape_media_access_finished(drive);
|
||||
return ide_stopped;
|
||||
}
|
||||
@@ -853,8 +854,9 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
|
||||
BUG_ON(size < 0 || size % tape->blk_size);
|
||||
|
||||
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
rq->cmd_type = REQ_TYPE_DRV_PRIV;
|
||||
rq->cmd[13] = cmd;
|
||||
scsi_req(rq)->cmd[13] = cmd;
|
||||
rq->rq_disk = tape->disk;
|
||||
rq->__sector = tape->first_frame;
|
||||
|
||||
@@ -868,7 +870,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
|
||||
blk_execute_rq(drive->queue, tape->disk, rq, 0);
|
||||
|
||||
/* calculate the number of transferred bytes and update buffer state */
|
||||
size -= rq->resid_len;
|
||||
size -= scsi_req(rq)->resid_len;
|
||||
tape->cur = tape->buf;
|
||||
if (cmd == REQ_IDETAPE_READ)
|
||||
tape->valid = size;
|
||||
|
Criar uma nova questão referindo esta
Bloquear um utilizador