[01/25] target: move t_task_cdb initialization

Message ID 20210227170006.5077-2-michael.christie@oracle.com
State New
Headers show
Series
  • [01/25] target: move t_task_cdb initialization
Related show

Commit Message

Mike Christie Feb. 27, 2021, 4:59 p.m.
The next patch splits target_submit_cmd_map_sgls so the initialization
and submission part can be called at different times. If the init part
fails we can reference the t_task_cdb early in some of the logging
and tracing code. This moves it to transport_init_se_cmd so we don't
hit NULL pointer crashes.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Tested-by: Laurence Oberman <loberman@redhat.com>
---
 drivers/target/target_core_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin K. Petersen March 4, 2021, 4:15 a.m. | #1
On Sat, 27 Feb 2021 10:59:42 -0600, Mike Christie wrote:

> The next patch splits target_submit_cmd_map_sgls so the initialization

> and submission part can be called at different times. If the init part

> fails we can reference the t_task_cdb early in some of the logging

> and tracing code. This moves it to transport_init_se_cmd so we don't

> hit NULL pointer crashes.


Applied to 5.13/scsi-queue, thanks!

[01/25] target: move t_task_cdb initialization
        https://git.kernel.org/mkp/scsi/c/eccc70ccfb15
[02/25] target: drop kref_get_unless_zero in target_get_sess_cmd
        https://git.kernel.org/mkp/scsi/c/14e025be793e
[03/25] target: rename transport_init_se_cmd
        https://git.kernel.org/mkp/scsi/c/ed58729a69f4
[04/25] target: break up target_submit_cmd_map_sgls
        https://git.kernel.org/mkp/scsi/c/4a3f993e79db
[05/25] srpt: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/834e8c13acc9
[06/25] ibmvscsi_tgt: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/3b168220e479
[07/25] qla2xxx: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/9e54e530349a
[08/25] tcm_loop: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/5f3e979db0ef
[09/25] sbp_target: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/207c30be067c
[10/25] usb gadget: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/1edc02440bde
[11/25] vhost-scsi: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/e4edee8ac14a
[12/25] xen-scsiback: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/4d1d39e3a2e7
[13/25] tcm_fc: Convert to new submission API
        https://git.kernel.org/mkp/scsi/c/bde30acd9bd6
[14/25] target: remove target_submit_cmd_map_sgls
        https://git.kernel.org/mkp/scsi/c/4d3a1c529373
[15/25] target: add gfp_t arg to target_cmd_init_cdb
        https://git.kernel.org/mkp/scsi/c/22be5fc090a1
[16/25] target: add workqueue based cmd submission
        https://git.kernel.org/mkp/scsi/c/1a8ce8031c2c
[17/25] vhost scsi: use lio wq cmd submission helper
        https://git.kernel.org/mkp/scsi/c/f4e69b337bd5
[18/25] tcm loop: use blk cmd allocator for se_cmds
        https://git.kernel.org/mkp/scsi/c/93239a54b60d
[19/25] tcm loop: use lio wq cmd submission helper
        https://git.kernel.org/mkp/scsi/c/3f335d8914bb
[20/25] target: cleanup cmd flag bits
        https://git.kernel.org/mkp/scsi/c/74493992906f
[21/25] target: fix backend plugging
        https://git.kernel.org/mkp/scsi/c/1518827a9c95
[22/25] target iblock: add backend plug/unplug callouts
        https://git.kernel.org/mkp/scsi/c/18a45511925b
[23/25] target_core_user: add backend plug/unplug callouts
        https://git.kernel.org/mkp/scsi/c/dfe49a322758
[24/25] target: flush submission work during TMR processing
        https://git.kernel.org/mkp/scsi/c/b0ab4acf2df8
[25/25] target: make completion affinity configurable
        https://git.kernel.org/mkp/scsi/c/100d21c4ff29

-- 
Martin K. Petersen	Oracle Linux Engineering

Patch

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index d47bfd8b0f87..5c4adde96d5e 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1389,6 +1389,7 @@  void transport_init_se_cmd(
 	INIT_WORK(&cmd->work, NULL);
 	kref_init(&cmd->cmd_kref);
 
+	cmd->t_task_cdb = &cmd->__t_task_cdb[0];
 	cmd->se_tfo = tfo;
 	cmd->se_sess = se_sess;
 	cmd->data_length = data_length;
@@ -1430,7 +1431,6 @@  target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb)
 {
 	sense_reason_t ret;
 
-	cmd->t_task_cdb = &cmd->__t_task_cdb[0];
 	/*
 	 * Ensure that the received CDB is less than the max (252 + 8) bytes
 	 * for VARIABLE_LENGTH_CMD