TESTS: UNMAP make sure we read the blocks back as 0 after unmap
This commit is contained in:
@@ -200,6 +200,7 @@ test_sanitize_block_erase(void)
|
|||||||
logging(LOG_VERBOSE, "Test SANITIZE BLOCK ERASE");
|
logging(LOG_VERBOSE, "Test SANITIZE BLOCK ERASE");
|
||||||
|
|
||||||
CHECK_FOR_SANITIZE;
|
CHECK_FOR_SANITIZE;
|
||||||
|
CHECK_FOR_DATALOSS;
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Check that SANITIZE BLOCK_ERASE is supported "
|
logging(LOG_NORMAL, "Check that SANITIZE BLOCK_ERASE is supported "
|
||||||
"in REPORT_SUPPORTED_OPCODES");
|
"in REPORT_SUPPORTED_OPCODES");
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ void test_sanitize_block_erase_reserved(void)
|
|||||||
logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE Reserved bits/bytes");
|
logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE Reserved bits/bytes");
|
||||||
|
|
||||||
CHECK_FOR_SANITIZE;
|
CHECK_FOR_SANITIZE;
|
||||||
|
CHECK_FOR_DATALOSS;
|
||||||
|
|
||||||
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ test_sanitize_crypto_erase(void)
|
|||||||
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO ERASE");
|
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO ERASE");
|
||||||
|
|
||||||
CHECK_FOR_SANITIZE;
|
CHECK_FOR_SANITIZE;
|
||||||
|
CHECK_FOR_DATALOSS;
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Check that SANITIZE CRYPTO_ERASE is supported "
|
logging(LOG_NORMAL, "Check that SANITIZE CRYPTO_ERASE is supported "
|
||||||
"in REPORT_SUPPORTED_OPCODES");
|
"in REPORT_SUPPORTED_OPCODES");
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ void test_sanitize_crypto_erase_reserved(void)
|
|||||||
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE Reserved bits/bytes");
|
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE Reserved bits/bytes");
|
||||||
|
|
||||||
CHECK_FOR_SANITIZE;
|
CHECK_FOR_SANITIZE;
|
||||||
|
CHECK_FOR_DATALOSS;
|
||||||
|
|
||||||
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ test_sanitize_exit_failure_mode(void)
|
|||||||
logging(LOG_VERBOSE, "Test SANITIZE EXIT FAILURE MODE");
|
logging(LOG_VERBOSE, "Test SANITIZE EXIT FAILURE MODE");
|
||||||
|
|
||||||
CHECK_FOR_SANITIZE;
|
CHECK_FOR_SANITIZE;
|
||||||
|
CHECK_FOR_DATALOSS;
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Check that SANITIZE EXIT FAILURE MODE is "
|
logging(LOG_NORMAL, "Check that SANITIZE EXIT FAILURE MODE is "
|
||||||
"supported in REPORT_SUPPORTED_OPCODES");
|
"supported in REPORT_SUPPORTED_OPCODES");
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ test_sanitize_overwrite(void)
|
|||||||
logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE");
|
logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE");
|
||||||
|
|
||||||
CHECK_FOR_SANITIZE;
|
CHECK_FOR_SANITIZE;
|
||||||
|
CHECK_FOR_DATALOSS;
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Check that SANITIZE OVERWRITE is supported "
|
logging(LOG_NORMAL, "Check that SANITIZE OVERWRITE is supported "
|
||||||
"in REPORT_SUPPORTED_OPCODES");
|
"in REPORT_SUPPORTED_OPCODES");
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ void test_sanitize_overwrite_reserved(void)
|
|||||||
logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE Reserved bits/bytes");
|
logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE Reserved bits/bytes");
|
||||||
|
|
||||||
CHECK_FOR_SANITIZE;
|
CHECK_FOR_SANITIZE;
|
||||||
|
CHECK_FOR_DATALOSS;
|
||||||
|
|
||||||
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <alloca.h>
|
||||||
|
|
||||||
#include <CUnit/CUnit.h>
|
#include <CUnit/CUnit.h>
|
||||||
|
|
||||||
@@ -30,26 +31,84 @@ test_unmap_simple(void)
|
|||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
struct unmap_list list[257];
|
struct unmap_list list[257];
|
||||||
|
unsigned char *buf = alloca(256 * block_size);
|
||||||
|
unsigned char *zbuf = alloca(256 * block_size);
|
||||||
|
|
||||||
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
|
logging(LOG_VERBOSE, "Test basic UNMAP");
|
||||||
|
|
||||||
CHECK_FOR_DATALOSS;
|
CHECK_FOR_DATALOSS;
|
||||||
CHECK_FOR_THIN_PROVISIONING;
|
CHECK_FOR_THIN_PROVISIONING;
|
||||||
CHECK_FOR_SBC;
|
CHECK_FOR_SBC;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
|
||||||
logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the LUN as a single descriptor");
|
logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the "
|
||||||
|
"LUN as a single descriptor");
|
||||||
|
logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
|
||||||
|
memset(buf, 'a', 256 * block_size);
|
||||||
|
memset(zbuf, 0, 256 * block_size);
|
||||||
|
ret = write10(iscsic, tgt_lun, 0, 256 * block_size,
|
||||||
|
block_size, 0, 0, 0, 0, 0, buf);
|
||||||
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
for (i = 1; i <= 256; i++) {
|
for (i = 1; i <= 256; i++) {
|
||||||
|
logging(LOG_VERBOSE, "UNMAP blocks 0-%d", i);
|
||||||
list[0].lba = 0;
|
list[0].lba = 0;
|
||||||
list[0].num = i;
|
list[0].num = i;
|
||||||
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 blocks 0-%d", i);
|
||||||
|
ret = read10(iscsic, tgt_lun, 0, i * block_size,
|
||||||
|
block_size, 0, 0, 0, 0, 0, buf);
|
||||||
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
if (rc16 && rc16->lbprz) {
|
||||||
|
logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
|
||||||
|
"should read back as 0");
|
||||||
|
if (memcmp(buf, zbuf, i * block_size)) {
|
||||||
|
logging(LOG_NORMAL, "[FAILED] Blocks did not "
|
||||||
|
"read back as zero");
|
||||||
|
CU_FAIL("[FAILED] Blocks did not read back "
|
||||||
|
"as zero");
|
||||||
|
} else {
|
||||||
|
logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
|
||||||
|
"back as zero");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the "
|
||||||
logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the LUN with one descriptor per block");
|
"LUN with one descriptor per block");
|
||||||
|
logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
|
||||||
|
memset(buf, 'a', 256 * block_size);
|
||||||
|
memset(zbuf, 0, 256 * block_size);
|
||||||
|
ret = write10(iscsic, tgt_lun, 0, 256 * block_size,
|
||||||
|
block_size, 0, 0, 0, 0, 0, buf);
|
||||||
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
list[i].lba = i;
|
list[i].lba = i;
|
||||||
list[i].num = 1;
|
list[i].num = 1;
|
||||||
ret = unmap(iscsic, tgt_lun, 0, list, i + 1);
|
ret = unmap(iscsic, tgt_lun, 0, list, i + 1);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
logging(LOG_VERBOSE, "Read blocks 0-%d", i);
|
||||||
|
ret = read10(iscsic, tgt_lun, 0, i * block_size,
|
||||||
|
block_size, 0, 0, 0, 0, 0, buf);
|
||||||
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
if (rc16 && rc16->lbprz) {
|
||||||
|
logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
|
||||||
|
"should read back as 0");
|
||||||
|
if (memcmp(buf, zbuf, i * block_size)) {
|
||||||
|
logging(LOG_NORMAL, "[FAILED] Blocks did not "
|
||||||
|
"read back as zero");
|
||||||
|
CU_FAIL("[FAILED] Blocks did not read back "
|
||||||
|
"as zero");
|
||||||
|
} else {
|
||||||
|
logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
|
||||||
|
"back as zero");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user