TESTS: Keep the LogicalBlockProvisioning VPD around after we read it during

test startup.
This commit is contained in:
Ronnie Sahlberg
2013-05-14 20:25:42 -07:00
parent f49a1beb16
commit dd46f3acf0
8 changed files with 43 additions and 65 deletions

View File

@@ -25,7 +25,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url)
struct iscsi_context *iscsi;
struct scsi_task *task;
int full_size;
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
struct scsi_inquiry_logical_block_provisioning *lbp;
int ret, i, lun;
printf("0180_writesame10_unmap:\n");
@@ -77,21 +77,16 @@ int T0180_writesame10_unmap(const char *initiator, const char *url)
}
}
inq_lbp = scsi_datain_unmarshall(task);
if (inq_lbp == NULL) {
lbp = scsi_datain_unmarshall(task);
if (lbp == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
ret = -1;
goto finished;
}
lbpws10 = inq_lbp->lbpws10;
anc_sup = inq_lbp->anc_sup;
scsi_free_scsi_task(task);
printf("[OK]\n");
if (lbpws10 == 0) {
if (lbp->lbpws10 == 0) {
printf("Device does not support WRITE_SAME10 for UNMAP. All WRITE_SAME10 commands to unmap should fail.\n");
}
@@ -105,13 +100,13 @@ int T0180_writesame10_unmap(const char *initiator, const char *url)
/* unmap the first 1 - 256 blocks at the start of the LUN */
printf("Unmapping first 1-256 blocks ... ");
if (lbpws10 == 0) {
if (lbp->lbpws10 == 0) {
printf("(Should all fail since LBPWS10 is 0) ");
}
for (i=1; i<=256; i++) {
/* only try unmapping whole physical blocks, of if unmap using ws10 is not supported
we test for all and they should all fail */
if (lbpws10 == 1 && i % lbppb) {
if (lbp->lbpws10 == 1 && i % lbppb) {
continue;
}
task = iscsi_writesame10_sync(iscsi, lun, 0,
@@ -133,7 +128,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url)
ret = -2;
goto finished;
}
if (lbpws10) {
if (lbp->lbpws10) {
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
@@ -160,13 +155,13 @@ int T0180_writesame10_unmap(const char *initiator, const char *url)
/* unmap the last 1 - 256 blocks at the end of the LUN */
printf("Unmapping last 1-256 blocks ... ");
if (lbpws10 == 0) {
if (lbp->lbpws10 == 0) {
printf("(Should all fail since LBPWS10 is 0) ");
}
for (i=1; i<=256; i++) {
/* only try unmapping whole physical blocks, of if unmap using ws10 is not supported
we test for all and they should all fail */
if (lbpws10 == 1 && i % lbppb) {
if (lbp->lbpws10 == 1 && i % lbppb) {
continue;
}
@@ -180,7 +175,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url)
ret = -1;
goto finished;
}
if (lbpws10) {
if (lbp->lbpws10) {
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
@@ -234,7 +229,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url)
/* Test UNMAP=1 and ANCHOR==1 */
printf("Try UNMAP==1 and ANCHOR==1 ... ");
if (anc_sup == 0) {
if (lbp->anc_sup == 0) {
printf("(ANC_SUP==0 so check condition expected) ");
}
task = iscsi_writesame10_sync(iscsi, lun, 0,
@@ -247,7 +242,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url)
ret = -1;
goto finished;
}
if (anc_sup == 0) {
if (lbp->anc_sup == 0) {
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {

View File

@@ -25,7 +25,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url)
struct iscsi_context *iscsi;
struct scsi_task *task;
int full_size;
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
struct scsi_inquiry_logical_block_provisioning *lbp;
int ret, i, lun;
printf("0190_writesame16_unmap:\n");
@@ -78,21 +78,16 @@ int T0190_writesame16_unmap(const char *initiator, const char *url)
}
}
inq_lbp = scsi_datain_unmarshall(task);
if (inq_lbp == NULL) {
lbp = scsi_datain_unmarshall(task);
if (lbp == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
ret = -1;
goto finished;
}
lbpws = inq_lbp->lbpws;
anc_sup = inq_lbp->anc_sup;
scsi_free_scsi_task(task);
printf("[OK]\n");
if (lbpws == 0) {
if (lbp->lbpws == 0) {
printf("Device does not support WRITE_SAME16 for UNMAP. All WRITE_SAME16 commands to unmap should fail.\n");
}
@@ -107,13 +102,13 @@ int T0190_writesame16_unmap(const char *initiator, const char *url)
/* unmap the first 1 - 256 blocks at the start of the LUN */
printf("Unmapping first 1-256 blocks ... ");
if (lbpws == 0) {
if (lbp->lbpws == 0) {
printf("(Should all fail since LBPWS is 0) ");
}
for (i=1; i<=256; i++) {
/* only try unmapping whole physical blocks, of if unmap using ws16 is not supported
we test for all and they should all fail */
if (lbpws == 1 && i % lbppb) {
if (lbp->lbpws == 1 && i % lbppb) {
continue;
}
task = iscsi_writesame16_sync(iscsi, lun, 0,
@@ -135,7 +130,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url)
ret = -2;
goto finished;
}
if (lbpws) {
if (lbp->lbpws) {
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
@@ -162,13 +157,13 @@ int T0190_writesame16_unmap(const char *initiator, const char *url)
/* unmap the last 1 - 256 blocks at the end of the LUN */
printf("Unmapping last 1-256 blocks ... ");
if (lbpws == 0) {
if (lbp->lbpws == 0) {
printf("(Should all fail since LBPWS is 0) ");
}
for (i=1; i<=256; i++) {
/* only try unmapping whole physical blocks, of if unmap using ws16 is not supported
we test for all and they should all fail */
if (lbpws == 1 && i % lbppb) {
if (lbp->lbpws == 1 && i % lbppb) {
continue;
}
@@ -182,7 +177,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url)
ret = -1;
goto finished;
}
if (lbpws) {
if (lbp->lbpws) {
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
@@ -233,7 +228,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url)
/* Test UNMAP=1 and ANCHOR==1 */
printf("Try UNMAP==1 and ANCHOR==1 ... ");
if (anc_sup == 0) {
if (lbp->anc_sup == 0) {
printf("(ANC_SUP==0 so check condition expected) ");
}
task = iscsi_writesame16_sync(iscsi, lun, 0,
@@ -246,7 +241,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url)
ret = -1;
goto finished;
}
if (anc_sup == 0) {
if (lbp->anc_sup == 0) {
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {

View File

@@ -47,6 +47,7 @@ const char *initiatorname2 =
const char *tgt_url;
struct scsi_inquiry_standard *inq;
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
struct scsi_readcapacity16 *rc16;
size_t block_size;
@@ -54,9 +55,6 @@ uint64_t num_blocks;
int lbppb;
enum scsi_inquiry_peripheral_device_type device_type;
int data_loss;
int anc_sup;
int lbpws10;
int lbpws;
int readonly;
int sbc3_support;
int maximum_transfer_length;

View File

@@ -88,7 +88,7 @@ do { \
#define CHECK_FOR_LBPWS10 \
do { \
if (lbpws10 == 0) { \
if (inq_lbp->lbpws10 == 0) { \
logging(LOG_VERBOSE, "[SKIPPED] Logical unit does not" \
" have LBPWS10. Skipping test"); \
CU_PASS("[SKIPPED] Logical unit does not have LBPWS10." \
@@ -99,7 +99,7 @@ do { \
#define CHECK_FOR_LBPWS \
do { \
if (lbpws == 0) { \
if (inq_lbp->lbpws == 0) { \
logging(LOG_VERBOSE, "[SKIPPED] Logical unit does not" \
" have LBPWS. Skipping test"); \
CU_PASS("[SKIPPED] Logical unit does not have LBPWS." \
@@ -129,15 +129,13 @@ do { \
} while (0);
extern struct scsi_inquiry_standard *inq;
extern struct scsi_inquiry_logical_block_provisioning *inq_lbp;
extern struct scsi_readcapacity16 *rc16;
extern size_t block_size;
extern uint64_t num_blocks;
extern int lbppb;
extern int data_loss;
extern int anc_sup;
extern int lbpws10;
extern int lbpws;
extern int readonly;
extern int sbc3_support;
extern int maximum_transfer_length;

View File

@@ -861,6 +861,7 @@ main(int argc, char *argv[])
int res;
struct scsi_readcapacity10 *rc10;
struct scsi_task *inq_task;
struct scsi_task *inq_lbp_task = NULL;
struct scsi_task *rc16_task;
int full_size;
int is_usb;
@@ -1049,37 +1050,27 @@ main(int argc, char *argv[])
/* if thin provisioned we also need to read the VPD page for it */
if (rc16 && rc16->lbpme != 0){
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
inq_lbp_task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64);
if (inq_lbp_task == NULL || inq_lbp_task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsic));
return -1;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
full_size = scsi_datain_getfullsize(inq_lbp_task);
if (full_size > inq_lbp_task->datain.size) {
scsi_free_scsi_task(inq_lbp_task);
/* we need more data for the full list */
if ((task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, full_size)) == NULL) {
if ((inq_lbp_task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, full_size)) == NULL) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsic));
scsi_free_scsi_task(task);
return -1;
}
}
inq_lbp = scsi_datain_unmarshall(task);
inq_lbp = scsi_datain_unmarshall(inq_lbp_task);
if (inq_lbp == NULL) {
printf("failed to unmarshall inquiry datain blob\n");
scsi_free_scsi_task(task);
return -1;
}
lbpws10 = inq_lbp->lbpws10;
lbpws = inq_lbp->lbpws;
anc_sup = inq_lbp->anc_sup;
scsi_free_scsi_task(task);
}
@@ -1145,6 +1136,7 @@ main(int argc, char *argv[])
free(discard_const(tgt_url));
scsi_free_scsi_task(inq_task);
scsi_free_scsi_task(inq_lbp_task);
scsi_free_scsi_task(rc16_task);
return 0;

View File

@@ -30,7 +30,7 @@ test_inquiry_block_limits(void)
int ret, expected_pl;
struct scsi_inquiry_block_limits *inq_bl;
struct scsi_task *bl_task = NULL;
struct scsi_inquiry_logical_block_provisioning *inq_lbp = NULL;
struct scsi_inquiry_logical_block_provisioning *lbp = NULL;
struct scsi_task *lbp_task = NULL;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -97,14 +97,14 @@ test_inquiry_block_limits(void)
1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
64, &lbp_task);
if (ret == 0) {
inq_lbp = scsi_datain_unmarshall(lbp_task);
if (inq_lbp == NULL) {
lbp = scsi_datain_unmarshall(lbp_task);
if (lbp == NULL) {
logging(LOG_NORMAL, "[FAILURE] failed to unmarshall "
"inquiry datain blob.");
}
}
if (inq_lbp && inq_lbp->lbpu) {
if (lbp && lbp->lbpu) {
/* We support UNMAP so MAXIMUM UNMAP LBA COUNT and
* MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT.
* They must be > 0.

View File

@@ -104,7 +104,7 @@ test_writesame10_unmap(void)
if (anc_sup) {
if (inq_lbp->anc_sup) {
logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0");
ret = writesame10(iscsic, tgt_lun, 0,
block_size, 1,

View File

@@ -105,7 +105,7 @@ test_writesame16_unmap(void)
if (anc_sup) {
if (inq_lbp->anc_sup) {
logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0");
ret = writesame16(iscsic, tgt_lun, 0,
block_size, 1,