aboutsummaryrefslogtreecommitdiffstats
path: root/include/target
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2012-11-06 15:24:09 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2012-11-06 23:55:46 -0500
commitde103c93aff0bed0ae984274e5dc8b95899badab (patch)
tree7db9bba755fa95772052e8d31285a38ba48f1a84 /include/target
parentfecae40abb1ae9218bdbaa8b8e30bfb5ae43f522 (diff)
target: pass sense_reason as a return value
Pass the sense reason as an explicit return value from the I/O submission path instead of storing it in struct se_cmd and using negative return values. This cleans up a lot of the code pathes, and with the sparse annotations for the new sense_reason_t type allows for much better error checking. (nab: Convert spc_emulate_modesense + spc_emulate_modeselect to use sense_reason_t with Roland's MODE SELECT changes) Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'include/target')
-rw-r--r--include/target/target_core_backend.h16
-rw-r--r--include/target/target_core_base.h46
-rw-r--r--include/target/target_core_fabric.h13
3 files changed, 38 insertions, 37 deletions
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index e57f738f04f9..aa868090b9ab 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -31,17 +31,17 @@ struct se_subsystem_api {
31 struct scatterlist *, 31 struct scatterlist *,
32 unsigned char *); 32 unsigned char *);
33 33
34 int (*parse_cdb)(struct se_cmd *cmd); 34 sense_reason_t (*parse_cdb)(struct se_cmd *cmd);
35 u32 (*get_device_type)(struct se_device *); 35 u32 (*get_device_type)(struct se_device *);
36 sector_t (*get_blocks)(struct se_device *); 36 sector_t (*get_blocks)(struct se_device *);
37 unsigned char *(*get_sense_buffer)(struct se_cmd *); 37 unsigned char *(*get_sense_buffer)(struct se_cmd *);
38}; 38};
39 39
40struct sbc_ops { 40struct sbc_ops {
41 int (*execute_rw)(struct se_cmd *cmd); 41 sense_reason_t (*execute_rw)(struct se_cmd *cmd);
42 int (*execute_sync_cache)(struct se_cmd *cmd); 42 sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd);
43 int (*execute_write_same)(struct se_cmd *cmd); 43 sense_reason_t (*execute_write_same)(struct se_cmd *cmd);
44 int (*execute_unmap)(struct se_cmd *cmd); 44 sense_reason_t (*execute_unmap)(struct se_cmd *cmd);
45}; 45};
46 46
47int transport_subsystem_register(struct se_subsystem_api *); 47int transport_subsystem_register(struct se_subsystem_api *);
@@ -49,11 +49,11 @@ void transport_subsystem_release(struct se_subsystem_api *);
49 49
50void target_complete_cmd(struct se_cmd *, u8); 50void target_complete_cmd(struct se_cmd *, u8);
51 51
52int spc_parse_cdb(struct se_cmd *cmd, unsigned int *size); 52sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size);
53int spc_emulate_report_luns(struct se_cmd *cmd); 53sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd);
54int spc_get_write_same_sectors(struct se_cmd *cmd); 54int spc_get_write_same_sectors(struct se_cmd *cmd);
55 55
56int sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops); 56sense_reason_t sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops);
57u32 sbc_get_device_rev(struct se_device *dev); 57u32 sbc_get_device_rev(struct se_device *dev);
58u32 sbc_get_device_type(struct se_device *dev); 58u32 sbc_get_device_type(struct se_device *dev);
59 59
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 11b0a68dc765..5350f6e580f0 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -144,8 +144,6 @@ enum se_cmd_flags_table {
144 SCF_EMULATED_TASK_SENSE = 0x00000004, 144 SCF_EMULATED_TASK_SENSE = 0x00000004,
145 SCF_SCSI_DATA_CDB = 0x00000008, 145 SCF_SCSI_DATA_CDB = 0x00000008,
146 SCF_SCSI_TMR_CDB = 0x00000010, 146 SCF_SCSI_TMR_CDB = 0x00000010,
147 SCF_SCSI_CDB_EXCEPTION = 0x00000020,
148 SCF_SCSI_RESERVATION_CONFLICT = 0x00000040,
149 SCF_FUA = 0x00000080, 147 SCF_FUA = 0x00000080,
150 SCF_SE_LUN_CMD = 0x00000100, 148 SCF_SE_LUN_CMD = 0x00000100,
151 SCF_BIDI = 0x00000400, 149 SCF_BIDI = 0x00000400,
@@ -167,27 +165,32 @@ enum transport_lunflags_table {
167}; 165};
168 166
169/* 167/*
170 * Used by transport_send_check_condition_and_sense() and se_cmd->scsi_sense_reason 168 * Used by transport_send_check_condition_and_sense()
171 * to signal which ASC/ASCQ sense payload should be built. 169 * to signal which ASC/ASCQ sense payload should be built.
172 */ 170 */
171typedef unsigned __bitwise__ sense_reason_t;
172
173enum tcm_sense_reason_table { 173enum tcm_sense_reason_table {
174 TCM_NON_EXISTENT_LUN = 0x01, 174#define R(x) (__force sense_reason_t )(x)
175 TCM_UNSUPPORTED_SCSI_OPCODE = 0x02, 175 TCM_NON_EXISTENT_LUN = R(0x01),
176 TCM_INCORRECT_AMOUNT_OF_DATA = 0x03, 176 TCM_UNSUPPORTED_SCSI_OPCODE = R(0x02),
177 TCM_UNEXPECTED_UNSOLICITED_DATA = 0x04, 177 TCM_INCORRECT_AMOUNT_OF_DATA = R(0x03),
178 TCM_SERVICE_CRC_ERROR = 0x05, 178 TCM_UNEXPECTED_UNSOLICITED_DATA = R(0x04),
179 TCM_SNACK_REJECTED = 0x06, 179 TCM_SERVICE_CRC_ERROR = R(0x05),
180 TCM_SECTOR_COUNT_TOO_MANY = 0x07, 180 TCM_SNACK_REJECTED = R(0x06),
181 TCM_INVALID_CDB_FIELD = 0x08, 181 TCM_SECTOR_COUNT_TOO_MANY = R(0x07),
182 TCM_INVALID_PARAMETER_LIST = 0x09, 182 TCM_INVALID_CDB_FIELD = R(0x08),
183 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE = 0x0a, 183 TCM_INVALID_PARAMETER_LIST = R(0x09),
184 TCM_UNKNOWN_MODE_PAGE = 0x0b, 184 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE = R(0x0a),
185 TCM_WRITE_PROTECTED = 0x0c, 185 TCM_UNKNOWN_MODE_PAGE = R(0x0b),
186 TCM_CHECK_CONDITION_ABORT_CMD = 0x0d, 186 TCM_WRITE_PROTECTED = R(0x0c),
187 TCM_CHECK_CONDITION_UNIT_ATTENTION = 0x0e, 187 TCM_CHECK_CONDITION_ABORT_CMD = R(0x0d),
188 TCM_CHECK_CONDITION_NOT_READY = 0x0f, 188 TCM_CHECK_CONDITION_UNIT_ATTENTION = R(0x0e),
189 TCM_RESERVATION_CONFLICT = 0x10, 189 TCM_CHECK_CONDITION_NOT_READY = R(0x0f),
190 TCM_ADDRESS_OUT_OF_RANGE = 0x11, 190 TCM_RESERVATION_CONFLICT = R(0x10),
191 TCM_ADDRESS_OUT_OF_RANGE = R(0x11),
192 TCM_OUT_OF_RESOURCES = R(0x12),
193#undef R
191}; 194};
192 195
193enum target_sc_flags_table { 196enum target_sc_flags_table {
@@ -407,7 +410,6 @@ struct se_cmd {
407 u8 scsi_status; 410 u8 scsi_status;
408 u8 scsi_asc; 411 u8 scsi_asc;
409 u8 scsi_ascq; 412 u8 scsi_ascq;
410 u8 scsi_sense_reason;
411 u16 scsi_sense_length; 413 u16 scsi_sense_length;
412 /* Delay for ALUA Active/NonOptimized state access in milliseconds */ 414 /* Delay for ALUA Active/NonOptimized state access in milliseconds */
413 int alua_nonop_delay; 415 int alua_nonop_delay;
@@ -445,7 +447,7 @@ struct se_cmd {
445 struct completion cmd_wait_comp; 447 struct completion cmd_wait_comp;
446 struct kref cmd_kref; 448 struct kref cmd_kref;
447 struct target_core_fabric_ops *se_tfo; 449 struct target_core_fabric_ops *se_tfo;
448 int (*execute_cmd)(struct se_cmd *); 450 sense_reason_t (*execute_cmd)(struct se_cmd *);
449 void (*transport_complete_callback)(struct se_cmd *); 451 void (*transport_complete_callback)(struct se_cmd *);
450 452
451 unsigned char *t_task_cdb; 453 unsigned char *t_task_cdb;
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index 81ddb4ae6c3f..9087b200e552 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -98,8 +98,8 @@ void transport_deregister_session(struct se_session *);
98 98
99void transport_init_se_cmd(struct se_cmd *, struct target_core_fabric_ops *, 99void transport_init_se_cmd(struct se_cmd *, struct target_core_fabric_ops *,
100 struct se_session *, u32, int, int, unsigned char *); 100 struct se_session *, u32, int, int, unsigned char *);
101int transport_lookup_cmd_lun(struct se_cmd *, u32); 101sense_reason_t transport_lookup_cmd_lun(struct se_cmd *, u32);
102int target_setup_cmd_from_cdb(struct se_cmd *, unsigned char *); 102sense_reason_t target_setup_cmd_from_cdb(struct se_cmd *, unsigned char *);
103int target_submit_cmd_map_sgls(struct se_cmd *, struct se_session *, 103int target_submit_cmd_map_sgls(struct se_cmd *, struct se_session *,
104 unsigned char *, unsigned char *, u32, u32, int, int, int, 104 unsigned char *, unsigned char *, u32, u32, int, int, int,
105 struct scatterlist *, u32, struct scatterlist *, u32); 105 struct scatterlist *, u32, struct scatterlist *, u32);
@@ -110,9 +110,7 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,
110 void *fabric_tmr_ptr, unsigned char tm_type, 110 void *fabric_tmr_ptr, unsigned char tm_type,
111 gfp_t, unsigned int, int); 111 gfp_t, unsigned int, int);
112int transport_handle_cdb_direct(struct se_cmd *); 112int transport_handle_cdb_direct(struct se_cmd *);
113int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, 113sense_reason_t transport_generic_new_cmd(struct se_cmd *);
114 struct scatterlist *, u32, struct scatterlist *, u32);
115int transport_generic_new_cmd(struct se_cmd *);
116 114
117void target_execute_cmd(struct se_cmd *cmd); 115void target_execute_cmd(struct se_cmd *cmd);
118 116
@@ -120,7 +118,8 @@ void transport_generic_free_cmd(struct se_cmd *, int);
120 118
121bool transport_wait_for_tasks(struct se_cmd *); 119bool transport_wait_for_tasks(struct se_cmd *);
122int transport_check_aborted_status(struct se_cmd *, int); 120int transport_check_aborted_status(struct se_cmd *, int);
123int transport_send_check_condition_and_sense(struct se_cmd *, u8, int); 121int transport_send_check_condition_and_sense(struct se_cmd *,
122 sense_reason_t, int);
124 123
125int target_put_sess_cmd(struct se_session *, struct se_cmd *); 124int target_put_sess_cmd(struct se_session *, struct se_cmd *);
126void target_sess_cmd_list_set_waiting(struct se_session *); 125void target_sess_cmd_list_set_waiting(struct se_session *);
@@ -131,7 +130,7 @@ int core_alua_check_nonop_delay(struct se_cmd *);
131int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t); 130int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t);
132void core_tmr_release_req(struct se_tmr_req *); 131void core_tmr_release_req(struct se_tmr_req *);
133int transport_generic_handle_tmr(struct se_cmd *); 132int transport_generic_handle_tmr(struct se_cmd *);
134void transport_generic_request_failure(struct se_cmd *); 133void transport_generic_request_failure(struct se_cmd *, sense_reason_t);
135int transport_lookup_tmr_lun(struct se_cmd *, u32); 134int transport_lookup_tmr_lun(struct se_cmd *, u32);
136 135
137struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *, 136struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *,