Fix WRITE SAME data buffer length handling

From the SPC-4 paragraph about WRITE SAME(10): "The WRITE SAME (10)
command requests that the device server transfer a single logical
block from the Data-Out Buffer [ ... ]". Hence always pass a data
buffer when sending a WRITE SAME(10) command.

Set the NDOB bit in the WRITE SAME(16) command if no data out buffer
is present.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2014-08-18 08:37:30 +02:00
committed by Ronnie Sahlberg
parent e8c4be8f62
commit ded75ae18a
6 changed files with 22 additions and 15 deletions

View File

@@ -27,6 +27,7 @@ void
test_writesame10_0blocks(void)
{
int ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -41,7 +42,7 @@ test_writesame10_0blocks(void)
inq_bl->wsnz);
ret = writesame10(iscsic, tgt_lun, 0,
block_size, 0,
0, 0, 0, 0, NULL);
0, 0, 0, 0, buf);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
return;
@@ -60,20 +61,20 @@ test_writesame10_0blocks(void)
logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks one block past end-of-LUN");
ret = writesame10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1,
block_size, 0,
0, 0, 0, 0, NULL);
0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==2^31");
ret = writesame10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
block_size, 0,
0, 0, 0, 0, NULL);
0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==-1");
ret = writesame10_lbaoutofrange(iscsic, tgt_lun, -1,
block_size, 0,
0, 0, 0, 0, NULL);
0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -29,6 +29,7 @@ void
test_writesame10_unmap_unaligned(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
@@ -42,7 +43,7 @@ test_writesame10_unmap_unaligned(void)
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10 at LBA:%d", lbppb - i, i);
ret = writesame10_invalidfieldincdb(iscsic, tgt_lun, i,
block_size, lbppb - i,
0, 1, 0, 0, NULL);
0, 1, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -54,8 +54,8 @@ test_writesame10_unmap_until_end(void)
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
ret = writesame10(iscsic, tgt_lun, num_blocks - i,
0, i,
0, 1, 0, 0, NULL);
block_size, i,
0, 1, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
if (rc16->lbprz) {