scsi: core: Move the resid_len field from struct scsi_request to struct scsi_cmnd
Prepare for removing the scsi_request structure by moving the resid_len field to struct scsi_cmnd. Link: https://lore.kernel.org/r/20220224175552.988286-6-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>
This commit is contained in:
parent
5b794f9807
commit
a9a4ea1166
@ -88,9 +88,9 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rq_data_dir(rq) == READ)
|
if (rq_data_dir(rq) == READ)
|
||||||
hdr->din_resid = sreq->resid_len;
|
hdr->din_resid = scmd->resid_len;
|
||||||
else
|
else
|
||||||
hdr->dout_resid = sreq->resid_len;
|
hdr->dout_resid = scmd->resid_len;
|
||||||
|
|
||||||
blk_rq_unmap_user(bio);
|
blk_rq_unmap_user(bio);
|
||||||
|
|
||||||
|
@ -1005,7 +1005,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
|
|||||||
ses->data_direction = scmd->sc_data_direction;
|
ses->data_direction = scmd->sc_data_direction;
|
||||||
ses->sdb = scmd->sdb;
|
ses->sdb = scmd->sdb;
|
||||||
ses->result = scmd->result;
|
ses->result = scmd->result;
|
||||||
ses->resid_len = scmd->req.resid_len;
|
ses->resid_len = scmd->resid_len;
|
||||||
ses->underflow = scmd->underflow;
|
ses->underflow = scmd->underflow;
|
||||||
ses->prot_op = scmd->prot_op;
|
ses->prot_op = scmd->prot_op;
|
||||||
ses->eh_eflags = scmd->eh_eflags;
|
ses->eh_eflags = scmd->eh_eflags;
|
||||||
@ -1016,7 +1016,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
|
|||||||
memset(scmd->cmnd, 0, sizeof(scmd->cmnd));
|
memset(scmd->cmnd, 0, sizeof(scmd->cmnd));
|
||||||
memset(&scmd->sdb, 0, sizeof(scmd->sdb));
|
memset(&scmd->sdb, 0, sizeof(scmd->sdb));
|
||||||
scmd->result = 0;
|
scmd->result = 0;
|
||||||
scmd->req.resid_len = 0;
|
scmd->resid_len = 0;
|
||||||
|
|
||||||
if (sense_bytes) {
|
if (sense_bytes) {
|
||||||
scmd->sdb.length = min_t(unsigned, SCSI_SENSE_BUFFERSIZE,
|
scmd->sdb.length = min_t(unsigned, SCSI_SENSE_BUFFERSIZE,
|
||||||
@ -1069,7 +1069,7 @@ void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses)
|
|||||||
scmd->sc_data_direction = ses->data_direction;
|
scmd->sc_data_direction = ses->data_direction;
|
||||||
scmd->sdb = ses->sdb;
|
scmd->sdb = ses->sdb;
|
||||||
scmd->result = ses->result;
|
scmd->result = ses->result;
|
||||||
scmd->req.resid_len = ses->resid_len;
|
scmd->resid_len = ses->resid_len;
|
||||||
scmd->underflow = ses->underflow;
|
scmd->underflow = ses->underflow;
|
||||||
scmd->prot_op = ses->prot_op;
|
scmd->prot_op = ses->prot_op;
|
||||||
scmd->eh_eflags = ses->eh_eflags;
|
scmd->eh_eflags = ses->eh_eflags;
|
||||||
|
@ -386,7 +386,7 @@ static int scsi_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
|
|||||||
hdr->info = 0;
|
hdr->info = 0;
|
||||||
if (hdr->masked_status || hdr->host_status || hdr->driver_status)
|
if (hdr->masked_status || hdr->host_status || hdr->driver_status)
|
||||||
hdr->info |= SG_INFO_CHECK;
|
hdr->info |= SG_INFO_CHECK;
|
||||||
hdr->resid = req->resid_len;
|
hdr->resid = scmd->resid_len;
|
||||||
hdr->sb_len_wr = 0;
|
hdr->sb_len_wr = 0;
|
||||||
|
|
||||||
if (scmd->sense_len && hdr->sbp) {
|
if (scmd->sense_len && hdr->sbp) {
|
||||||
|
@ -251,11 +251,11 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
|
|||||||
* is invalid. Prevent the garbage from being misinterpreted
|
* is invalid. Prevent the garbage from being misinterpreted
|
||||||
* and prevent security leaks by zeroing out the excess data.
|
* and prevent security leaks by zeroing out the excess data.
|
||||||
*/
|
*/
|
||||||
if (unlikely(rq->resid_len > 0 && rq->resid_len <= bufflen))
|
if (unlikely(scmd->resid_len > 0 && scmd->resid_len <= bufflen))
|
||||||
memset(buffer + (bufflen - rq->resid_len), 0, rq->resid_len);
|
memset(buffer + bufflen - scmd->resid_len, 0, scmd->resid_len);
|
||||||
|
|
||||||
if (resid)
|
if (resid)
|
||||||
*resid = rq->resid_len;
|
*resid = scmd->resid_len;
|
||||||
if (sense && scmd->sense_len)
|
if (sense && scmd->sense_len)
|
||||||
memcpy(sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
|
memcpy(sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
|
||||||
if (sshdr)
|
if (sshdr)
|
||||||
|
@ -1346,7 +1346,7 @@ sg_rq_end_io(struct request *rq, blk_status_t status)
|
|||||||
|
|
||||||
sense = scmd->sense_buffer;
|
sense = scmd->sense_buffer;
|
||||||
result = req->result;
|
result = req->result;
|
||||||
resid = req->resid_len;
|
resid = scmd->resid_len;
|
||||||
|
|
||||||
SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
|
SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
|
||||||
"sg_cmd_done: pack_id=%d, res=0x%x\n",
|
"sg_cmd_done: pack_id=%d, res=0x%x\n",
|
||||||
|
@ -521,7 +521,7 @@ static void st_scsi_execute_end(struct request *req, blk_status_t status)
|
|||||||
struct bio *tmp;
|
struct bio *tmp;
|
||||||
|
|
||||||
STp->buffer->cmdstat.midlevel_result = SRpnt->result = rq->result;
|
STp->buffer->cmdstat.midlevel_result = SRpnt->result = rq->result;
|
||||||
STp->buffer->cmdstat.residual = rq->resid_len;
|
STp->buffer->cmdstat.residual = scmd->resid_len;
|
||||||
|
|
||||||
st_do_stats(STp, req);
|
st_do_stats(STp, req);
|
||||||
|
|
||||||
|
@ -1046,7 +1046,7 @@ static void pscsi_req_done(struct request *req, blk_status_t status)
|
|||||||
switch (host_byte(result)) {
|
switch (host_byte(result)) {
|
||||||
case DID_OK:
|
case DID_OK:
|
||||||
target_complete_cmd_with_length(cmd, scsi_status,
|
target_complete_cmd_with_length(cmd, scsi_status,
|
||||||
cmd->data_length - scsi_req(req)->resid_len);
|
cmd->data_length - scmd->resid_len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_debug("PSCSI Host Byte exception at cmd: %p CDB:"
|
pr_debug("PSCSI Host Byte exception at cmd: %p CDB:"
|
||||||
|
@ -111,7 +111,7 @@ struct scsi_cmnd {
|
|||||||
(ie, between disconnect /
|
(ie, between disconnect /
|
||||||
reconnects. Probably == sector
|
reconnects. Probably == sector
|
||||||
size */
|
size */
|
||||||
|
unsigned resid_len; /* residual count */
|
||||||
unsigned sense_len;
|
unsigned sense_len;
|
||||||
unsigned char *sense_buffer;
|
unsigned char *sense_buffer;
|
||||||
/* obtained by REQUEST SENSE when
|
/* obtained by REQUEST SENSE when
|
||||||
@ -200,12 +200,12 @@ static inline unsigned scsi_bufflen(struct scsi_cmnd *cmd)
|
|||||||
|
|
||||||
static inline void scsi_set_resid(struct scsi_cmnd *cmd, unsigned int resid)
|
static inline void scsi_set_resid(struct scsi_cmnd *cmd, unsigned int resid)
|
||||||
{
|
{
|
||||||
cmd->req.resid_len = resid;
|
cmd->resid_len = resid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int scsi_get_resid(struct scsi_cmnd *cmd)
|
static inline unsigned int scsi_get_resid(struct scsi_cmnd *cmd)
|
||||||
{
|
{
|
||||||
return cmd->req.resid_len;
|
return cmd->resid_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define scsi_for_each_sg(cmd, sg, nseg, __i) \
|
#define scsi_for_each_sg(cmd, sg, nseg, __i) \
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
struct scsi_request {
|
struct scsi_request {
|
||||||
int result;
|
int result;
|
||||||
unsigned int resid_len; /* residual count */
|
|
||||||
int retries;
|
int retries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user