diff options
author | Roland Dreier <roland@purestorage.com> | 2011-12-13 17:55:33 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-12-16 01:29:04 -0500 |
commit | 895f3022523361e9b383cf48f51feb1f7d5e7e53 (patch) | |
tree | 6a692ebaacc4af38c8869eee0da7c6e868b1232a /drivers/target | |
parent | 6d5b59756033c2a029bde7262bb5f8d45f4ca952 (diff) |
target: Set additional sense length field in sense data
The target code was not setting the additional sense length field in the
sense data it returned, which meant that at least the Linux stack
ignored the ASC/ASCQ fields. For example, without this patch, on a
tcm_loop device:
# sg_raw -v /dev/sda 2 0 0 0 0 0
gives
cdb to send: 02 00 00 00 00 00
SCSI Status: Check Condition
Sense Information:
Fixed format, current; Sense key: Illegal Request
Raw sense data (in hex):
70 00 05 00 00 00 00 00
while after the patch we correctly get the following (which matches what
a regular disk returns):
cdb to send: 02 00 00 00 00 00
SCSI Status: Check Condition
Sense Information:
Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid command operation code
Raw sense data (in hex):
70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00
00 00
Signed-off-by: Roland Dreier <roland@purestorage.com>
Cc: stable@kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_transport.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index b5fdacce0671..d3ddd1361949 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -4398,6 +4398,7 @@ int transport_send_check_condition_and_sense( | |||
4398 | case TCM_NON_EXISTENT_LUN: | 4398 | case TCM_NON_EXISTENT_LUN: |
4399 | /* CURRENT ERROR */ | 4399 | /* CURRENT ERROR */ |
4400 | buffer[offset] = 0x70; | 4400 | buffer[offset] = 0x70; |
4401 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4401 | /* ILLEGAL REQUEST */ | 4402 | /* ILLEGAL REQUEST */ |
4402 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 4403 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
4403 | /* LOGICAL UNIT NOT SUPPORTED */ | 4404 | /* LOGICAL UNIT NOT SUPPORTED */ |
@@ -4407,6 +4408,7 @@ int transport_send_check_condition_and_sense( | |||
4407 | case TCM_SECTOR_COUNT_TOO_MANY: | 4408 | case TCM_SECTOR_COUNT_TOO_MANY: |
4408 | /* CURRENT ERROR */ | 4409 | /* CURRENT ERROR */ |
4409 | buffer[offset] = 0x70; | 4410 | buffer[offset] = 0x70; |
4411 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4410 | /* ILLEGAL REQUEST */ | 4412 | /* ILLEGAL REQUEST */ |
4411 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 4413 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
4412 | /* INVALID COMMAND OPERATION CODE */ | 4414 | /* INVALID COMMAND OPERATION CODE */ |
@@ -4415,6 +4417,7 @@ int transport_send_check_condition_and_sense( | |||
4415 | case TCM_UNKNOWN_MODE_PAGE: | 4417 | case TCM_UNKNOWN_MODE_PAGE: |
4416 | /* CURRENT ERROR */ | 4418 | /* CURRENT ERROR */ |
4417 | buffer[offset] = 0x70; | 4419 | buffer[offset] = 0x70; |
4420 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4418 | /* ILLEGAL REQUEST */ | 4421 | /* ILLEGAL REQUEST */ |
4419 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 4422 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
4420 | /* INVALID FIELD IN CDB */ | 4423 | /* INVALID FIELD IN CDB */ |
@@ -4423,6 +4426,7 @@ int transport_send_check_condition_and_sense( | |||
4423 | case TCM_CHECK_CONDITION_ABORT_CMD: | 4426 | case TCM_CHECK_CONDITION_ABORT_CMD: |
4424 | /* CURRENT ERROR */ | 4427 | /* CURRENT ERROR */ |
4425 | buffer[offset] = 0x70; | 4428 | buffer[offset] = 0x70; |
4429 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4426 | /* ABORTED COMMAND */ | 4430 | /* ABORTED COMMAND */ |
4427 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4431 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4428 | /* BUS DEVICE RESET FUNCTION OCCURRED */ | 4432 | /* BUS DEVICE RESET FUNCTION OCCURRED */ |
@@ -4432,6 +4436,7 @@ int transport_send_check_condition_and_sense( | |||
4432 | case TCM_INCORRECT_AMOUNT_OF_DATA: | 4436 | case TCM_INCORRECT_AMOUNT_OF_DATA: |
4433 | /* CURRENT ERROR */ | 4437 | /* CURRENT ERROR */ |
4434 | buffer[offset] = 0x70; | 4438 | buffer[offset] = 0x70; |
4439 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4435 | /* ABORTED COMMAND */ | 4440 | /* ABORTED COMMAND */ |
4436 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4441 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4437 | /* WRITE ERROR */ | 4442 | /* WRITE ERROR */ |
@@ -4442,6 +4447,7 @@ int transport_send_check_condition_and_sense( | |||
4442 | case TCM_INVALID_CDB_FIELD: | 4447 | case TCM_INVALID_CDB_FIELD: |
4443 | /* CURRENT ERROR */ | 4448 | /* CURRENT ERROR */ |
4444 | buffer[offset] = 0x70; | 4449 | buffer[offset] = 0x70; |
4450 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4445 | /* ABORTED COMMAND */ | 4451 | /* ABORTED COMMAND */ |
4446 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4452 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4447 | /* INVALID FIELD IN CDB */ | 4453 | /* INVALID FIELD IN CDB */ |
@@ -4450,6 +4456,7 @@ int transport_send_check_condition_and_sense( | |||
4450 | case TCM_INVALID_PARAMETER_LIST: | 4456 | case TCM_INVALID_PARAMETER_LIST: |
4451 | /* CURRENT ERROR */ | 4457 | /* CURRENT ERROR */ |
4452 | buffer[offset] = 0x70; | 4458 | buffer[offset] = 0x70; |
4459 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4453 | /* ABORTED COMMAND */ | 4460 | /* ABORTED COMMAND */ |
4454 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4461 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4455 | /* INVALID FIELD IN PARAMETER LIST */ | 4462 | /* INVALID FIELD IN PARAMETER LIST */ |
@@ -4458,6 +4465,7 @@ int transport_send_check_condition_and_sense( | |||
4458 | case TCM_UNEXPECTED_UNSOLICITED_DATA: | 4465 | case TCM_UNEXPECTED_UNSOLICITED_DATA: |
4459 | /* CURRENT ERROR */ | 4466 | /* CURRENT ERROR */ |
4460 | buffer[offset] = 0x70; | 4467 | buffer[offset] = 0x70; |
4468 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4461 | /* ABORTED COMMAND */ | 4469 | /* ABORTED COMMAND */ |
4462 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4470 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4463 | /* WRITE ERROR */ | 4471 | /* WRITE ERROR */ |
@@ -4468,6 +4476,7 @@ int transport_send_check_condition_and_sense( | |||
4468 | case TCM_SERVICE_CRC_ERROR: | 4476 | case TCM_SERVICE_CRC_ERROR: |
4469 | /* CURRENT ERROR */ | 4477 | /* CURRENT ERROR */ |
4470 | buffer[offset] = 0x70; | 4478 | buffer[offset] = 0x70; |
4479 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4471 | /* ABORTED COMMAND */ | 4480 | /* ABORTED COMMAND */ |
4472 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4481 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4473 | /* PROTOCOL SERVICE CRC ERROR */ | 4482 | /* PROTOCOL SERVICE CRC ERROR */ |
@@ -4478,6 +4487,7 @@ int transport_send_check_condition_and_sense( | |||
4478 | case TCM_SNACK_REJECTED: | 4487 | case TCM_SNACK_REJECTED: |
4479 | /* CURRENT ERROR */ | 4488 | /* CURRENT ERROR */ |
4480 | buffer[offset] = 0x70; | 4489 | buffer[offset] = 0x70; |
4490 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4481 | /* ABORTED COMMAND */ | 4491 | /* ABORTED COMMAND */ |
4482 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4492 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4483 | /* READ ERROR */ | 4493 | /* READ ERROR */ |
@@ -4488,6 +4498,7 @@ int transport_send_check_condition_and_sense( | |||
4488 | case TCM_WRITE_PROTECTED: | 4498 | case TCM_WRITE_PROTECTED: |
4489 | /* CURRENT ERROR */ | 4499 | /* CURRENT ERROR */ |
4490 | buffer[offset] = 0x70; | 4500 | buffer[offset] = 0x70; |
4501 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4491 | /* DATA PROTECT */ | 4502 | /* DATA PROTECT */ |
4492 | buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT; | 4503 | buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT; |
4493 | /* WRITE PROTECTED */ | 4504 | /* WRITE PROTECTED */ |
@@ -4496,6 +4507,7 @@ int transport_send_check_condition_and_sense( | |||
4496 | case TCM_CHECK_CONDITION_UNIT_ATTENTION: | 4507 | case TCM_CHECK_CONDITION_UNIT_ATTENTION: |
4497 | /* CURRENT ERROR */ | 4508 | /* CURRENT ERROR */ |
4498 | buffer[offset] = 0x70; | 4509 | buffer[offset] = 0x70; |
4510 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4499 | /* UNIT ATTENTION */ | 4511 | /* UNIT ATTENTION */ |
4500 | buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; | 4512 | buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; |
4501 | core_scsi3_ua_for_check_condition(cmd, &asc, &ascq); | 4513 | core_scsi3_ua_for_check_condition(cmd, &asc, &ascq); |
@@ -4505,6 +4517,7 @@ int transport_send_check_condition_and_sense( | |||
4505 | case TCM_CHECK_CONDITION_NOT_READY: | 4517 | case TCM_CHECK_CONDITION_NOT_READY: |
4506 | /* CURRENT ERROR */ | 4518 | /* CURRENT ERROR */ |
4507 | buffer[offset] = 0x70; | 4519 | buffer[offset] = 0x70; |
4520 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4508 | /* Not Ready */ | 4521 | /* Not Ready */ |
4509 | buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY; | 4522 | buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY; |
4510 | transport_get_sense_codes(cmd, &asc, &ascq); | 4523 | transport_get_sense_codes(cmd, &asc, &ascq); |
@@ -4515,6 +4528,7 @@ int transport_send_check_condition_and_sense( | |||
4515 | default: | 4528 | default: |
4516 | /* CURRENT ERROR */ | 4529 | /* CURRENT ERROR */ |
4517 | buffer[offset] = 0x70; | 4530 | buffer[offset] = 0x70; |
4531 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4518 | /* ILLEGAL REQUEST */ | 4532 | /* ILLEGAL REQUEST */ |
4519 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 4533 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
4520 | /* LOGICAL UNIT COMMUNICATION FAILURE */ | 4534 | /* LOGICAL UNIT COMMUNICATION FAILURE */ |