TESTS: change get_lba_status to new api
Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
This commit is contained in:
committed by
Ronnie Sahlberg
parent
fd21a8f2c4
commit
9e75b10103
+15
-156
@@ -1368,169 +1368,28 @@ int compareandwrite(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct scsi_task *get_lba_status_task(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len)
|
int get_lba_status(struct iscsi_context *iscsi, struct scsi_task **out_task, int lun, uint64_t lba, uint32_t len, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
|
||||||
{
|
{
|
||||||
struct scsi_task *task;
|
struct scsi_task *task;
|
||||||
|
int ret;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send GET_LBA_STATUS LBA:%" PRIu64 " alloc_len:%d",
|
logging(LOG_VERBOSE, "Send GET_LBA_STATUS (Expecting %s) LBA:%" PRIu64
|
||||||
|
" alloc_len:%d",
|
||||||
|
scsi_status_str(status),
|
||||||
lba, len);
|
lba, len);
|
||||||
|
|
||||||
task = iscsi_get_lba_status_sync(iscsi, lun, lba, len);
|
task = scsi_cdb_get_lba_status(lba, len);
|
||||||
if (task == NULL) {
|
assert(task != NULL);
|
||||||
logging(LOG_NORMAL, "[FAILED] Failed to send GET_LBA_STATUS "
|
|
||||||
"command: %s",
|
task = iscsi_scsi_command_sync(iscsi, lun, task, NULL);
|
||||||
iscsi_get_error(iscsi));
|
|
||||||
return NULL;
|
ret = check_result("GET_LBA_STATUS", iscsi, task, status, key, ascq, num_ascq);
|
||||||
}
|
if (out_task) {
|
||||||
if (task->status == SCSI_STATUS_CHECK_CONDITION
|
*out_task = task;
|
||||||
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
|
} else if (task) {
|
||||||
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
|
|
||||||
logging(LOG_NORMAL, "[SKIPPED] GET_LBA_STATUS is not "
|
|
||||||
"implemented on target");
|
|
||||||
scsi_free_scsi_task(task);
|
scsi_free_scsi_task(task);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
logging(LOG_VERBOSE, "[OK] GET_LBA_STATUS returned SUCCESS.");
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
|
|
||||||
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_get_lba_status *lbas = NULL;
|
|
||||||
struct scsi_lba_status_descriptor *lbasd = NULL;
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send GET_LBA_STATUS LBA:%" PRIu64 " alloc_len:%d",
|
|
||||||
lba, len);
|
|
||||||
|
|
||||||
task = iscsi_get_lba_status_sync(iscsi, lun, lba, len);
|
|
||||||
if (task == NULL) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] Failed to send GET_LBA_STATUS "
|
|
||||||
"command: %s",
|
|
||||||
iscsi_get_error(iscsi));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (task->status == SCSI_STATUS_CHECK_CONDITION
|
|
||||||
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
|
|
||||||
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
|
|
||||||
logging(LOG_NORMAL, "[SKIPPED] GET_LBA_STATUS is not "
|
|
||||||
"implemented on target");
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
if (task->status != SCSI_STATUS_GOOD) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
|
|
||||||
"failed with sense. %s", iscsi_get_error(iscsi));
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
lbas = scsi_datain_unmarshall(task);
|
|
||||||
if (lbas == NULL) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
|
|
||||||
"failed to unmarschall data.");
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
lbasd = &lbas->descriptors[0];
|
|
||||||
if (lbasd->lba != lba) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
|
|
||||||
"lba offset in first descriptor does not match request (0x%" PRIx64 " != 0x%" PRIx64 ").",
|
|
||||||
lbasd->lba, lba);
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (provisioning0 != NULL) {
|
|
||||||
*provisioning0 = lbasd->provisioning;
|
|
||||||
}
|
|
||||||
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
logging(LOG_VERBOSE, "[OK] GET_LBA_STATUS returned SUCCESS.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_lba_status_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len)
|
|
||||||
{
|
|
||||||
struct scsi_task *task;
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send GET_LBA_STATUS (Expecting LBA_OUT_OF_RANGE) LBA:%" PRIu64 " alloc_len:%d",
|
|
||||||
lba, len);
|
|
||||||
|
|
||||||
task = iscsi_get_lba_status_sync(iscsi, lun, lba, len);
|
|
||||||
if (task == NULL) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] Failed to send GET_LBA_STATUS "
|
|
||||||
"command: %s",
|
|
||||||
iscsi_get_error(iscsi));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (task->status == SCSI_STATUS_CHECK_CONDITION
|
|
||||||
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
|
|
||||||
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
|
|
||||||
logging(LOG_NORMAL, "[SKIPPED] GET_LBA_STATUS is not "
|
|
||||||
"implemented on target");
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
if (task->status == SCSI_STATUS_GOOD) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS returned SUCCESS. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
|
||||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
|
||||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS failed with the wrong sense code. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE but failed with sense:%s", iscsi_get_error(iscsi));
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
logging(LOG_VERBOSE, "[OK] GET_LBA_STATUS returned ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_lba_status_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len)
|
|
||||||
{
|
|
||||||
struct scsi_task *task;
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send GET_LBA_STATUS (Expecting MEDIUM_NOT_PRESENT) "
|
|
||||||
"LBA:%" PRIu64 " alloc_len:%d",
|
|
||||||
lba, len);
|
|
||||||
|
|
||||||
task = iscsi_get_lba_status_sync(iscsi, lun, lba, len);
|
|
||||||
if (task == NULL) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] Failed to send GET_LBA_STATUS "
|
|
||||||
"command: %s",
|
|
||||||
iscsi_get_error(iscsi));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (task->status == SCSI_STATUS_CHECK_CONDITION
|
|
||||||
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
|
|
||||||
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
|
|
||||||
logging(LOG_NORMAL, "[SKIPPED] GET_LBA_STATUS is not "
|
|
||||||
"implemented on target");
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
if (task->status == SCSI_STATUS_GOOD) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS returned SUCCESS. Should have failed with MEDIUM_NOT_PRESENT.");
|
|
||||||
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_MEDIUM_NOT_PRESENT
|
|
||||||
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN
|
|
||||||
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS failed with the wrong sense code. Should have failed with NOT_READY/MEDIUM_NOT_PRESENT but failed with sense:%s", iscsi_get_error(iscsi));
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
logging(LOG_VERBOSE, "[OK] GET_LBA_STATUS returned MEDIUM_NOT_PRESENT.");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -253,11 +253,8 @@ int verify_read_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf);
|
|||||||
int verify_write_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf);
|
int verify_write_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf);
|
||||||
int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize, struct scsi_task **save_task);
|
int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize, struct scsi_task **save_task);
|
||||||
int inquiry_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize);
|
int inquiry_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize);
|
||||||
struct scsi_task *get_lba_status_task(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
|
|
||||||
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 status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
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 status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||||
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(struct iscsi_context *iscsi, struct scsi_task **task, int lun, uint64_t lba, uint32_t len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||||
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 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 status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
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 status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||||
int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||||
int prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
int prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ test_get_lba_status_beyond_eol(void)
|
|||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test GET_LBA_STATUS one block beyond the end of the LUN");
|
logging(LOG_VERBOSE, "Test GET_LBA_STATUS one block beyond the end of the LUN");
|
||||||
|
|
||||||
ret = get_lba_status_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 24);
|
ret = get_lba_status(iscsic, NULL, tgt_lun, num_blocks + 1, 24,
|
||||||
|
EXPECT_LBA_OOB);
|
||||||
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;
|
||||||
@@ -42,11 +43,13 @@ test_get_lba_status_beyond_eol(void)
|
|||||||
|
|
||||||
logging(LOG_VERBOSE, "Test GET_LBA_STATUS at LBA 2^63");
|
logging(LOG_VERBOSE, "Test GET_LBA_STATUS at LBA 2^63");
|
||||||
|
|
||||||
ret = get_lba_status_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000ULL, 24);
|
ret = get_lba_status(iscsic, NULL, tgt_lun, 0x8000000000000000ULL, 24,
|
||||||
|
EXPECT_LBA_OOB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Test GET_LBA_STATUS at LBA -1");
|
logging(LOG_VERBOSE, "Test GET_LBA_STATUS at LBA -1");
|
||||||
|
|
||||||
ret = get_lba_status_lbaoutofrange(iscsic, tgt_lun, 0xffffffffffffffffULL, 24);
|
ret = get_lba_status(iscsic, NULL, tgt_lun, 0xffffffffffffffffULL, 24,
|
||||||
|
EXPECT_LBA_OOB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ 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, NULL);
|
ret = get_lba_status(iscsic, NULL, tgt_lun, 0, 24,
|
||||||
|
EXPECT_STATUS_GOOD);
|
||||||
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;
|
||||||
@@ -47,7 +48,8 @@ test_get_lba_status_simple(void)
|
|||||||
|
|
||||||
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, NULL);
|
ret = get_lba_status(iscsic, NULL, tgt_lun, num_blocks - i, 24,
|
||||||
|
EXPECT_STATUS_GOOD);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#include "iscsi-support.h"
|
#include "iscsi-support.h"
|
||||||
#include "iscsi-test-cu.h"
|
#include "iscsi-test-cu.h"
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
test_get_lba_status_unmap_single(void)
|
test_get_lba_status_unmap_single(void)
|
||||||
{
|
{
|
||||||
@@ -33,7 +32,9 @@ test_get_lba_status_unmap_single(void)
|
|||||||
uint64_t i;
|
uint64_t i;
|
||||||
unsigned char *buf = alloca(257 * block_size);
|
unsigned char *buf = alloca(257 * block_size);
|
||||||
struct unmap_list list[1];
|
struct unmap_list list[1];
|
||||||
enum scsi_provisioning_type provisioning;
|
struct scsi_task *t = NULL;
|
||||||
|
struct scsi_get_lba_status *lbas = NULL;
|
||||||
|
struct scsi_lba_status_descriptor *lbasd = NULL;
|
||||||
|
|
||||||
CHECK_FOR_DATALOSS;
|
CHECK_FOR_DATALOSS;
|
||||||
CHECK_FOR_THIN_PROVISIONING;
|
CHECK_FOR_THIN_PROVISIONING;
|
||||||
@@ -64,7 +65,8 @@ 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);
|
||||||
ret = get_lba_status(iscsic, tgt_lun, i, 24, NULL);
|
ret = get_lba_status(iscsic, NULL, tgt_lun, i, 24,
|
||||||
|
EXPECT_STATUS_GOOD);
|
||||||
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;
|
||||||
@@ -75,15 +77,36 @@ 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 + lbppb);
|
PRIu64, i + lbppb);
|
||||||
ret = get_lba_status(iscsic, tgt_lun, i + lbppb, 24, &provisioning);
|
ret = get_lba_status(iscsic, &t, tgt_lun, i + lbppb, 24,
|
||||||
|
EXPECT_STATUS_GOOD);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
|
if (t == NULL) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS task is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lbas = scsi_datain_unmarshall(t);
|
||||||
|
if (lbas == NULL) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS command: failed "
|
||||||
|
"to unmarshall data.");
|
||||||
|
scsi_free_scsi_task(t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lbasd = &lbas->descriptors[0];
|
||||||
|
if (lbasd->lba != i + lbppb) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS command: "
|
||||||
|
"lba offset in first descriptor does not "
|
||||||
|
"match request.");
|
||||||
|
scsi_free_scsi_task(t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lbasd->provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
|
||||||
CU_FAIL("[FAILED] LBA should be mapped but isn't");
|
CU_FAIL("[FAILED] LBA should be mapped but isn't");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
scsi_free_scsi_task(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
@@ -104,7 +127,8 @@ test_get_lba_status_unmap_single(void)
|
|||||||
|
|
||||||
logging(LOG_VERBOSE, "Read the status of the block at LBA:0");
|
logging(LOG_VERBOSE, "Read the status of the block at LBA:0");
|
||||||
|
|
||||||
ret = get_lba_status(iscsic, tgt_lun, 0, 24, NULL);
|
ret = get_lba_status(iscsic, NULL, tgt_lun, 0, 24,
|
||||||
|
EXPECT_STATUS_GOOD);
|
||||||
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;
|
||||||
@@ -114,14 +138,35 @@ test_get_lba_status_unmap_single(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logging(LOG_VERBOSE, "Read the status of the block at LBA:%" PRIu64, i + 1);
|
logging(LOG_VERBOSE, "Read the status of the block at LBA:%" PRIu64, i + 1);
|
||||||
ret = get_lba_status(iscsic, tgt_lun, i + 1, 24, &provisioning);
|
ret = get_lba_status(iscsic, &t, tgt_lun, i + 1, 24,
|
||||||
|
EXPECT_STATUS_GOOD);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
|
if (t == NULL) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS task is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lbas = scsi_datain_unmarshall(t);
|
||||||
|
if (lbas == NULL) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS command: failed "
|
||||||
|
"to unmarshall data.");
|
||||||
|
scsi_free_scsi_task(t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lbasd = &lbas->descriptors[0];
|
||||||
|
if (lbasd->lba != i + lbppb) {
|
||||||
|
CU_FAIL("[FAILED] GET_LBA_STATUS command: "
|
||||||
|
"lba offset in first descriptor does not "
|
||||||
|
"match request.");
|
||||||
|
scsi_free_scsi_task(t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lbasd->provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
|
||||||
CU_FAIL("[FAILED] LBA should be mapped but isn't");
|
CU_FAIL("[FAILED] LBA should be mapped but isn't");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
scsi_free_scsi_task(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ test_nomedia_sbc(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Test GET_LBA_STATUS when medium is ejected.");
|
logging(LOG_VERBOSE, "Test GET_LBA_STATUS when medium is ejected.");
|
||||||
ret = get_lba_status_nomedium(iscsic, tgt_lun, 0, 24);
|
ret = get_lba_status(iscsic, NULL, tgt_lun, 0, 24,
|
||||||
|
EXPECT_NO_MEDIUM);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
logging(LOG_NORMAL, "[SKIPPED] target does not support "
|
logging(LOG_NORMAL, "[SKIPPED] target does not support "
|
||||||
"GET_LBA_STATUS");
|
"GET_LBA_STATUS");
|
||||||
|
|||||||
@@ -103,12 +103,13 @@ static void
|
|||||||
check_unmap(void)
|
check_unmap(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct scsi_task *task_ret;
|
struct scsi_task *task_ret = NULL;
|
||||||
struct scsi_get_lba_status *lbas;
|
struct scsi_get_lba_status *lbas;
|
||||||
uint64_t lba;
|
uint64_t lba;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Read LBA mapping from the target");
|
logging(LOG_VERBOSE, "Read LBA mapping from the target");
|
||||||
task_ret = get_lba_status_task(iscsic, tgt_lun, 0, 256);
|
get_lba_status(iscsic, &task_ret, tgt_lun, 0, 256,
|
||||||
|
EXPECT_STATUS_GOOD);
|
||||||
if (task_ret == NULL) {
|
if (task_ret == NULL) {
|
||||||
logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping "
|
logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping "
|
||||||
"from the target.");
|
"from the target.");
|
||||||
|
|||||||
Reference in New Issue
Block a user