]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: core: Remove struct scsi_request
authorChristoph Hellwig <hch@lst.de>
Thu, 24 Feb 2022 17:55:51 +0000 (18:55 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 2 Mar 2022 03:21:50 +0000 (22:21 -0500)
Let submitters initialize the scmd->allowed field directly instead of
indirecting through struct scsi_request and remove the now superfluous
structure.

Link: https://lore.kernel.org/r/20220224175552.988286-8-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_debugfs.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_ioctl.c
drivers/scsi/scsi_lib.c
drivers/scsi/sg.c
drivers/scsi/sr.c
drivers/scsi/st.c
drivers/target/target_core_pscsi.c
include/scsi/scsi_cmnd.h
include/scsi/scsi_request.h

index 17d7f73a895c6f3b6f2fb1edf00abc5ca41ba4cd..217b70c678c3ad322ddfd23b6a992fb0e977202a 100644 (file)
@@ -33,7 +33,7 @@ static int scsi_flags_show(struct seq_file *m, const unsigned long flags,
 
 void scsi_show_rq(struct seq_file *m, struct request *rq)
 {
-       struct scsi_cmnd *cmd = container_of(scsi_req(rq), typeof(*cmd), req);
+       struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
        int alloc_ms = jiffies_to_msecs(jiffies - cmd->jiffies_at_alloc);
        int timeout_ms = jiffies_to_msecs(rq->timeout);
        char buf[80] = "(?)";
index cf02d1c503897b77444384f7ef4b6df8f83a9364..9c237b223e63ced8f60cafa9e1edcffabe32c065 100644 (file)
@@ -2023,12 +2023,10 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
 {
        struct scsi_cmnd *scmd;
        struct request *req;
-       struct scsi_request *rq;
 
        req = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, 0);
        if (IS_ERR(req))
                return;
-       rq = scsi_req(req);
        scmd = blk_mq_rq_to_pdu(req);
 
        scmd->cmnd[0] = ALLOW_MEDIUM_REMOVAL;
@@ -2041,7 +2039,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
 
        req->rq_flags |= RQF_QUIET;
        req->timeout = 10 * HZ;
-       rq->retries = 5;
+       scmd->allowed = 5;
 
        blk_execute_rq_nowait(req, true, eh_lock_door_done);
 }
index 04b7c70d1dba3a0f3705f8d9cb9a493927ce18ce..0613015cae39c58c0424d133e5449e164263a836 100644 (file)
@@ -411,7 +411,6 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode)
        int writing = 0;
        int at_head = 0;
        struct request *rq;
-       struct scsi_request *req;
        struct scsi_cmnd *scmd;
        struct bio *bio;
 
@@ -440,7 +439,6 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode)
                             REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
        if (IS_ERR(rq))
                return PTR_ERR(rq);
-       req = scsi_req(rq);
        scmd = blk_mq_rq_to_pdu(rq);
 
        if (hdr->cmd_len > sizeof(scmd->cmnd)) {
@@ -475,7 +473,7 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode)
                goto out_put_request;
 
        bio = rq->bio;
-       req->retries = 0;
+       scmd->allowed = 0;
 
        start_time = jiffies;
 
@@ -521,7 +519,6 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode,
                struct scsi_ioctl_command __user *sic)
 {
        struct request *rq;
-       struct scsi_request *req;
        int err;
        unsigned int in_len, out_len, bytes, opcode, cmdlen;
        struct scsi_cmnd *scmd;
@@ -555,7 +552,6 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode,
                err = PTR_ERR(rq);
                goto error_free_buffer;
        }
-       req = scsi_req(rq);
        scmd = blk_mq_rq_to_pdu(rq);
 
        cmdlen = COMMAND_SIZE(opcode);
@@ -576,13 +572,13 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode,
                goto error;
 
        /* default.  possible overridden later */
-       req->retries = 5;
+       scmd->allowed = 5;
 
        switch (opcode) {
        case SEND_DIAGNOSTIC:
        case FORMAT_UNIT:
                rq->timeout = FORMAT_UNIT_TIMEOUT;
-               req->retries = 1;
+               scmd->allowed = 1;
                break;
        case START_STOP:
                rq->timeout = START_STOP_TIMEOUT;
@@ -595,7 +591,7 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode,
                break;
        case READ_DEFECT_DATA:
                rq->timeout = READ_DEFECT_DATA_TIMEOUT;
-               req->retries = 1;
+               scmd->allowed = 1;
                break;
        default:
                rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
index 0c41e023a3cea63924eae1f8ba5d95250e94b3ed..a7788184908e9b5f69abaf097afdfd1cfb4cc39a 100644 (file)
@@ -213,7 +213,6 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
                 int *resid)
 {
        struct request *req;
-       struct scsi_request *rq;
        struct scsi_cmnd *scmd;
        int ret;
 
@@ -224,8 +223,6 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       rq = scsi_req(req);
-
        if (bufflen) {
                ret = blk_rq_map_kern(sdev->request_queue, req,
                                      buffer, bufflen, GFP_NOIO);
@@ -235,7 +232,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
        scmd = blk_mq_rq_to_pdu(req);
        scmd->cmd_len = COMMAND_SIZE(cmd[0]);
        memcpy(scmd->cmnd, cmd, scmd->cmd_len);
-       rq->retries = retries;
+       scmd->allowed = retries;
        req->timeout = timeout;
        req->cmd_flags |= flags;
        req->rq_flags |= rq_flags | RQF_QUIET;
@@ -1189,7 +1186,6 @@ static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev,
        }
 
        cmd->transfersize = blk_rq_bytes(req);
-       cmd->allowed = scsi_req(req)->retries;
        return BLK_STS_OK;
 }
 
