From: Christoph Hellwig <hch@lst.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Subject: [PATCH 5/8] scsi: remove the sense and sense_len fields from struct scsi_request
Date: Tue, 22 Feb 2022 15:04:40 +0100 [thread overview]
Message-ID: <20220222140443.589882-6-hch@lst.de> (raw)
In-Reply-To: <20220222140443.589882-1-hch@lst.de>
Just use the sense_buffer field in struct scsi_cmnd for the sense data
and move the sense_len field over to struct scsi_cmnd.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/scsi/scsi_bsg.c | 7 ++++---
drivers/scsi/scsi_ioctl.c | 15 ++++++++-------
drivers/scsi/scsi_lib.c | 18 +++++++-----------
drivers/scsi/sg.c | 7 ++++---
drivers/scsi/sr.c | 2 +-
drivers/scsi/st.c | 5 +++--
drivers/target/target_core_pscsi.c | 3 ++-
include/scsi/scsi_cmnd.h | 1 +
include/scsi/scsi_request.h | 2 --
9 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/drivers/scsi/scsi_bsg.c b/drivers/scsi/scsi_bsg.c
index f8b65bd75ee10..0a6f6140501be 100644
--- a/drivers/scsi/scsi_bsg.c
+++ b/drivers/scsi/scsi_bsg.c
@@ -76,11 +76,12 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
hdr->info |= SG_INFO_CHECK;
hdr->response_len = 0;
- if (sreq->sense_len && hdr->response) {
+ if (scmd->sense_len && hdr->response) {
int len = min_t(unsigned int, hdr->max_response_len,
- sreq->sense_len);
+ scmd->sense_len);
- if (copy_to_user(uptr64(hdr->response), sreq->sense, len))
+ if (copy_to_user(uptr64(hdr->response), scmd->sense_buffer,
+ len))
ret = -EFAULT;
else
hdr->response_len = len;
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 6d9f1b44566d1..731232e6ee664 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -369,6 +369,7 @@ static int scsi_fill_sghdr_rq(struct scsi_device *sdev, struct request *rq,
static int scsi_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
struct bio *bio)
{
+ struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
struct scsi_request *req = scsi_req(rq);
int r, ret = 0;
@@ -388,10 +389,10 @@ static int scsi_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
hdr->resid = req->resid_len;
hdr->sb_len_wr = 0;
- if (req->sense_len && hdr->sbp) {
- int len = min((unsigned int) hdr->mx_sb_len, req->sense_len);
+ if (scmd->sense_len && hdr->sbp) {
+ int len = min((unsigned int) hdr->mx_sb_len, scmd->sense_len);
- if (!copy_to_user(hdr->sbp, req->sense, len))
+ if (!copy_to_user(hdr->sbp, scmd->sense_buffer, len))
hdr->sb_len_wr = len;
else
ret = -EFAULT;
@@ -613,10 +614,10 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode,
err = req->result & 0xff; /* only 8 bit SCSI status */
if (err) {
- if (req->sense_len && req->sense) {
- bytes = (OMAX_SB_LEN > req->sense_len) ?
- req->sense_len : OMAX_SB_LEN;
- if (copy_to_user(sic->data, req->sense, bytes))
+ if (scmd->sense_len && scmd->sense_buffer) {
+ bytes = (OMAX_SB_LEN > scmd->sense_len) ?
+ scmd->sense_len : OMAX_SB_LEN;
+ if (copy_to_user(sic->data, scmd->sense_buffer, bytes))
err = -EFAULT;
}
} else {
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index be02999b78ea5..db269f1d70b83 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -256,10 +256,11 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
if (resid)
*resid = rq->resid_len;
- if (sense && rq->sense_len)
- memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE);
+ if (sense && scmd->sense_len)
+ memcpy(sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
if (sshdr)
- scsi_normalize_sense(rq->sense, rq->sense_len, sshdr);
+ scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len,
+ sshdr);
ret = rq->result;
out:
blk_mq_free_request(req);
@@ -876,9 +877,8 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
/*
* SG_IO wants current and deferred errors
*/
- scsi_req(req)->sense_len =
- min(8 + cmd->sense_buffer[7],
- SCSI_SENSE_BUFFERSIZE);
+ cmd->sense_len = min(8 + cmd->sense_buffer[7],
+ SCSI_SENSE_BUFFERSIZE);
}
if (sense_current)
*blk_statp = scsi_result_to_blk_status(cmd, result);
@@ -1126,13 +1126,10 @@ EXPORT_SYMBOL(scsi_alloc_sgtables);
static void scsi_initialize_rq(struct request *rq)
{
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
- struct scsi_request *req = &cmd->req;
memset(cmd->cmnd, 0, sizeof(cmd->cmnd));
cmd->cmd_len = MAX_COMMAND_SIZE;
-
- req->sense_len = 0;
-
+ cmd->sense_len = 0;
init_rcu_head(&cmd->rcu);
cmd->jiffies_at_alloc = jiffies;
cmd->retries = 0;
@@ -1825,7 +1822,6 @@ static int scsi_mq_init_request(struct blk_mq_tag_set *set, struct request *rq,
kmem_cache_alloc_node(scsi_sense_cache, GFP_KERNEL, numa_node);
if (!cmd->sense_buffer)
return -ENOMEM;
- cmd->req.sense = cmd->sense_buffer;
if (scsi_host_get_prot(shost)) {
sg = (void *)cmd + sizeof(struct scsi_cmnd) +
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index cc3f11270dc23..0f96c7cde9e51 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1323,6 +1323,7 @@ sg_rq_end_io_usercontext(struct work_struct *work)
static void
sg_rq_end_io(struct request *rq, blk_status_t status)
{
+ struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
struct sg_request *srp = rq->end_io_data;
struct scsi_request *req = scsi_req(rq);
Sg_device *sdp;
@@ -1343,7 +1344,7 @@ sg_rq_end_io(struct request *rq, blk_status_t status)
if (unlikely(atomic_read(&sdp->detaching)))
pr_info("%s: device detaching\n", __func__);
- sense = req->sense;
+ sense = scmd->sense_buffer;
result = req->result;
resid = req->resid_len;
@@ -1380,8 +1381,8 @@ sg_rq_end_io(struct request *rq, blk_status_t status)
}
}
- if (req->sense_len)
- memcpy(srp->sense_b, req->sense, SCSI_SENSE_BUFFERSIZE);
+ if (scmd->sense_len)
+ memcpy(srp->sense_b, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
/* Rely on write phase to clean out srp status values, so no "else" */
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 3adba389cae51..1d19dd13d7f01 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -999,7 +999,7 @@ static int sr_read_cdda_bpc(struct cdrom_device_info *cdi, void __user *ubuf,
if (scsi_req(rq)->result) {
struct scsi_sense_hdr sshdr;
- scsi_normalize_sense(req->sense, req->sense_len,
+ scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len,
&sshdr);
*last_sense = sshdr.sense_key;
ret = -EIO;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 229e819a1797e..9b98e848d78c1 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -514,6 +514,7 @@ static void st_do_stats(struct scsi_tape *STp, struct request *req)
static void st_scsi_execute_end(struct request *req, blk_status_t status)
{
+ struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req);
struct st_request *SRpnt = req->end_io_data;
struct scsi_request *rq = scsi_req(req);
struct scsi_tape *STp = SRpnt->stp;
@@ -525,8 +526,8 @@ static void st_scsi_execute_end(struct request *req, blk_status_t status)
st_do_stats(STp, req);
tmp = SRpnt->bio;
- if (rq->sense_len)
- memcpy(SRpnt->sense, rq->sense, SCSI_SENSE_BUFFERSIZE);
+ if (scmd->sense_len)
+ memcpy(SRpnt->sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
if (SRpnt->waiting)
complete(SRpnt->waiting);
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 0a8078db923d3..9146193d0576a 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -1031,6 +1031,7 @@ static sector_t pscsi_get_blocks(struct se_device *dev)
static void pscsi_req_done(struct request *req, blk_status_t status)
{
struct se_cmd *cmd = req->end_io_data;
+ struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req);
int result = scsi_req(req)->result;
enum sam_status scsi_status = result & 0xff;
u8 *cdb = cmd->priv;
@@ -1040,7 +1041,7 @@ static void pscsi_req_done(struct request *req, blk_status_t status)
" 0x%02x Result: 0x%08x\n", cmd, cdb[0], result);
}
- pscsi_complete_cmd(cmd, scsi_status, scsi_req(req)->sense);
+ pscsi_complete_cmd(cmd, scsi_status, scmd->sense_buffer);
switch (host_byte(result)) {
case DID_OK:
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 3e432e25645ac..47add5b32f460 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -112,6 +112,7 @@ struct scsi_cmnd {
reconnects. Probably == sector
size */
+ unsigned sense_len;
unsigned char *sense_buffer;
/* obtained by REQUEST SENSE when
* CHECK CONDITION is received on original
diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
index aeee0611bcbe1..bed1cc49132ab 100644
--- a/include/scsi/scsi_request.h
+++ b/include/scsi/scsi_request.h
@@ -6,10 +6,8 @@
struct scsi_request {
int result;
- unsigned int sense_len;
unsigned int resid_len; /* residual count */
int retries;
- void *sense;
};
static inline struct scsi_request *scsi_req(struct request *rq)
--
2.30.2
next prev parent reply other threads:[~2022-02-22 14:05 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 14:04 remove struct scsi_request Christoph Hellwig
2022-02-22 14:04 ` [PATCH 1/8] bsg: don't include scsi_request.h in bsg-lib.h Christoph Hellwig
2022-02-22 18:33 ` Bart Van Assche
2022-02-22 14:04 ` [PATCH 2/8] target/pscsi: remove struct pscsi_plugin_task Christoph Hellwig
2022-02-22 14:04 ` [PATCH 3/8] scsi: don't memset the entire scsi_cmnd in scsi_init_command Christoph Hellwig
2022-02-23 12:21 ` John Garry
2022-02-23 12:39 ` Christoph Hellwig
2022-02-23 12:56 ` John Garry
2022-02-23 12:58 ` Christoph Hellwig
2022-02-23 20:16 ` Bart Van Assche
2022-02-24 6:52 ` Christoph Hellwig
2022-02-23 23:03 ` Bart Van Assche
2022-02-24 8:28 ` John Garry
2022-02-24 16:27 ` Christoph Hellwig
2022-02-24 16:38 ` John Garry
2022-02-22 14:04 ` [PATCH 4/8] scsi: remove the cmd field from struct scsi_request Christoph Hellwig
2022-02-23 3:31 ` Martin K. Petersen
2022-02-23 23:36 ` Bart Van Assche
2022-02-22 14:04 ` Christoph Hellwig [this message]
2022-02-23 23:39 ` [PATCH 5/8] scsi: remove the sense and sense_len fields " Bart Van Assche
2022-02-24 6:53 ` Christoph Hellwig
2022-02-22 14:04 ` [PATCH 6/8] scsi: move the resid_len field from struct scsi_request to struct scsi_cmnd Christoph Hellwig
2022-02-23 23:41 ` Bart Van Assche
2022-02-22 14:04 ` [PATCH 7/8] scsi: move the result " Christoph Hellwig
2022-02-23 23:43 ` Bart Van Assche
2022-02-22 14:04 ` [PATCH 8/8] scsi: remove struct scsi_request Christoph Hellwig
2022-02-23 23:48 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220222140443.589882-6-hch@lst.de \
--to=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox