TESTS: Change all tests to use 'block_size' instead of hardcoded 512
This should allow the testst to work corectly on block devices with 4k blocksize too.
This commit is contained in:
@@ -27,6 +27,8 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_standard *inq;
|
||||
struct scsi_readcapacity10 *rc10;
|
||||
uint32_t block_size;
|
||||
int ret, lun;
|
||||
|
||||
printf("0104_read10_flags:\n");
|
||||
@@ -48,9 +50,6 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
/* This test is only valid for SBC devices */
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64);
|
||||
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
|
||||
@@ -69,6 +68,33 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* find the size of the LUN */
|
||||
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
|
||||
if (task == NULL) {
|
||||
printf("Failed to send readcapacity10 command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto finished;
|
||||
}
|
||||
rc10 = scsi_datain_unmarshall(task);
|
||||
if (rc10 == NULL) {
|
||||
printf("failed to unmarshall readcapacity10 data. %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto finished;
|
||||
}
|
||||
block_size = rc10->block_size;
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
/* Try out DPO : 1 */
|
||||
printf("Read10 with DPO==1 ... ");
|
||||
|
||||
@@ -85,7 +111,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
|
||||
task->cdb[8] = 1;
|
||||
task->cdb_size = 10;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
task->expxferlen = 512;
|
||||
task->expxferlen = block_size;
|
||||
|
||||
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
@@ -122,7 +148,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
|
||||
task->cdb[8] = 1;
|
||||
task->cdb_size = 10;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
task->expxferlen = 512;
|
||||
task->expxferlen = block_size;
|
||||
|
||||
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
@@ -158,7 +184,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
|
||||
task->cdb[8] = 1;
|
||||
task->cdb_size = 10;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
task->expxferlen = 512;
|
||||
task->expxferlen = block_size;
|
||||
|
||||
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
@@ -194,7 +220,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
|
||||
task->cdb[8] = 1;
|
||||
task->cdb_size = 10;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
task->expxferlen = 512;
|
||||
task->expxferlen = block_size;
|
||||
|
||||
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
@@ -230,7 +256,7 @@ int T0104_read10_flags(const char *initiator, const char *url, int data_loss _U_
|
||||
task->cdb[8] = 1;
|
||||
task->cdb_size = 10;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
task->expxferlen = 512;
|
||||
task->expxferlen = block_size;
|
||||
|
||||
if (iscsi_scsi_command_sync(iscsi, lun, task, NULL) == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
|
||||
Reference in New Issue
Block a user