diff options
| author | Mike Christie <[email protected]> | 2021-02-27 10:59:45 -0600 |
|---|---|---|
| committer | Martin K. Petersen <[email protected]> | 2021-03-04 17:37:00 -0500 |
| commit | 750a1d93f90583a270eb62f36e6d32ebbb6af779 (patch) | |
| tree | 9b419019a6c8cff07c916cca585a98613db04ff4 /include/target | |
| parent | a78b713618c02752310b2be7da465a34fb660ed9 (diff) | |
scsi: target: core: Break up target_submit_cmd_map_sgls()
This breaks up target_submit_cmd_map_sgls() into 3 helpers:
- target_init_cmd(): Do the basic general setup and get a refcount to the
session to make sure the caller can execute the cmd.
- target_submit_prep(): Do the mapping, cdb processing and get a ref to
the LUN.
- target_submit(): Pass the cmd to LIO core for execution.
The above functions must be used by drivers that either:
1. Rely on LIO for session shutdown synchronization by calling
target_stop_session().
2. Need to map sgls.
When the next patches are applied then simple drivers that do not need the
extra functionality above can use target_submit_cmd() and not worry about
failures being returned and how to handle them, since many drivers were
getting this wrong and would have hit refcount bugs.
Also, by breaking target_submit_cmd_map_sgls() up into these 3 helper
functions, we can allow the later patches to do the init/prep from
interrupt context and then do the submission from a workqueue.
Link: https://lore.kernel.org/r/[email protected]
Cc: Bart Van Assche <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Hannes Reinecke <[email protected]>
Cc: Nilesh Javali <[email protected]>
Cc: Michael Cyr <[email protected]>
Cc: Chris Boot <[email protected]>
Cc: Felipe Balbi <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>
Tested-by: Laurence Oberman <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Himanshu Madhani <[email protected]>
Signed-off-by: Mike Christie <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
Diffstat (limited to 'include/target')
| -rw-r--r-- | include/target/target_core_fabric.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 4975c4d2a933..4b5f6687393a 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -151,6 +151,14 @@ void transport_deregister_session(struct se_session *); void __target_init_cmd(struct se_cmd *, const struct target_core_fabric_ops *, struct se_session *, u32, int, int, unsigned char *, u64); +int target_init_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, + unsigned char *sense, u64 unpacked_lun, u32 data_length, + int task_attr, int data_dir, int flags); +int target_submit_prep(struct se_cmd *se_cmd, unsigned char *cdb, + struct scatterlist *sgl, u32 sgl_count, + struct scatterlist *sgl_bidi, u32 sgl_bidi_count, + struct scatterlist *sgl_prot, u32 sgl_prot_count); +void target_submit(struct se_cmd *se_cmd); sense_reason_t transport_lookup_cmd_lun(struct se_cmd *); sense_reason_t target_cmd_init_cdb(struct se_cmd *, unsigned char *); sense_reason_t target_cmd_parse_cdb(struct se_cmd *); |
