mirror of
https://github.com/torvalds/linux.git
synced 2024-12-13 06:32:50 +00:00
block: Make most scsi_req_init() calls implicit
Instead of explicitly calling scsi_req_init() after blk_get_request(),
call that function from inside blk_get_request(). Add an
.initialize_rq_fn() callback function to the block drivers that need
it. Merge the IDE .init_rq_fn() function into .initialize_rq_fn()
because it is too small to keep it as a separate function. Keep the
scsi_req_init() call in ide_prep_sense() because it follows a
blk_rq_init() call.
References: commit 82ed4db499
("block: split scsi_request out of struct request")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
d280bab305
commit
ca18d6f769
@ -236,7 +236,6 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)
|
||||
rq = blk_get_request(q, op, GFP_KERNEL);
|
||||
if (IS_ERR(rq))
|
||||
return rq;
|
||||
scsi_req_init(rq);
|
||||
|
||||
ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd, has_write_perm);
|
||||
if (ret)
|
||||
|
@ -326,7 +326,6 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
|
||||
if (IS_ERR(rq))
|
||||
return PTR_ERR(rq);
|
||||
req = scsi_req(rq);
|
||||
scsi_req_init(rq);
|
||||
|
||||
if (hdr->cmd_len > BLK_MAX_CDB) {
|
||||
req->cmd = kzalloc(hdr->cmd_len, GFP_KERNEL);
|
||||
@ -456,7 +455,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
|
||||
goto error_free_buffer;
|
||||
}
|
||||
req = scsi_req(rq);
|
||||
scsi_req_init(rq);
|
||||
|
||||
cmdlen = COMMAND_SIZE(opcode);
|
||||
|
||||
@ -542,7 +540,6 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
|
||||
rq = blk_get_request(q, REQ_OP_SCSI_OUT, __GFP_RECLAIM);
|
||||
if (IS_ERR(rq))
|
||||
return PTR_ERR(rq);
|
||||
scsi_req_init(rq);
|
||||
rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
|
||||
scsi_req(rq)->cmd[0] = cmd;
|
||||
scsi_req(rq)->cmd[4] = data;
|
||||
|
@ -708,7 +708,6 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
|
||||
REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, __GFP_RECLAIM);
|
||||
if (IS_ERR(rq))
|
||||
return PTR_ERR(rq);
|
||||
scsi_req_init(rq);
|
||||
|
||||
if (cgc->buflen) {
|
||||
ret = blk_rq_map_kern(q, rq, cgc->buffer, cgc->buflen,
|
||||
|
@ -2201,7 +2201,6 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
|
||||
break;
|
||||
}
|
||||
req = scsi_req(rq);
|
||||
scsi_req_init(rq);
|
||||
|
||||
ret = blk_rq_map_user(q, rq, NULL, ubuf, len, GFP_KERNEL);
|
||||
if (ret) {
|
||||
|
@ -93,7 +93,6 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
|
||||
int error;
|
||||
|
||||
rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_MISC;
|
||||
rq->special = (char *)pc;
|
||||
|
||||
|
@ -438,7 +438,6 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
|
||||
|
||||
rq = blk_get_request(drive->queue,
|
||||
write ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
memcpy(scsi_req(rq)->cmd, cmd, BLK_MAX_CDB);
|
||||
ide_req(rq)->type = ATA_PRIV_PC;
|
||||
rq->rq_flags |= rq_flags;
|
||||
|
@ -304,7 +304,6 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)
|
||||
int ret;
|
||||
|
||||
rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_MISC;
|
||||
rq->rq_flags = RQF_QUIET;
|
||||
blk_execute_rq(drive->queue, cd->disk, rq, 0);
|
||||
|
@ -166,7 +166,6 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
|
||||
return setting->set(drive, arg);
|
||||
|
||||
rq = blk_get_request(q, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_MISC;
|
||||
scsi_req(rq)->cmd_len = 5;
|
||||
scsi_req(rq)->cmd[0] = REQ_DEVSET_EXEC;
|
||||
|
@ -478,7 +478,6 @@ static int set_multcount(ide_drive_t *drive, int arg)
|
||||
return -EBUSY;
|
||||
|
||||
rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_TASKFILE;
|
||||
|
||||
drive->mult_req = arg;
|
||||
|
@ -126,7 +126,6 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
|
||||
struct request *rq;
|
||||
|
||||
rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_TASKFILE;
|
||||
blk_execute_rq(drive->queue, NULL, rq, 0);
|
||||
err = scsi_req(rq)->result ? -EIO : 0;
|
||||
@ -224,7 +223,6 @@ static int generic_drive_reset(ide_drive_t *drive)
|
||||
int ret = 0;
|
||||
|
||||
rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_MISC;
|
||||
scsi_req(rq)->cmd_len = 1;
|
||||
scsi_req(rq)->cmd[0] = REQ_DRIVE_RESET;
|
||||
|
@ -32,7 +32,6 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
|
||||
spin_unlock_irq(&hwif->lock);
|
||||
|
||||
rq = blk_get_request(q, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
scsi_req(rq)->cmd[0] = REQ_PARK_HEADS;
|
||||
scsi_req(rq)->cmd_len = 1;
|
||||
ide_req(rq)->type = ATA_PRIV_MISC;
|
||||
@ -48,7 +47,6 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
|
||||
* timeout has expired, so power management will be reenabled.
|
||||
*/
|
||||
rq = blk_get_request(q, REQ_OP_DRV_IN, GFP_NOWAIT);
|
||||
scsi_req_init(rq);
|
||||
if (IS_ERR(rq))
|
||||
goto out;
|
||||
|
||||
|
@ -19,7 +19,6 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
|
||||
|
||||
memset(&rqpm, 0, sizeof(rqpm));
|
||||
rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_PM_SUSPEND;
|
||||
rq->special = &rqpm;
|
||||
rqpm.pm_step = IDE_PM_START_SUSPEND;
|
||||
@ -91,7 +90,6 @@ int generic_ide_resume(struct device *dev)
|
||||
|
||||
memset(&rqpm, 0, sizeof(rqpm));
|
||||
rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_PM_RESUME;
|
||||
rq->rq_flags |= RQF_PREEMPT;
|
||||
rq->special = &rqpm;
|
||||
|
@ -741,12 +741,12 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
|
||||
}
|
||||
}
|
||||
|
||||
static int ide_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp)
|
||||
static void ide_initialize_rq(struct request *rq)
|
||||
{
|
||||
struct ide_request *req = blk_mq_rq_to_pdu(rq);
|
||||
|
||||
scsi_req_init(rq);
|
||||
req->sreq.sense = req->sense;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -771,7 +771,7 @@ static int ide_init_queue(ide_drive_t *drive)
|
||||
return 1;
|
||||
|
||||
q->request_fn = do_ide_request;
|
||||
q->init_rq_fn = ide_init_rq;
|
||||
q->initialize_rq_fn = ide_initialize_rq;
|
||||
q->cmd_size = sizeof(struct ide_request);
|
||||
queue_flag_set_unlocked(QUEUE_FLAG_SCSI_PASSTHROUGH, q);
|
||||
if (blk_init_allocated_queue(q) < 0) {
|
||||
|
@ -855,7 +855,6 @@ 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, REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_MISC;
|
||||
scsi_req(rq)->cmd[13] = cmd;
|
||||
rq->rq_disk = tape->disk;
|
||||
|
@ -433,7 +433,6 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
|
||||
rq = blk_get_request(drive->queue,
|
||||
(cmd->tf_flags & IDE_TFLAG_WRITE) ?
|
||||
REQ_OP_DRV_OUT : REQ_OP_DRV_IN, __GFP_RECLAIM);
|
||||
scsi_req_init(rq);
|
||||
ide_req(rq)->type = ATA_PRIV_TASKFILE;
|
||||
|
||||
/*
|
||||
|
@ -1574,7 +1574,6 @@ static struct request *_make_request(struct request_queue *q, bool has_write,
|
||||
flags);
|
||||
if (IS_ERR(req))
|
||||
return req;
|
||||
scsi_req_init(req);
|
||||
|
||||
for_each_bio(bio) {
|
||||
struct bio *bounce_bio = bio;
|
||||
@ -1619,7 +1618,6 @@ static int _init_blk_request(struct osd_request *or,
|
||||
ret = PTR_ERR(req);
|
||||
goto out;
|
||||
}
|
||||
scsi_req_init(req);
|
||||
or->in.req = or->request->next_rq = req;
|
||||
}
|
||||
} else if (has_in)
|
||||
|
@ -373,7 +373,6 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd,
|
||||
return DRIVER_ERROR << 24;
|
||||
|
||||
rq = scsi_req(req);
|
||||
scsi_req_init(req);
|
||||
req->rq_flags |= RQF_QUIET;
|
||||
|
||||
SRpnt->bio = NULL;
|
||||
|
@ -1903,7 +1903,6 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
|
||||
if (IS_ERR(req))
|
||||
return;
|
||||
rq = scsi_req(req);
|
||||
scsi_req_init(req);
|
||||
|
||||
rq->cmd[0] = ALLOW_MEDIUM_REMOVAL;
|
||||
rq->cmd[1] = 0;
|
||||
|
@ -250,7 +250,6 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
|
||||
if (IS_ERR(req))
|
||||
return ret;
|
||||
rq = scsi_req(req);
|
||||
scsi_req_init(req);
|
||||
|
||||
if (bufflen && blk_rq_map_kern(sdev->request_queue, req,
|
||||
buffer, bufflen, __GFP_RECLAIM))
|
||||
@ -1117,6 +1116,18 @@ err_exit:
|
||||
}
|
||||
EXPORT_SYMBOL(scsi_init_io);
|
||||
|
||||
/**
|
||||
* scsi_initialize_rq - initialize struct scsi_cmnd.req
|
||||
*
|
||||
* Called from inside blk_get_request().
|
||||
*/
|
||||
void scsi_initialize_rq(struct request *rq)
|
||||
{
|
||||
scsi_req_init(rq);
|
||||
}
|
||||
EXPORT_SYMBOL(scsi_initialize_rq);
|
||||
|
||||
/* Called after a request has been started. */
|
||||
void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
|
||||
{
|
||||
void *buf = cmd->sense_buffer;
|
||||
@ -2124,6 +2135,7 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
|
||||
q->request_fn = scsi_request_fn;
|
||||
q->init_rq_fn = scsi_init_rq;
|
||||
q->exit_rq_fn = scsi_exit_rq;
|
||||
q->initialize_rq_fn = scsi_initialize_rq;
|
||||
|
||||
if (blk_init_allocated_queue(q) < 0) {
|
||||
blk_cleanup_queue(q);
|
||||
@ -2148,6 +2160,7 @@ static const struct blk_mq_ops scsi_mq_ops = {
|
||||
#endif
|
||||
.init_request = scsi_init_request,
|
||||
.exit_request = scsi_exit_request,
|
||||
.initialize_rq_fn = scsi_initialize_rq,
|
||||
.map_queues = scsi_map_queues,
|
||||
};
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <linux/bsg.h>
|
||||
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/scsi_cmnd.h>
|
||||
#include <scsi/scsi_request.h>
|
||||
#include <scsi/scsi_device.h>
|
||||
#include <scsi/scsi_host.h>
|
||||
@ -230,6 +231,7 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)
|
||||
q = blk_alloc_queue(GFP_KERNEL);
|
||||
if (!q)
|
||||
return -ENOMEM;
|
||||
q->initialize_rq_fn = scsi_initialize_rq;
|
||||
q->cmd_size = sizeof(struct scsi_request);
|
||||
|
||||
if (rphy) {
|
||||
|
@ -1732,8 +1732,6 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
|
||||
}
|
||||
req = scsi_req(rq);
|
||||
|
||||
scsi_req_init(rq);
|
||||
|
||||
if (hp->cmd_len > BLK_MAX_CDB)
|
||||
req->cmd = long_cmdp;
|
||||
memcpy(req->cmd, cmd, hp->cmd_len);
|
||||
|
@ -549,7 +549,6 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
|
||||
if (IS_ERR(req))
|
||||
return DRIVER_ERROR << 24;
|
||||
rq = scsi_req(req);
|
||||
scsi_req_init(req);
|
||||
req->rq_flags |= RQF_QUIET;
|
||||
|
||||
mdata->null_mapped = 1;
|
||||
|
@ -992,8 +992,6 @@ pscsi_execute_cmd(struct se_cmd *cmd)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
scsi_req_init(req);
|
||||
|
||||
if (sgl) {
|
||||
ret = pscsi_map_sg(cmd, sgl, sgl_nents, req);
|
||||
if (ret)
|
||||
|
@ -232,7 +232,6 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,
|
||||
goto out_free_buf;
|
||||
}
|
||||
req = scsi_req(rq);
|
||||
scsi_req_init(rq);
|
||||
|
||||
error = blk_rq_map_kern(q, rq, buf, bufflen, GFP_KERNEL);
|
||||
if (error)
|
||||
|
@ -166,6 +166,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
|
||||
extern void scsi_kunmap_atomic_sg(void *virt);
|
||||
|
||||
extern int scsi_init_io(struct scsi_cmnd *cmd);
|
||||
extern void scsi_initialize_rq(struct request *rq);
|
||||
|
||||
extern int scsi_dma_map(struct scsi_cmnd *cmd);
|
||||
extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user