@@ -899,12 +899,14 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
switch (cdb[0]) {
case READ_6:
sectors = transport_get_sectors_6(cdb);
+ size = sbc_get_size(cmd, sectors);
cmd->t_task_lba = transport_lba_21(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
cmd->execute_cmd = sbc_execute_rw;
break;
case READ_10:
sectors = transport_get_sectors_10(cdb);
+ size = sbc_get_size(cmd, sectors);
cmd->t_task_lba = transport_lba_32(cdb);
if (sbc_check_dpofua(dev, cmd, cdb))
@@ -919,6 +921,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
break;
case READ_12:
sectors = transport_get_sectors_12(cdb);
+ size = sbc_get_size(cmd, sectors);
cmd->t_task_lba = transport_lba_32(cdb);
if (sbc_check_dpofua(dev, cmd, cdb))
@@ -933,6 +936,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
break;
case READ_16:
sectors = transport_get_sectors_16(cdb);
+ size = sbc_get_size(cmd, sectors);
cmd->t_task_lba = transport_lba_64(cdb);
if (sbc_check_dpofua(dev, cmd, cdb))
@@ -947,12 +951,14 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
break;
case WRITE_6:
sectors = transport_get_sectors_6(cdb);
+ size = sbc_get_size(cmd, sectors);
cmd->t_task_lba = transport_lba_21(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
cmd->execute_cmd = sbc_execute_rw;
break;
case WRITE_10:
sectors = transport_get_sectors_10(cdb);
+ size = sbc_get_size(cmd, sectors);
cmd->t_task_lba = transport_lba_32(cdb);
if (sbc_check_dpofua(dev, cmd, cdb))
@@ -974,6 +980,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
goto check_lba;
case WRITE_12:
sectors = transport_get_sectors_12(cdb);
+ size = sbc_get_size(cmd, sectors);
cmd->t_task_lba = transport_lba_32(cdb);
if (sbc_check_dpofua(dev, cmd, cdb))
@@ -988,6 +995,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
break;
case WRITE_16:
sectors = transport_get_sectors_16(cdb);
+ size = sbc_get_size(cmd, sectors);
cmd->t_task_lba = transport_lba_64(cdb);
if (sbc_check_dpofua(dev, cmd, cdb))
@@ -1005,6 +1013,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
!(cmd->se_cmd_flags & SCF_BIDI))
return TCM_INVALID_CDB_FIELD;
sectors = transport_get_sectors_10(cdb);
+ size = sbc_get_size(cmd, sectors);
if (sbc_check_dpofua(dev, cmd, cdb))
return TCM_INVALID_CDB_FIELD;
@@ -1024,6 +1033,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
switch (service_action) {
case XDWRITEREAD_32:
sectors = transport_get_sectors_32(cdb);
+ size = sbc_get_size(cmd, sectors);
if (sbc_check_dpofua(dev, cmd, cdb))
return TCM_INVALID_CDB_FIELD;
@@ -1116,7 +1126,13 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
sectors = transport_get_sectors_16(cdb);
cmd->t_task_lba = transport_lba_64(cdb);
}
+
+ /*
+ * XXX: why treat sectors / size check differently for
+ * the offload / non-offload cases?
+ */
if (ops->execute_sync_cache) {
+ size = sbc_get_size(cmd, sectors);
cmd->execute_cmd = ops->execute_sync_cache;
goto check_lba;
}
@@ -1205,9 +1221,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
end_lba, cmd->t_task_lba, sectors);
return TCM_ADDRESS_OUT_OF_RANGE;
}
-
- if (!(cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE))
- size = sbc_get_size(cmd, sectors);
}
return target_cmd_size_check(cmd, size);