TESTS: Dont assume atomic align/granularity is always reported as non-0
From Alexander Motin <mav@freebsd.org> Treat BlockLimits VPD atomic granulatity/alignment reported as 0 (no restrictions) as == 1 (also means no restriction). Both 0 and 1 mean that there is no restriction on alignment or granularity but with the difference being that the second value can be used to increment to the next valid LBA. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -26,12 +26,13 @@
|
||||
void
|
||||
test_writeatomic16_0blocks(void)
|
||||
{
|
||||
int ret;
|
||||
int align, ret;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
align = inq_bl->atomic_align ? inq_bl->atomic_align : 1;
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==0");
|
||||
ret = writeatomic16(sd, 0, 0, block_size,
|
||||
0, 0, 0, 0, NULL,
|
||||
@@ -44,7 +45,7 @@ test_writeatomic16_0blocks(void)
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks one alignment past end-of-LUN");
|
||||
ret = writeatomic16(sd, num_blocks + inq_bl->atomic_align, 0,
|
||||
ret = writeatomic16(sd, num_blocks + align, 0,
|
||||
block_size, 0, 0, 0, 0, NULL,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
@@ -58,7 +59,7 @@ test_writeatomic16_0blocks(void)
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==-<alignment>");
|
||||
ret = writeatomic16(sd, -inq_bl->atomic_align, 0, block_size,
|
||||
ret = writeatomic16(sd, -align, 0, block_size,
|
||||
0, 0, 0, 0, NULL,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
void
|
||||
test_writeatomic16_beyond_eol(void)
|
||||
{
|
||||
int i, gran, ret;
|
||||
int align, i, gran, ret;
|
||||
unsigned char *buf = alloca(256 * 2 * block_size);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ test_writeatomic16_beyond_eol(void)
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
|
||||
align = inq_bl->atomic_align ? inq_bl->atomic_align : 1;
|
||||
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
|
||||
ret = writeatomic16(sd, 0,
|
||||
block_size * gran,
|
||||
@@ -51,7 +52,7 @@ test_writeatomic16_beyond_eol(void)
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks <granularity> blocks beyond the end");
|
||||
memset(buf, 0xa6, 256 * block_size);
|
||||
for (i = inq_bl->atomic_gran; i <= 256; i += inq_bl->atomic_gran) {
|
||||
for (i = gran; i <= 256; i += gran) {
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
break;
|
||||
}
|
||||
@@ -64,7 +65,7 @@ test_writeatomic16_beyond_eol(void)
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks at LBA==2^63");
|
||||
for (i = inq_bl->atomic_gran; i <= 256; i += inq_bl->atomic_gran) {
|
||||
for (i = gran; i <= 256; i += gran) {
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
break;
|
||||
}
|
||||
@@ -76,11 +77,11 @@ test_writeatomic16_beyond_eol(void)
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks at LBA==-<alignment>");
|
||||
for (i = inq_bl->atomic_gran; i <= 256; i += inq_bl->atomic_gran) {
|
||||
for (i = gran; i <= 256; i += gran) {
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
break;
|
||||
}
|
||||
ret = writeatomic16(sd, -inq_bl->atomic_align, i * block_size,
|
||||
ret = writeatomic16(sd, -align, i * block_size,
|
||||
block_size, 0, 0, 0, 0, buf,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
@@ -88,11 +89,11 @@ test_writeatomic16_beyond_eol(void)
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 2-256 blocks all but one block beyond the end");
|
||||
for (i = 2 * inq_bl->atomic_gran; i <= 256; i += inq_bl->atomic_gran) {
|
||||
for (i = 2 * gran; i <= 256; i += gran) {
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
break;
|
||||
}
|
||||
ret = writeatomic16(sd, num_blocks - inq_bl->atomic_gran,
|
||||
ret = writeatomic16(sd, num_blocks - gran,
|
||||
i * block_size, block_size, 0, 0, 0, 0, buf,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
@@ -53,7 +53,7 @@ test_writeatomic16_simple(void)
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 of 1-256 blocks at the start of the LUN");
|
||||
memset(buf, 0xa6, 256 * block_size);
|
||||
for (i = inq_bl->atomic_gran; i <= 256; i += inq_bl->atomic_gran) {
|
||||
for (i = gran; i <= 256; i += gran) {
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
break;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ test_writeatomic16_simple(void)
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITEATOMIC16 of 1-256 blocks at the end of the LUN");
|
||||
for (i = inq_bl->atomic_gran; i <= 256; i += inq_bl->atomic_gran) {
|
||||
for (i = gran; i <= 256; i += gran) {
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user