Skip test_writesame1[06]_unmap large len test for small disks

Only perform the test with 65536 blocks on block devices with at
least that number of blocks. Fix the 65536 block test log message.
Generalize the WRITE SAME(10) 256-block test log messages. Fix
interpretation of the MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT field.
A quote from SPC-4: "If there is no limit on the number of UNMAP
block descriptors contained in the parameter data, then the device
server shall set the MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT field to
FFFF_FFFFh."

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2014-08-18 10:58:49 +02:00
committed by Ronnie Sahlberg
parent 1deb4f8e4a
commit d4ac9ef1b5
2 changed files with 20 additions and 17 deletions

View File

@@ -29,8 +29,8 @@
void
test_writesame10_unmap(void)
{
int i, ret;
unsigned int j;
int ret;
unsigned int i, j;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -148,11 +148,12 @@ test_writesame10_unmap(void)
}
i = 256;
if (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= 256) {
if (i <= num_blocks
&& (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
"as either 0 (==no limit) or >= 256. Test Unmapping "
"256 blocks to verify that it can handle 2-byte "
"lengths");
"as either 0 (==no limit) or >= %d. Test Unmapping "
"%d blocks to verify that it can handle 2-byte "
"lengths", i, i);
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
@@ -186,7 +187,7 @@ test_writesame10_unmap(void)
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
}
} else {
} else if (i <= num_blocks) {
logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
"as <256. Verify that a 256 block unmap fails with "
"INVALID_FIELD_IN_CDB.");

View File

@@ -146,11 +146,12 @@ test_writesame16_unmap(void)
}
i = 256;
if (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= 256) {
if (i <= num_blocks
&& (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
"as either 0 (==no limit) or >= 256. Test Unmapping "
"256 blocks to verify that it can handle 2-byte "
"lengths");
"as either 0 (==no limit) or >= %d. Test Unmapping "
"%d blocks to verify that it can handle 2-byte "
"lengths", i, i);
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
@@ -182,7 +183,7 @@ test_writesame16_unmap(void)
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
}
} else {
} else if (i <= num_blocks) {
logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
"as <256. Verify that a 256 block unmap fails with "
"INVALID_FIELD_IN_CDB.");
@@ -196,11 +197,12 @@ test_writesame16_unmap(void)
i = 65536;
if (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= 256) {
if (i <= num_blocks
&& (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
"as either 0 (==no limit) or >= 256. Test Unmapping "
"256 blocks to verify that it can handle 2-byte "
"lengths");
"as either 0 (==no limit) or >= %d. Test Unmapping "
"%d blocks to verify that it can handle 4-byte "
"lengths", i, i);
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
@@ -232,7 +234,7 @@ test_writesame16_unmap(void)
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
}
} else {
} else if (i <= num_blocks) {
logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
"as <256. Verify that a 256 block unmap fails with "
"INVALID_FIELD_IN_CDB.");