index 26a753521cb292422d1a67176f11241e20b49448..6a1c3ffaf32a00250c8c48f2e0e930d64c6206ac 100644 (file)
@@ -1725,7 +1725,6 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
 {
        int res;
        struct request *rq;
-       struct scsi_request *req;
        Sg_fd *sfp = srp->parentfp;
        sg_io_hdr_t *hp = &srp->header;
        int dxfer_len = (int) hp->dxfer_len;
@@ -1758,7 +1757,6 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
        if (IS_ERR(rq))
                return PTR_ERR(rq);
        scmd = blk_mq_rq_to_pdu(rq);
-       req = scsi_req(rq);
 
        if (hp->cmd_len > sizeof(scmd->cmnd)) {
                blk_mq_free_request(rq);
@@ -1770,7 +1768,7 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
 
        srp->rq = rq;
        rq->end_io_data = srp;
-       req->retries = SG_DEFAULT_RETRIES;
+       scmd->allowed = SG_DEFAULT_RETRIES;
 
        if ((dxfer_len <= 0) || (dxfer_dir == SG_DXFER_NONE))
                return 0;
index 494d00b05f53e098add144becca9a0a2448e6647..aaa54ad5f03524e10f38979ba000385573b8df1e 100644 (file)
@@ -965,7 +965,6 @@ static int sr_read_cdda_bpc(struct cdrom_device_info *cdi, void __user *ubuf,
 {
        struct gendisk *disk = cdi->disk;
        u32 len = nr * CD_FRAMESIZE_RAW;
-       struct scsi_request *req;
        struct scsi_cmnd *scmd;
        struct request *rq;
        struct bio *bio;
@@ -974,7 +973,6 @@ static int sr_read_cdda_bpc(struct cdrom_device_info *cdi, void __user *ubuf,
        rq = scsi_alloc_request(disk->queue, REQ_OP_DRV_IN, 0);
        if (IS_ERR(rq))
                return PTR_ERR(rq);
-       req = scsi_req(rq);
        scmd = blk_mq_rq_to_pdu(rq);
 
        ret = blk_rq_map_user(disk->queue, rq, NULL, ubuf, len, GFP_KERNEL);
index c8533ca225bc0c3f6ff43f7e6badf1cbd52e0ea5..6d4213e2e49ae6948144ebfd8993f252e71bc65b 100644 (file)
@@ -539,7 +539,6 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
                           int timeout, int retries)
 {
        struct request *req;
-       struct scsi_request *rq;
        struct rq_map_data *mdata = &SRpnt->stp->buffer->map_data;
        int err = 0;
        struct scsi_tape *STp = SRpnt->stp;
@@ -551,7 +550,6 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
        if (IS_ERR(req))
                return PTR_ERR(req);
        scmd = blk_mq_rq_to_pdu(req);
-       rq = scsi_req(req);
        req->rq_flags |= RQF_QUIET;
 
        mdata->null_mapped = 1;
@@ -580,7 +578,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
        scmd->cmd_len = COMMAND_SIZE(cmd[0]);
        memcpy(scmd->cmnd, cmd, scmd->cmd_len);
        req->timeout = timeout;
-       rq->retries = retries;
+       scmd->allowed = retries;
        req->end_io_data = SRpnt;
 
        blk_execute_rq_nowait(req, true, st_scsi_execute_end);
index 5b23a0ff905eaa6b0b0226c439b8526a7f590969..d18d75d0d750c43f6b05ed65a2b53a0341196d2c 100644 (file)
@@ -993,7 +993,7 @@ pscsi_execute_cmd(struct se_cmd *cmd)
                req->timeout = PS_TIMEOUT_DISK;
        else
                req->timeout = PS_TIMEOUT_OTHER;
-       scsi_req(req)->retries = PS_RETRY;
+       scmd->allowed = PS_RETRY;
 
        cmd->priv = scmd->cmnd;
 
index 5ff0a6e8460c39a6b68e1f76c03cdec621ddca54..4b33ca6a7c7d6e3bac8371c3b4af2e61acb145cc 100644 (file)
@@ -68,7 +68,6 @@ enum scsi_cmnd_submitter {
 } __packed;
 
 struct scsi_cmnd {
-       struct scsi_request req;
        struct scsi_device *device;
        struct list_head eh_entry; /* entry for the host eh_abort_list/eh_cmd_q */
        struct delayed_work abort_work;
index 929c7bd5c72fe081b6177dce6e74524f7020491b..6d424d3e8d02f33d1b281d2b977ad811120cd560 100644 (file)
@@ -4,13 +4,4 @@
 
 #include <linux/blk-mq.h>
 
-struct scsi_request {
-       int             retries;
-};
-
-static inline struct scsi_request *scsi_req(struct request *rq)
-{
-       return blk_mq_rq_to_pdu(rq);
-}
-
 #endif /* _SCSI_SCSI_REQUEST_H */