Merge pull request #132 from plieven/test_lbas_check_desc
Some improvements for the get_lba_status tests.
This commit is contained in:
@@ -1909,7 +1909,8 @@ struct scsi_task *get_lba_status_task(struct iscsi_context *iscsi, int lun, uint
|
|||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len)
|
int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len,
|
||||||
|
enum scsi_provisioning_type *provisioning0)
|
||||||
{
|
{
|
||||||
struct scsi_task *task;
|
struct scsi_task *task;
|
||||||
struct scsi_get_lba_status *lbas = NULL;
|
struct scsi_get_lba_status *lbas = NULL;
|
||||||
@@ -1954,6 +1955,9 @@ int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t
|
|||||||
scsi_free_scsi_task(task);
|
scsi_free_scsi_task(task);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (provisioning0 != NULL) {
|
||||||
|
*provisioning0 = lbasd->provisioning;
|
||||||
|
}
|
||||||
|
|
||||||
scsi_free_scsi_task(task);
|
scsi_free_scsi_task(task);
|
||||||
logging(LOG_VERBOSE, "[OK] GET_LBA_STATUS returned SUCCESS.");
|
logging(LOG_VERBOSE, "[OK] GET_LBA_STATUS returned SUCCESS.");
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ struct scsi_task *get_lba_status_task(struct iscsi_context *iscsi, int lun, uint
|
|||||||
int compareandwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
|
int compareandwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
|
||||||
int compareandwrite_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
|
int compareandwrite_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
|
||||||
int compareandwrite_miscompare(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
|
int compareandwrite_miscompare(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
|
||||||
int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
|
int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len, enum scsi_provisioning_type *provisioning0);
|
||||||
int get_lba_status_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
|
int get_lba_status_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
|
||||||
int get_lba_status_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
|
int get_lba_status_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
|
||||||
int orwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
int orwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||||
|
|||||||
@@ -33,18 +33,24 @@ test_get_lba_status_simple(void)
|
|||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test GET_LBA_STATUS of 1-256 blocks at the start of the LUN");
|
logging(LOG_VERBOSE, "Test GET_LBA_STATUS of 1-256 blocks at the start of the LUN");
|
||||||
for (i = 1; i <= 256; i++) {
|
for (i = 1; i <= 256; i++) {
|
||||||
ret = get_lba_status(iscsic, tgt_lun, 0, 24);
|
ret = get_lba_status(iscsic, tgt_lun, 0, 24, NULL);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test");
|
CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
if (ret != 0) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Test GET_LBA_STATUS of 1-256 blocks at the end of the LUN");
|
logging(LOG_VERBOSE, "Test GET_LBA_STATUS of 1-256 blocks at the end of the LUN");
|
||||||
for (i = 1; i <= 256; i++) {
|
for (i = 1; i <= 256; i++) {
|
||||||
ret = get_lba_status(iscsic, tgt_lun, num_blocks - i, 24);
|
ret = get_lba_status(iscsic, tgt_lun, num_blocks - i, 24, NULL);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
if (ret != 0) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,8 @@ test_get_lba_status_unmap_single(void)
|
|||||||
int ret;
|
int ret;
|
||||||
uint64_t i;
|
uint64_t i;
|
||||||
unsigned char *buf = alloca(257 * block_size);
|
unsigned char *buf = alloca(257 * block_size);
|
||||||
struct scsi_task *task_ret;
|
|
||||||
struct unmap_list list[1];
|
struct unmap_list list[1];
|
||||||
struct scsi_get_lba_status *lbas = NULL;
|
enum scsi_provisioning_type provisioning;
|
||||||
struct scsi_lba_status_descriptor *lbasd = NULL;
|
|
||||||
|
|
||||||
CHECK_FOR_DATALOSS;
|
CHECK_FOR_DATALOSS;
|
||||||
CHECK_FOR_THIN_PROVISIONING;
|
CHECK_FOR_THIN_PROVISIONING;
|
||||||
@@ -48,12 +46,14 @@ test_get_lba_status_unmap_single(void)
|
|||||||
"at offset 0-255");
|
"at offset 0-255");
|
||||||
logging(LOG_VERBOSE, "We have %d logical blocks per physical block",
|
logging(LOG_VERBOSE, "We have %d logical blocks per physical block",
|
||||||
lbppb);
|
lbppb);
|
||||||
for (i = 0; i + lbppb <= 256; i += lbppb) {
|
|
||||||
logging(LOG_VERBOSE, "Write the first 257 blocks with a known "
|
|
||||||
"pattern and thus map the blocks");
|
|
||||||
ret = write10(iscsic, tgt_lun, 0, 257 * block_size,
|
|
||||||
block_size, 0, 0, 0, 0, 0, buf);
|
|
||||||
|
|
||||||
|
logging(LOG_VERBOSE, "Write the first %i blocks with a known "
|
||||||
|
"pattern and thus map the blocks", 256 + lbppb);
|
||||||
|
ret = write10(iscsic, tgt_lun, 0, (256 + lbppb) * block_size,
|
||||||
|
block_size, 0, 0, 0, 0, 0, buf);
|
||||||
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
for (i = 0; i + lbppb <= 256; i += lbppb) {
|
||||||
logging(LOG_VERBOSE, "Unmap a single physical block at LBA:%"
|
logging(LOG_VERBOSE, "Unmap a single physical block at LBA:%"
|
||||||
PRIu64 " (number of logical blocks: %d)", i, lbppb);
|
PRIu64 " (number of logical blocks: %d)", i, lbppb);
|
||||||
list[0].lba = i;
|
list[0].lba = i;
|
||||||
@@ -63,48 +63,35 @@ test_get_lba_status_unmap_single(void)
|
|||||||
|
|
||||||
logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
|
logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
|
||||||
PRIu64, i);
|
PRIu64, i);
|
||||||
task_ret = get_lba_status_task(iscsic, tgt_lun, i, 24);
|
ret = get_lba_status(iscsic, tgt_lun, i, 24, NULL);
|
||||||
if (!task_ret) {
|
if (ret == -2) {
|
||||||
CU_PASS("[SKIPPED] Target does not support "
|
CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test");
|
||||||
"GET_LBA_STATUS. Skipping test");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (ret != 0) {
|
||||||
lbas = scsi_datain_unmarshall(task_ret);
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
if (lbas == NULL) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
|
|
||||||
"failed to unmarschall data.");
|
|
||||||
CU_FAIL("[FAILED] GET_LBA_STATUS command: "
|
|
||||||
"failed to unmarschall data.");
|
|
||||||
scsi_free_scsi_task(task_ret);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lbasd = &lbas->descriptors[0];
|
logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
|
||||||
|
PRIu64, i + lbppb);
|
||||||
|
ret = get_lba_status(iscsic, tgt_lun, i + lbppb, 24, &provisioning);
|
||||||
logging(LOG_VERBOSE, "Verify that the LBA in the first "
|
if (ret != 0) {
|
||||||
"descriptor matches the LBA in the CDB");
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
if (lbasd->lba != i) {
|
return;
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
|
}
|
||||||
"LBA offset in first descriptor does not match "
|
if (provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
|
||||||
"request (0x%" PRIx64 " != 0x%" PRIx64 ").",
|
CU_FAIL("[FAILED] LBA should be mapped but isn't");
|
||||||
lbasd->lba, i);
|
|
||||||
CU_FAIL("[FAILED] GET_LBA_STATUS command: "
|
|
||||||
"LBA offset in first descriptor does not match "
|
|
||||||
"the LBA in the CDB.");
|
|
||||||
scsi_free_scsi_task(task_ret);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scsi_free_scsi_task(task_ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test GET_LBA_STATUS for a single range of 1-255 "
|
logging(LOG_VERBOSE, "Test GET_LBA_STATUS for a single range of 1-255 "
|
||||||
"blocks at offset 0");
|
"blocks at offset 0");
|
||||||
for (i = lbppb; i + lbppb <= 256; i += lbppb) {
|
for (i = lbppb; i + lbppb <= 256; i += lbppb) {
|
||||||
logging(LOG_VERBOSE, "Write the first 257 blocks with a known "
|
logging(LOG_VERBOSE, "Write the first %i blocks with a known "
|
||||||
"pattern and thus map the blocks");
|
"pattern and thus map the blocks", (256 + lbppb));
|
||||||
ret = write10(iscsic, tgt_lun, 0, 257 * block_size,
|
ret = write10(iscsic, tgt_lun, 0, (256 + lbppb) * block_size,
|
||||||
block_size, 0, 0, 0, 0, 0, buf);
|
block_size, 0, 0, 0, 0, 0, buf);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Unmap %" PRIu64 " blocks at LBA 0", i);
|
logging(LOG_VERBOSE, "Unmap %" PRIu64 " blocks at LBA 0", i);
|
||||||
@@ -113,33 +100,26 @@ test_get_lba_status_unmap_single(void)
|
|||||||
ret = unmap(iscsic, tgt_lun, 0, list, 1);
|
ret = unmap(iscsic, tgt_lun, 0, list, 1);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Read the status of the block at LBA 0");
|
logging(LOG_VERBOSE, "Read the status of the block at LBA:0");
|
||||||
task_ret = get_lba_status_task(iscsic, tgt_lun, 0, 24);
|
|
||||||
lbas = scsi_datain_unmarshall(task_ret);
|
ret = get_lba_status(iscsic, tgt_lun, 0, 24, NULL);
|
||||||
if (lbas == NULL) {
|
if (ret == -2) {
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
|
CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test");
|
||||||
"failed to unmarschall data.");
|
|
||||||
CU_FAIL("[FAILED] GET_LBA_STATUS command: "
|
|
||||||
"failed to unmarschall data.");
|
|
||||||
scsi_free_scsi_task(task_ret);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lbasd = &lbas->descriptors[0];
|
if (ret != 0) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
|
return;
|
||||||
logging(LOG_VERBOSE, "Verify that the LBA in the first "
|
}
|
||||||
"descriptor matches the LBA in the CDB");
|
logging(LOG_VERBOSE, "Read the status of the block at LBA:%" PRIu64, i + 1);
|
||||||
if (lbasd->lba != 0) {
|
ret = get_lba_status(iscsic, tgt_lun, i + 1, 24, &provisioning);
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
|
if (ret != 0) {
|
||||||
"LBA offset in first descriptor does not match "
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
"request (0x%" PRIx64 " != 0x%" PRIx64 ").",
|
return;
|
||||||
lbasd->lba, i);
|
}
|
||||||
CU_FAIL("[FAILED] GET_LBA_STATUS command: "
|
if (provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
|
||||||
"LBA offset in first descriptor does not match "
|
CU_FAIL("[FAILED] LBA should be mapped but isn't");
|
||||||
"the LBA in the CDB.");
|
|
||||||
scsi_free_scsi_task(task_ret);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scsi_free_scsi_task(task_ret);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user