Commit 64f1db38 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger

target: remove control CDB flags

We don't need three flags to classifiy the CDB as we can check for a NULL S/G
list for a dataless command, and can infer from the absence of the data flag
that we deal with a control CDB.  Also remove the _SG_IO from the data CDB
flag as all I/O is dont on S/G lists now.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent cb4f4d3c
...@@ -211,12 +211,11 @@ static void tcm_loop_submission_work(struct work_struct *work) ...@@ -211,12 +211,11 @@ static void tcm_loop_submission_work(struct work_struct *work)
/* /*
* Because some userspace code via scsi-generic do not memset their * Because some userspace code via scsi-generic do not memset their
* associated read buffers, go ahead and do that here for type * associated read buffers, go ahead and do that here for type
* SCF_SCSI_CONTROL_SG_IO_CDB. Also note that this is currently * non-data CDBs. Also note that this is currently guaranteed to be a
* guaranteed to be a single SGL for SCF_SCSI_CONTROL_SG_IO_CDB * single SGL for this case by target core in
* by target core in target_setup_cmd_from_cdb() -> * target_setup_cmd_from_cdb() -> transport_generic_cmd_sequencer().
* transport_generic_cmd_sequencer().
*/ */
if (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB && if (!(se_cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) &&
se_cmd->data_direction == DMA_FROM_DEVICE) { se_cmd->data_direction == DMA_FROM_DEVICE) {
struct scatterlist *sg = scsi_sglist(sc); struct scatterlist *sg = scsi_sglist(sc);
unsigned char *buf = kmap(sg_page(sg)) + sg->offset; unsigned char *buf = kmap(sg_page(sg)) + sg->offset;
......
...@@ -1042,7 +1042,7 @@ static int pscsi_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl, ...@@ -1042,7 +1042,7 @@ static int pscsi_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl,
memcpy(pt->pscsi_cdb, cmd->t_task_cdb, memcpy(pt->pscsi_cdb, cmd->t_task_cdb,
scsi_command_size(cmd->t_task_cdb)); scsi_command_size(cmd->t_task_cdb));
if (cmd->se_cmd_flags & SCF_SCSI_NON_DATA_CDB) { if (!sgl) {
req = blk_get_request(pdv->pdv_sd->request_queue, req = blk_get_request(pdv->pdv_sd->request_queue,
(data_direction == DMA_TO_DEVICE), (data_direction == DMA_TO_DEVICE),
GFP_KERNEL); GFP_KERNEL);
......
...@@ -2446,7 +2446,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2446,7 +2446,7 @@ static int transport_generic_cmd_sequencer(
goto out_unsupported_cdb; goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd); size = transport_get_size(sectors, cdb, cmd);
cmd->t_task_lba = transport_lba_21(cdb); cmd->t_task_lba = transport_lba_21(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
break; break;
case READ_10: case READ_10:
sectors = transport_get_sectors_10(cdb, cmd, &sector_ret); sectors = transport_get_sectors_10(cdb, cmd, &sector_ret);
...@@ -2454,7 +2454,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2454,7 +2454,7 @@ static int transport_generic_cmd_sequencer(
goto out_unsupported_cdb; goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd); size = transport_get_size(sectors, cdb, cmd);
cmd->t_task_lba = transport_lba_32(cdb); cmd->t_task_lba = transport_lba_32(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
break; break;
case READ_12: case READ_12:
sectors = transport_get_sectors_12(cdb, cmd, &sector_ret); sectors = transport_get_sectors_12(cdb, cmd, &sector_ret);
...@@ -2462,7 +2462,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2462,7 +2462,7 @@ static int transport_generic_cmd_sequencer(
goto out_unsupported_cdb; goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd); size = transport_get_size(sectors, cdb, cmd);
cmd->t_task_lba = transport_lba_32(cdb); cmd->t_task_lba = transport_lba_32(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
break; break;
case READ_16: case READ_16:
sectors = transport_get_sectors_16(cdb, cmd, &sector_ret); sectors = transport_get_sectors_16(cdb, cmd, &sector_ret);
...@@ -2470,7 +2470,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2470,7 +2470,7 @@ static int transport_generic_cmd_sequencer(
goto out_unsupported_cdb; goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd); size = transport_get_size(sectors, cdb, cmd);
cmd->t_task_lba = transport_lba_64(cdb); cmd->t_task_lba = transport_lba_64(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
break; break;
case WRITE_6: case WRITE_6:
sectors = transport_get_sectors_6(cdb, cmd, &sector_ret); sectors = transport_get_sectors_6(cdb, cmd, &sector_ret);
...@@ -2478,7 +2478,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2478,7 +2478,7 @@ static int transport_generic_cmd_sequencer(
goto out_unsupported_cdb; goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd); size = transport_get_size(sectors, cdb, cmd);
cmd->t_task_lba = transport_lba_21(cdb); cmd->t_task_lba = transport_lba_21(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
break; break;
case WRITE_10: case WRITE_10:
case WRITE_VERIFY: case WRITE_VERIFY:
...@@ -2489,7 +2489,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2489,7 +2489,7 @@ static int transport_generic_cmd_sequencer(
cmd->t_task_lba = transport_lba_32(cdb); cmd->t_task_lba = transport_lba_32(cdb);
if (cdb[1] & 0x8) if (cdb[1] & 0x8)
cmd->se_cmd_flags |= SCF_FUA; cmd->se_cmd_flags |= SCF_FUA;
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
break; break;
case WRITE_12: case WRITE_12:
sectors = transport_get_sectors_12(cdb, cmd, &sector_ret); sectors = transport_get_sectors_12(cdb, cmd, &sector_ret);
...@@ -2499,7 +2499,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2499,7 +2499,7 @@ static int transport_generic_cmd_sequencer(
cmd->t_task_lba = transport_lba_32(cdb); cmd->t_task_lba = transport_lba_32(cdb);
if (cdb[1] & 0x8) if (cdb[1] & 0x8)
cmd->se_cmd_flags |= SCF_FUA; cmd->se_cmd_flags |= SCF_FUA;
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
break; break;
case WRITE_16: case WRITE_16:
sectors = transport_get_sectors_16(cdb, cmd, &sector_ret); sectors = transport_get_sectors_16(cdb, cmd, &sector_ret);
...@@ -2509,7 +2509,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2509,7 +2509,7 @@ static int transport_generic_cmd_sequencer(
cmd->t_task_lba = transport_lba_64(cdb); cmd->t_task_lba = transport_lba_64(cdb);
if (cdb[1] & 0x8) if (cdb[1] & 0x8)
cmd->se_cmd_flags |= SCF_FUA; cmd->se_cmd_flags |= SCF_FUA;
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
break; break;
case XDWRITEREAD_10: case XDWRITEREAD_10:
if ((cmd->data_direction != DMA_TO_DEVICE) || if ((cmd->data_direction != DMA_TO_DEVICE) ||
...@@ -2520,7 +2520,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2520,7 +2520,7 @@ static int transport_generic_cmd_sequencer(
goto out_unsupported_cdb; goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd); size = transport_get_size(sectors, cdb, cmd);
cmd->t_task_lba = transport_lba_32(cdb); cmd->t_task_lba = transport_lba_32(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
/* /*
* Do now allow BIDI commands for passthrough mode. * Do now allow BIDI commands for passthrough mode.
...@@ -2548,7 +2548,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2548,7 +2548,7 @@ static int transport_generic_cmd_sequencer(
* XDWRITE_READ_32 logic. * XDWRITE_READ_32 logic.
*/ */
cmd->t_task_lba = transport_lba_64_ext(cdb); cmd->t_task_lba = transport_lba_64_ext(cdb);
cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
/* /*
* Do now allow BIDI commands for passthrough mode. * Do now allow BIDI commands for passthrough mode.
...@@ -2578,7 +2578,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2578,7 +2578,6 @@ static int transport_generic_cmd_sequencer(
} }
cmd->t_task_lba = get_unaligned_be64(&cdb[12]); cmd->t_task_lba = get_unaligned_be64(&cdb[12]);
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (target_check_write_same_discard(&cdb[10], dev) < 0) if (target_check_write_same_discard(&cdb[10], dev) < 0)
goto out_unsupported_cdb; goto out_unsupported_cdb;
...@@ -2608,25 +2607,20 @@ static int transport_generic_cmd_sequencer( ...@@ -2608,25 +2607,20 @@ static int transport_generic_cmd_sequencer(
/* GPCMD_SEND_KEY from multi media commands */ /* GPCMD_SEND_KEY from multi media commands */
size = (cdb[8] << 8) + cdb[9]; size = (cdb[8] << 8) + cdb[9];
} }
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case MODE_SELECT: case MODE_SELECT:
size = cdb[4]; size = cdb[4];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case MODE_SELECT_10: case MODE_SELECT_10:
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case MODE_SENSE: case MODE_SENSE:
size = cdb[4]; size = cdb[4];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_cmd = target_emulate_modesense; cmd->execute_cmd = target_emulate_modesense;
break; break;
case MODE_SENSE_10: case MODE_SENSE_10:
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_cmd = target_emulate_modesense; cmd->execute_cmd = target_emulate_modesense;
break; break;
...@@ -2635,39 +2629,32 @@ static int transport_generic_cmd_sequencer( ...@@ -2635,39 +2629,32 @@ static int transport_generic_cmd_sequencer(
case LOG_SELECT: case LOG_SELECT:
case LOG_SENSE: case LOG_SENSE:
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case READ_BLOCK_LIMITS: case READ_BLOCK_LIMITS:
size = READ_BLOCK_LEN; size = READ_BLOCK_LEN;
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case GPCMD_GET_CONFIGURATION: case GPCMD_GET_CONFIGURATION:
case GPCMD_READ_FORMAT_CAPACITIES: case GPCMD_READ_FORMAT_CAPACITIES:
case GPCMD_READ_DISC_INFO: case GPCMD_READ_DISC_INFO:
case GPCMD_READ_TRACK_RZONE_INFO: case GPCMD_READ_TRACK_RZONE_INFO:
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case PERSISTENT_RESERVE_IN: case PERSISTENT_RESERVE_IN:
if (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS)
cmd->execute_cmd = target_scsi3_emulate_pr_in; cmd->execute_cmd = target_scsi3_emulate_pr_in;
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case PERSISTENT_RESERVE_OUT: case PERSISTENT_RESERVE_OUT:
if (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS)
cmd->execute_cmd = target_scsi3_emulate_pr_out; cmd->execute_cmd = target_scsi3_emulate_pr_out;
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case GPCMD_MECHANISM_STATUS: case GPCMD_MECHANISM_STATUS:
case GPCMD_READ_DVD_STRUCTURE: case GPCMD_READ_DVD_STRUCTURE:
size = (cdb[8] << 8) + cdb[9]; size = (cdb[8] << 8) + cdb[9];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case READ_POSITION: case READ_POSITION:
size = READ_POSITION_LEN; size = READ_POSITION_LEN;
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case MAINTENANCE_OUT: case MAINTENANCE_OUT:
if (dev->transport->get_device_type(dev) != TYPE_ROM) { if (dev->transport->get_device_type(dev) != TYPE_ROM) {
...@@ -2687,7 +2674,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2687,7 +2674,6 @@ static int transport_generic_cmd_sequencer(
/* GPCMD_REPORT_KEY from multi media commands */ /* GPCMD_REPORT_KEY from multi media commands */
size = (cdb[8] << 8) + cdb[9]; size = (cdb[8] << 8) + cdb[9];
} }
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case INQUIRY: case INQUIRY:
size = (cdb[3] << 8) + cdb[4]; size = (cdb[3] << 8) + cdb[4];
...@@ -2697,17 +2683,14 @@ static int transport_generic_cmd_sequencer( ...@@ -2697,17 +2683,14 @@ static int transport_generic_cmd_sequencer(
*/ */
if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED)
cmd->sam_task_attr = MSG_HEAD_TAG; cmd->sam_task_attr = MSG_HEAD_TAG;
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_cmd = target_emulate_inquiry; cmd->execute_cmd = target_emulate_inquiry;
break; break;
case READ_BUFFER: case READ_BUFFER:
size = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8]; size = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case READ_CAPACITY: case READ_CAPACITY:
size = READ_CAP_LEN; size = READ_CAP_LEN;
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_cmd = target_emulate_readcapacity; cmd->execute_cmd = target_emulate_readcapacity;
break; break;
...@@ -2715,7 +2698,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2715,7 +2698,6 @@ static int transport_generic_cmd_sequencer(
case SECURITY_PROTOCOL_IN: case SECURITY_PROTOCOL_IN:
case SECURITY_PROTOCOL_OUT: case SECURITY_PROTOCOL_OUT:
size = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9]; size = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case SERVICE_ACTION_IN: case SERVICE_ACTION_IN:
switch (cmd->t_task_cdb[1] & 0x1f) { switch (cmd->t_task_cdb[1] & 0x1f) {
...@@ -2741,38 +2723,31 @@ static int transport_generic_cmd_sequencer( ...@@ -2741,38 +2723,31 @@ static int transport_generic_cmd_sequencer(
case WRITE_ATTRIBUTE: case WRITE_ATTRIBUTE:
size = (cdb[10] << 24) | (cdb[11] << 16) | size = (cdb[10] << 24) | (cdb[11] << 16) |
(cdb[12] << 8) | cdb[13]; (cdb[12] << 8) | cdb[13];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case RECEIVE_DIAGNOSTIC: case RECEIVE_DIAGNOSTIC:
case SEND_DIAGNOSTIC: case SEND_DIAGNOSTIC:
size = (cdb[3] << 8) | cdb[4]; size = (cdb[3] << 8) | cdb[4];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
/* #warning FIXME: Figure out correct GPCMD_READ_CD blocksize. */ /* #warning FIXME: Figure out correct GPCMD_READ_CD blocksize. */
#if 0 #if 0
case GPCMD_READ_CD: case GPCMD_READ_CD:
sectors = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8]; sectors = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8];
size = (2336 * sectors); size = (2336 * sectors);
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
#endif #endif
case READ_TOC: case READ_TOC:
size = cdb[8]; size = cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case REQUEST_SENSE: case REQUEST_SENSE:
size = cdb[4]; size = cdb[4];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_cmd = target_emulate_request_sense; cmd->execute_cmd = target_emulate_request_sense;
break; break;
case READ_ELEMENT_STATUS: case READ_ELEMENT_STATUS:
size = 65536 * cdb[7] + 256 * cdb[8] + cdb[9]; size = 65536 * cdb[7] + 256 * cdb[8] + cdb[9];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case WRITE_BUFFER: case WRITE_BUFFER:
size = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8]; size = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case RESERVE: case RESERVE:
case RESERVE_10: case RESERVE_10:
...@@ -2794,7 +2769,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2794,7 +2769,6 @@ static int transport_generic_cmd_sequencer(
*/ */
if (su_dev->t10_pr.res_type != SPC_PASSTHROUGH) if (su_dev->t10_pr.res_type != SPC_PASSTHROUGH)
cmd->execute_cmd = target_scsi2_reservation_reserve; cmd->execute_cmd = target_scsi2_reservation_reserve;
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
break; break;
case RELEASE: case RELEASE:
case RELEASE_10: case RELEASE_10:
...@@ -2809,7 +2783,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2809,7 +2783,6 @@ static int transport_generic_cmd_sequencer(
if (su_dev->t10_pr.res_type != SPC_PASSTHROUGH) if (su_dev->t10_pr.res_type != SPC_PASSTHROUGH)
cmd->execute_cmd = target_scsi2_reservation_release; cmd->execute_cmd = target_scsi2_reservation_release;
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
break; break;
case SYNCHRONIZE_CACHE: case SYNCHRONIZE_CACHE:
case SYNCHRONIZE_CACHE_16: case SYNCHRONIZE_CACHE_16:
...@@ -2827,7 +2800,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2827,7 +2800,6 @@ static int transport_generic_cmd_sequencer(
goto out_unsupported_cdb; goto out_unsupported_cdb;
size = transport_get_size(sectors, cdb, cmd); size = transport_get_size(sectors, cdb, cmd);
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
if (passthrough) if (passthrough)
break; break;
...@@ -2844,7 +2816,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2844,7 +2816,6 @@ static int transport_generic_cmd_sequencer(
break; break;
case UNMAP: case UNMAP:
size = get_unaligned_be16(&cdb[7]); size = get_unaligned_be16(&cdb[7]);
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_cmd = target_emulate_unmap; cmd->execute_cmd = target_emulate_unmap;
break; break;
...@@ -2861,7 +2832,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2861,7 +2832,6 @@ static int transport_generic_cmd_sequencer(
} }
cmd->t_task_lba = get_unaligned_be64(&cdb[2]); cmd->t_task_lba = get_unaligned_be64(&cdb[2]);
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (target_check_write_same_discard(&cdb[1], dev) < 0) if (target_check_write_same_discard(&cdb[1], dev) < 0)
goto out_unsupported_cdb; goto out_unsupported_cdb;
...@@ -2881,7 +2851,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2881,7 +2851,6 @@ static int transport_generic_cmd_sequencer(
} }
cmd->t_task_lba = get_unaligned_be32(&cdb[2]); cmd->t_task_lba = get_unaligned_be32(&cdb[2]);
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
/* /*
* Follow sbcr26 with WRITE_SAME (10) and check for the existence * Follow sbcr26 with WRITE_SAME (10) and check for the existence
* of byte 1 bit 3 UNMAP instead of original reserved field * of byte 1 bit 3 UNMAP instead of original reserved field
...@@ -2900,7 +2869,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2900,7 +2869,6 @@ static int transport_generic_cmd_sequencer(
case TEST_UNIT_READY: case TEST_UNIT_READY:
case VERIFY: case VERIFY:
case WRITE_FILEMARKS: case WRITE_FILEMARKS:
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_cmd = target_emulate_noop; cmd->execute_cmd = target_emulate_noop;
break; break;
...@@ -2909,7 +2877,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2909,7 +2877,6 @@ static int transport_generic_cmd_sequencer(
case GPCMD_LOAD_UNLOAD: case GPCMD_LOAD_UNLOAD:
case GPCMD_SET_SPEED: case GPCMD_SET_SPEED:
case MOVE_MEDIUM: case MOVE_MEDIUM:
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
break; break;
case REPORT_LUNS: case REPORT_LUNS:
cmd->execute_cmd = target_report_luns; cmd->execute_cmd = target_report_luns;
...@@ -2920,11 +2887,9 @@ static int transport_generic_cmd_sequencer( ...@@ -2920,11 +2887,9 @@ static int transport_generic_cmd_sequencer(
*/ */
if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED)
cmd->sam_task_attr = MSG_HEAD_TAG; cmd->sam_task_attr = MSG_HEAD_TAG;
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case GET_EVENT_STATUS_NOTIFICATION: case GET_EVENT_STATUS_NOTIFICATION:
size = (cdb[7] << 8) | cdb[8]; size = (cdb[7] << 8) | cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case ATA_16: case ATA_16:
/* Only support ATA passthrough to pSCSI backends.. */ /* Only support ATA passthrough to pSCSI backends.. */
...@@ -2956,7 +2921,6 @@ static int transport_generic_cmd_sequencer( ...@@ -2956,7 +2921,6 @@ static int transport_generic_cmd_sequencer(
/* BYTE */ /* BYTE */
size = sectors; size = sectors;
} }
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
default: default:
pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode" pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode"
...@@ -2983,7 +2947,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2983,7 +2947,7 @@ static int transport_generic_cmd_sequencer(
} }
/* /*
* Reject READ_* or WRITE_* with overflow/underflow for * Reject READ_* or WRITE_* with overflow/underflow for
* type SCF_SCSI_DATA_SG_IO_CDB. * type SCF_SCSI_DATA_CDB.
*/ */
if (dev->se_sub_dev->se_dev_attrib.block_size != 512) { if (dev->se_sub_dev->se_dev_attrib.block_size != 512) {
pr_err("Failing OVERFLOW/UNDERFLOW for LBA op" pr_err("Failing OVERFLOW/UNDERFLOW for LBA op"
...@@ -3003,7 +2967,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3003,7 +2967,7 @@ static int transport_generic_cmd_sequencer(
cmd->data_length = size; cmd->data_length = size;
} }
if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) { if (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
if (sectors > su_dev->se_dev_attrib.fabric_max_sectors) { if (sectors > su_dev->se_dev_attrib.fabric_max_sectors) {
printk_ratelimited(KERN_ERR "SCSI OP %02xh with too" printk_ratelimited(KERN_ERR "SCSI OP %02xh with too"
" big sectors %u exceeds fabric_max_sectors:" " big sectors %u exceeds fabric_max_sectors:"
...@@ -3022,7 +2986,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3022,7 +2986,7 @@ static int transport_generic_cmd_sequencer(
/* reject any command that we don't have a handler for */ /* reject any command that we don't have a handler for */
if (!(passthrough || cmd->execute_cmd || if (!(passthrough || cmd->execute_cmd ||
(cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB))) (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB)))
goto out_unsupported_cdb; goto out_unsupported_cdb;
return 0; return 0;
...@@ -3357,31 +3321,27 @@ int transport_generic_map_mem_to_cmd( ...@@ -3357,31 +3321,27 @@ int transport_generic_map_mem_to_cmd(
if (!sgl || !sgl_count) if (!sgl || !sgl_count)
return 0; return 0;
if ((cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) || /*
(cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB)) { * Reject SCSI data overflow with map_mem_to_cmd() as incoming
/* * scatterlists already have been set to follow what the fabric
* Reject SCSI data overflow with map_mem_to_cmd() as incoming * passes for the original expected data transfer length.
* scatterlists already have been set to follow what the fabric */
* passes for the original expected data transfer length. if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT) {
*/ pr_warn("Rejecting SCSI DATA overflow for fabric using"
if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT) { " SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC\n");
pr_warn("Rejecting SCSI DATA overflow for fabric using" cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
" SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC\n"); cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD;
cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; return -EINVAL;
cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; }
return -EINVAL;
}
cmd->t_data_sg = sgl; cmd->t_data_sg = sgl;
cmd->t_data_nents = sgl_count; cmd->t_data_nents = sgl_count;
if (sgl_bidi && sgl_bidi_count) { if (sgl_bidi && sgl_bidi_count) {
cmd->t_bidi_data_sg = sgl_bidi; cmd->t_bidi_data_sg = sgl_bidi;
cmd->t_bidi_data_nents = sgl_bidi_count; cmd->t_bidi_data_nents = sgl_bidi_count;
}
cmd->se_cmd_flags |= SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC;
} }
cmd->se_cmd_flags |= SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC;
return 0; return 0;
} }
EXPORT_SYMBOL(transport_generic_map_mem_to_cmd); EXPORT_SYMBOL(transport_generic_map_mem_to_cmd);
...@@ -3453,7 +3413,7 @@ transport_generic_get_mem(struct se_cmd *cmd) ...@@ -3453,7 +3413,7 @@ transport_generic_get_mem(struct se_cmd *cmd)
cmd->t_data_nents = nents; cmd->t_data_nents = nents;
sg_init_table(cmd->t_data_sg, nents); sg_init_table(cmd->t_data_sg, nents);
zero_flag = cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB ? 0 : __GFP_ZERO; zero_flag = cmd->se_cmd_flags & SCF_SCSI_DATA_CDB ? 0 : __GFP_ZERO;
while (length) { while (length) {
u32 page_len = min_t(u32, length, PAGE_SIZE); u32 page_len = min_t(u32, length, PAGE_SIZE);
...@@ -3500,8 +3460,7 @@ int transport_generic_new_cmd(struct se_cmd *cmd) ...@@ -3500,8 +3460,7 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
} }
/* Workaround for handling zero-length control CDBs */ /* Workaround for handling zero-length control CDBs */
if ((cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) && if (!(cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) && !cmd->data_length) {
!cmd->data_length) {
spin_lock_irq(&cmd->t_state_lock); spin_lock_irq(&cmd->t_state_lock);
cmd->t_state = TRANSPORT_COMPLETE; cmd->t_state = TRANSPORT_COMPLETE;
cmd->transport_state |= CMD_T_ACTIVE; cmd->transport_state |= CMD_T_ACTIVE;
...@@ -3519,7 +3478,7 @@ int transport_generic_new_cmd(struct se_cmd *cmd) ...@@ -3519,7 +3478,7 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
return 0; return 0;
} }
if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) { if (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
struct se_dev_attrib *attr = &dev->se_sub_dev->se_dev_attrib; struct se_dev_attrib *attr = &dev->se_sub_dev->se_dev_attrib;
if (transport_cmd_get_valid_sectors(cmd) < 0) if (transport_cmd_get_valid_sectors(cmd) < 0)
......
...@@ -215,7 +215,7 @@ int ft_write_pending(struct se_cmd *se_cmd) ...@@ -215,7 +215,7 @@ int ft_write_pending(struct se_cmd *se_cmd)
*/ */
if ((ep->xid <= lport->lro_xid) && if ((ep->xid <= lport->lro_xid) &&
(fh->fh_r_ctl == FC_RCTL_DD_DATA_DESC)) { (fh->fh_r_ctl == FC_RCTL_DD_DATA_DESC)) {
if ((se_cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) && if ((se_cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) &&
lport->tt.ddp_target(lport, ep->xid, lport->tt.ddp_target(lport, ep->xid,
se_cmd->t_data_sg, se_cmd->t_data_sg,
se_cmd->t_data_nents)) se_cmd->t_data_nents))
......
...@@ -160,25 +160,22 @@ enum se_cmd_flags_table { ...@@ -160,25 +160,22 @@ enum se_cmd_flags_table {
SCF_SUPPORTED_SAM_OPCODE = 0x00000001, SCF_SUPPORTED_SAM_OPCODE = 0x00000001,
SCF_TRANSPORT_TASK_SENSE = 0x00000002, SCF_TRANSPORT_TASK_SENSE = 0x00000002,
SCF_EMULATED_TASK_SENSE = 0x00000004, SCF_EMULATED_TASK_SENSE = 0x00000004,
SCF_SCSI_DATA_SG_IO_CDB = 0x00000008, SCF_SCSI_DATA_CDB = 0x00000008,
SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010, SCF_SCSI_TMR_CDB = 0x00000010,
SCF_SCSI_NON_DATA_CDB = 0x00000020, SCF_SCSI_CDB_EXCEPTION = 0x00000020,
SCF_SCSI_TMR_CDB = 0x00000040, SCF_SCSI_RESERVATION_CONFLICT = 0x00000040,
SCF_SCSI_CDB_EXCEPTION = 0x00000080, SCF_FUA = 0x00000080,
SCF_SCSI_RESERVATION_CONFLICT = 0x00000100, SCF_SE_LUN_CMD = 0x00000100,
SCF_FUA = 0x00000200, SCF_SE_ALLOW_EOO = 0x00000200,
SCF_SE_LUN_CMD = 0x00000800, SCF_BIDI = 0x00000400,
SCF_SE_ALLOW_EOO = 0x00001000, SCF_SENT_CHECK_CONDITION = 0x00000800,
SCF_BIDI = 0x00002000, SCF_OVERFLOW_BIT = 0x00001000,
SCF_SENT_CHECK_CONDITION = 0x00004000, SCF_UNDERFLOW_BIT = 0x00002000,
SCF_OVERFLOW_BIT = 0x00008000, SCF_SENT_DELAYED_TAS = 0x00004000,
SCF_UNDERFLOW_BIT = 0x00010000, SCF_ALUA_NON_OPTIMIZED = 0x00008000,
SCF_SENT_DELAYED_TAS = 0x00020000, SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00010000,
SCF_ALUA_NON_OPTIMIZED = 0x00040000, SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00020000,
SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000, SCF_ACK_KREF = 0x00040000,
SCF_UNUSED = 0x00100000,
SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00200000,
SCF_ACK_KREF = 0x00400000,
}; };
/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */ /* struct se_dev_entry->lun_flags and struct se_lun->lun_access */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment