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 <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2014-07-15 08:45:39 +02:00
committed by Ronnie Sahlberg
parent bb8d01e093
commit b631a2146c
3 changed files with 24 additions and 5 deletions

View File

@@ -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,

View File

@@ -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);

View File

@@ -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");