TESTS: READ10 and STARTSTOPUNIT should fail while sanitize is in progress
Other commands should fail too but we dont need to test them all
This commit is contained in:
@@ -1536,6 +1536,42 @@ int startstopunit_preventremoval(struct iscsi_context *iscsi, int lun, int immed
|
||||
return 0;
|
||||
}
|
||||
|
||||
int startstopunit_sanitize(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send STARTSTOPUNIT (Expecting SANITIZE_IN_PROGRESS) "
|
||||
"IMMED:%d PCM:%d PC:%d NO_FLUSH:%d LOEJ:%d START:%d",
|
||||
immed, pcm, pc, no_flush, loej, start);
|
||||
|
||||
task = iscsi_startstopunit_sync(iscsi, lun, immed, pcm, pc, no_flush,
|
||||
loej, start);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL,
|
||||
"[FAILED] Failed to send STARTSTOPUNIT command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL,
|
||||
"[FAILED] STARTSTOPUNIT successful but should have failed with NOT_READY/SANITIZE_IN_PROGRESS");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_NOT_READY
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_SANITIZE_IN_PROGRESS) {
|
||||
logging(LOG_NORMAL, "[FAILED] STARTSTOPUNIT Should have failed "
|
||||
"with NOT_READY/SANITIZE_IN_PROGRESS But failed "
|
||||
"with %s", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] STARTSTOPUNIT returned SANITIZE_IN_PROGRESS.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
testunitready(struct iscsi_context *iscsi, int lun)
|
||||
{
|
||||
@@ -2818,6 +2854,52 @@ read16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
read16_sanitize(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
uint32_t datalen, int blocksize, int rdprotect,
|
||||
int dpo, int fua, int fua_nv, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send READ16 (Expecting SANITIZE_IN_PROGRESS) "
|
||||
"LBA:%" PRId64 " blocks:%d rdprotect:%d "
|
||||
"dpo:%d fua:%d fua_nv:%d group:%d",
|
||||
lba, datalen / blocksize, rdprotect,
|
||||
dpo, fua, fua_nv, group);
|
||||
|
||||
task = iscsi_read16_sync(iscsi, lun, lba, datalen, blocksize,
|
||||
rdprotect, dpo, fua, fua_nv, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send READ16 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 successful but should "
|
||||
"have failed with NOT_READY/SANITIZE_IN_PROGRESS");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_NOT_READY
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_SANITIZE_IN_PROGRESS) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 Should have failed "
|
||||
"with NOT_READY/SANITIZE_IN_PROGRESS But failed "
|
||||
"with %s", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (data != NULL) {
|
||||
memcpy(data, task->datain.data, task->datain.size);
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] READ16 returned SANITIZE_IN_PROGRESS");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
readcapacity10(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi)
|
||||
{
|
||||
|
||||
@@ -256,6 +256,7 @@ int read16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen,
|
||||
int read16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int read16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int read16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int read16_sanitize(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int readcapacity10(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi);
|
||||
int readcapacity10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi);
|
||||
int readcapacity16(struct iscsi_context *iscsi, int lun, int alloc_len);
|
||||
@@ -270,6 +271,7 @@ int sanitize_conflict(struct iscsi_context *iscsi, int lun, int immed, int ause,
|
||||
int sanitize_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
|
||||
int sanitize_writeprotected(struct iscsi_context *iscsi, int lun, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
|
||||
int startstopunit(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start);
|
||||
int startstopunit_sanitize(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start);
|
||||
int startstopunit_preventremoval(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start);
|
||||
int synchronizecache10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int sync_nv, int immed);
|
||||
int synchronizecache10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int sync_nv, int immed);
|
||||
|
||||
@@ -84,10 +84,21 @@ test_sanitize_reset(void)
|
||||
"slow to start the SANITIZE");
|
||||
sleep(3);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that the SANITIZE has started.");
|
||||
logging(LOG_VERBOSE, "Verify that the SANITIZE has started and that "
|
||||
"TESTUNITREADY fails with SANITIZE_IN_PROGRESS");
|
||||
ret = testunitready_sanitize(iscsic, tgt_lun);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that STARTSTOPUNIT fails with "
|
||||
"SANITIZE_IN_PROGRESS");
|
||||
ret = startstopunit_sanitize(iscsic, tgt_lun, 1, 0, 1, 0, 1, 0);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that READ16 fails with "
|
||||
"SANITIZE_IN_PROGRESS");
|
||||
ret = read16_sanitize(iscsic, tgt_lun, 0, block_size,
|
||||
block_size, 0, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that INQUIRY is still allowed while "
|
||||
"SANITIZE is in progress");
|
||||
|
||||
Reference in New Issue
Block a user