Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 322919
b: refs/heads/master
c: 32a8811
h: refs/heads/master
i:
  322917: be9a19e
  322915: d94e34c
  322911: 63e4645
v: v3
  • Loading branch information
Paolo Bonzini authored and Nicholas Bellinger committed Sep 7, 2012
1 parent 210c811 commit 8016617
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3717ef0c63e90686d959158e9728a13a49229be6
refs/heads/master: 32a8811ff164f882712c17946e58e52444f464a7
35 changes: 18 additions & 17 deletions trunk/drivers/target/target_core_spc.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,11 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
static int spc_emulate_request_sense(struct se_cmd *cmd)
{
unsigned char *cdb = cmd->t_task_cdb;
unsigned char *buf;
unsigned char *rbuf;
u8 ua_asc = 0, ua_ascq = 0;
int err = 0;
unsigned char buf[SE_SENSE_BUF];

memset(buf, 0, SE_SENSE_BUF);

if (cdb[1] & 0x01) {
pr_err("REQUEST_SENSE description emulation not"
Expand All @@ -888,20 +890,21 @@ static int spc_emulate_request_sense(struct se_cmd *cmd)
return -ENOSYS;
}

buf = transport_kmap_data_sg(cmd);

if (!core_scsi3_ua_clear_for_request_sense(cmd, &ua_asc, &ua_ascq)) {
rbuf = transport_kmap_data_sg(cmd);
if (cmd->scsi_sense_reason != 0) {
/*
* Out of memory. We will fail with CHECK CONDITION, so
* we must not clear the unit attention condition.
*/
target_complete_cmd(cmd, CHECK_CONDITION);
return 0;
} else if (!core_scsi3_ua_clear_for_request_sense(cmd, &ua_asc, &ua_ascq)) {
/*
* CURRENT ERROR, UNIT ATTENTION
*/
buf[0] = 0x70;
buf[SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION;

if (cmd->data_length < 18) {
buf[7] = 0x00;
err = -EINVAL;
goto end;
}
/*
* The Additional Sense Code (ASC) from the UNIT ATTENTION
*/
Expand All @@ -915,20 +918,18 @@ static int spc_emulate_request_sense(struct se_cmd *cmd)
buf[0] = 0x70;
buf[SPC_SENSE_KEY_OFFSET] = NO_SENSE;

if (cmd->data_length < 18) {
buf[7] = 0x00;
err = -EINVAL;
goto end;
}
/*
* NO ADDITIONAL SENSE INFORMATION
*/
buf[SPC_ASC_KEY_OFFSET] = 0x00;
buf[7] = 0x0A;
}

end:
transport_kunmap_data_sg(cmd);
if (rbuf) {
memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length));
transport_kunmap_data_sg(cmd);
}

target_complete_cmd(cmd, GOOD);
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions trunk/include/target/target_core_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@

#define SE_INQUIRY_BUF 512
#define SE_MODE_PAGE_BUF 512
#define SE_SENSE_BUF 96

/* struct se_hba->hba_flags */
enum hba_flags_table {
Expand Down

0 comments on commit 8016617

Please sign in to comment.