Skip to content

Commit e9512f3

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fix from James Bottomley: "One fix for an endless error loop with the target driver affecting tapes" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: target: pscsi: Set SCF_TREAT_READ_AS_NORMAL flag only if there is valid data
2 parents 8013d1d + 8be70a8 commit e9512f3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/target/target_core_pscsi.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static void pscsi_destroy_device(struct se_device *dev)
588588
}
589589

590590
static void pscsi_complete_cmd(struct se_cmd *cmd, u8 scsi_status,
591-
unsigned char *req_sense)
591+
unsigned char *req_sense, int valid_data)
592592
{
593593
struct pscsi_dev_virt *pdv = PSCSI_DEV(cmd->se_dev);
594594
struct scsi_device *sd = pdv->pdv_sd;
@@ -681,7 +681,7 @@ static void pscsi_complete_cmd(struct se_cmd *cmd, u8 scsi_status,
681681
* back despite framework assumption that a
682682
* check condition means there is no data
683683
*/
684-
if (sd->type == TYPE_TAPE &&
684+
if (sd->type == TYPE_TAPE && valid_data &&
685685
cmd->data_direction == DMA_FROM_DEVICE) {
686686
/*
687687
* is sense data valid, fixed format,
@@ -1032,19 +1032,19 @@ static void pscsi_req_done(struct request *req, blk_status_t status)
10321032
struct se_cmd *cmd = req->end_io_data;
10331033
struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req);
10341034
enum sam_status scsi_status = scmd->result & 0xff;
1035+
int valid_data = cmd->data_length - scmd->resid_len;
10351036
u8 *cdb = cmd->priv;
10361037

10371038
if (scsi_status != SAM_STAT_GOOD) {
10381039
pr_debug("PSCSI Status Byte exception at cmd: %p CDB:"
10391040
" 0x%02x Result: 0x%08x\n", cmd, cdb[0], scmd->result);
10401041
}
10411042

1042-
pscsi_complete_cmd(cmd, scsi_status, scmd->sense_buffer);
1043+
pscsi_complete_cmd(cmd, scsi_status, scmd->sense_buffer, valid_data);
10431044

10441045
switch (host_byte(scmd->result)) {
10451046
case DID_OK:
1046-
target_complete_cmd_with_length(cmd, scsi_status,
1047-
cmd->data_length - scmd->resid_len);
1047+
target_complete_cmd_with_length(cmd, scsi_status, valid_data);
10481048
break;
10491049
default:
10501050
pr_debug("PSCSI Host Byte exception at cmd: %p CDB:"

0 commit comments

Comments
 (0)