From b631a2146c361c027200128b98c1dd83ab84e737 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 15 Jul 2014 08:45:39 +0200 Subject: [PATCH] SPC-2 RESERVE tests: Use MODE SENSE instead of TEST UNIT READY Although SPC-2 specifies that a reservation conflict should be reported when TEST UNIT READY is received from another initiator than the registered initiator, it is an established practice that TEST UNIT READY is accepted in this case. Hence use the MODE SENSE command to test the effect of the RESERVE command instead of TEST UNIT READY. Signed-off-by: Bart Van Assche --- test-tool/iscsi-support.c | 18 ++++++++++++++++++ test-tool/iscsi-support.h | 1 + test-tool/test_reserve6_2initiators.c | 10 +++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 4758f92..be28660 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -1720,6 +1720,24 @@ testunitready_conflict(struct iscsi_context *iscsi, int lun) return 0; } +/* + * Returns -1 if allocating a SCSI task failed or if a communication error + * occurred and a SCSI status if a SCSI response has been received. + */ +int mode_sense(struct iscsi_context *iscsi, int lun) +{ + struct scsi_task *t; + enum scsi_status ret = -1; + + t = iscsi_modesense6_sync(iscsi, lun, 0, SCSI_MODESENSE_PC_CURRENT, + SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255); + if (t) { + ret = t->status; + scsi_free_scsi_task(t); + } + return ret; +} + int compareandwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 5bde199..2611d23 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -296,6 +296,7 @@ int testunitready(struct iscsi_context *iscsi, int lun); int testunitready_nomedium(struct iscsi_context *iscsi, int lun); int testunitready_conflict(struct iscsi_context *iscsi, int lun); int testunitready_sanitize(struct iscsi_context *iscsi, int lun); +int mode_sense(struct iscsi_context *iscsi, int lun); int unmap(struct iscsi_context *iscsi, int lun, int anchor, struct unmap_list *list, int list_len); int unmap_writeprotected(struct iscsi_context *iscsi, int lun, int anchor, struct unmap_list *list, int list_len); int unmap_nomedium(struct iscsi_context *iscsi, int lun, int anchor, struct unmap_list *list, int list_len); diff --git a/test-tool/test_reserve6_2initiators.c b/test-tool/test_reserve6_2initiators.c index e0b6b4e..1952aa4 100644 --- a/test-tool/test_reserve6_2initiators.c +++ b/test-tool/test_reserve6_2initiators.c @@ -67,13 +67,13 @@ test_reserve6_2initiators(void) CU_ASSERT_EQUAL(ret, 0); - logging(LOG_NORMAL, "Test we can still TESTUNITREADY from the first initiator"); - ret = testunitready(iscsic, tgt_lun); + logging(LOG_NORMAL, "Test we can still send MODE SENSE from the first initiator"); + ret = mode_sense(iscsic, tgt_lun); CU_ASSERT_EQUAL(ret, 0); - logging(LOG_NORMAL, "TESTUNITREADY should fail from the second initiator"); - ret = testunitready_conflict(iscsic2, tgt_lun); - CU_ASSERT_EQUAL(ret, 0); + logging(LOG_NORMAL, "MODE SENSE should fail from the second initiator"); + ret = mode_sense(iscsic2, tgt_lun); + CU_ASSERT_EQUAL(ret, SCSI_STATUS_RESERVATION_CONFLICT); logging(LOG_NORMAL, "RESERVE6 from the second initiator should still fail");