From e35fa8c2d0feb977c2f7d14a973b4132483ffef3 Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 19 Jan 2012 13:39:11 -0800 Subject: scsi: Use struct scsi_lun in fc/fcp.h This allows us to use scsilun_to_int without an ugly cast. Fix up places that use scsilun_to_int on fcp->fc_lun accordingly. In fc target, this leaves ft_cmd.lun unused, so remove it. Signed-off-by: Andy Grover Cc: Christoph Hellwig Cc: Kiran Patil Cc: James Bottomley Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tcm_fc.h | 1 - drivers/target/tcm_fc/tfc_cmd.c | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h index e05c55100ec..559f3bd6868 100644 --- a/drivers/target/tcm_fc/tcm_fc.h +++ b/drivers/target/tcm_fc/tcm_fc.h @@ -113,7 +113,6 @@ struct ft_lport_acl { * Commands */ struct ft_cmd { - u32 lun; /* LUN from request */ struct ft_sess *sess; /* session held for cmd */ struct fc_seq *seq; /* sequence in exchange mgr */ struct se_cmd se_cmd; /* Local TCM I/O descriptor */ diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 9e7e26c74c7..c5f5bb29a16 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -61,7 +61,6 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller) caller, cmd, cmd->sess, cmd->seq, se_cmd); pr_debug("%s: cmd %p cdb %p\n", caller, cmd, cmd->cdb); - pr_debug("%s: cmd %p lun %d\n", caller, cmd, cmd->lun); pr_debug("%s: cmd %p data_nents %u len %u se_cmd_flags <0x%x>\n", caller, cmd, se_cmd->t_data_nents, @@ -407,8 +406,7 @@ static void ft_send_tm(struct ft_cmd *cmd) switch (fcp->fc_tm_flags) { case FCP_TMF_LUN_RESET: - cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); - if (transport_lookup_tmr_lun(&cmd->se_cmd, cmd->lun) < 0) { + if (transport_lookup_tmr_lun(&cmd->se_cmd, scsilun_to_int(&fcp->fc_lun)) < 0) { /* * Make sure to clean up newly allocated TMR request * since "unable to handle TMR request because failed @@ -416,7 +414,7 @@ static void ft_send_tm(struct ft_cmd *cmd) */ pr_debug("Failed to get LUN for TMR func %d, " "se_cmd %p, unpacked_lun %d\n", - tm_func, &cmd->se_cmd, cmd->lun); + tm_func, &cmd->se_cmd, scsilun_to_int(&fcp->fc_lun)); ft_dump_cmd(cmd, __func__); sess = cmd->sess; transport_send_check_condition_and_sense(&cmd->se_cmd, @@ -597,14 +595,13 @@ static void ft_send_work(struct work_struct *work) return; } fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); - cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); /* * Use a single se_cmd->cmd_kref as we expect to release se_cmd * directly from ft_check_stop_free callback in response path. */ target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, cmd->cdb, - &cmd->ft_sense_buffer[0], cmd->lun, data_len, - task_attr, data_dir, 0); + &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), + data_len, task_attr, data_dir, 0); pr_debug("r_ctl %x alloc target_submit_cmd\n", fh->fh_r_ctl); return; -- cgit v1.2.3 From 0dccb69d42a06d438c979c933a1657cb0b4ec4fb Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 9 Feb 2012 06:42:33 +0000 Subject: tcm_fc: Simplify ft_send_work for tmr path Check fc_tm_flags early and call ft_send_tm() right away. Don't need to set local vars for tm case. data_len local var now unneeded, remove. Signed-off-by: Andy Grover Cc: Kiran Patil Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_cmd.c | 78 ++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 43 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index c5f5bb29a16..6b8d854cc71 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -536,7 +536,6 @@ static void ft_send_work(struct work_struct *work) struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame); struct fcp_cmnd *fcp; int data_dir = 0; - u32 data_len; int task_attr; fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); @@ -546,47 +545,6 @@ static void ft_send_work(struct work_struct *work) if (fcp->fc_flags & FCP_CFL_LEN_MASK) goto err; /* not handling longer CDBs yet */ - if (fcp->fc_tm_flags) { - task_attr = FCP_PTA_SIMPLE; - data_dir = DMA_NONE; - data_len = 0; - } else { - switch (fcp->fc_flags & (FCP_CFL_RDDATA | FCP_CFL_WRDATA)) { - case 0: - data_dir = DMA_NONE; - break; - case FCP_CFL_RDDATA: - data_dir = DMA_FROM_DEVICE; - break; - case FCP_CFL_WRDATA: - data_dir = DMA_TO_DEVICE; - break; - case FCP_CFL_WRDATA | FCP_CFL_RDDATA: - goto err; /* TBD not supported by tcm_fc yet */ - } - /* - * Locate the SAM Task Attr from fc_pri_ta - */ - switch (fcp->fc_pri_ta & FCP_PTA_MASK) { - case FCP_PTA_HEADQ: - task_attr = MSG_HEAD_TAG; - break; - case FCP_PTA_ORDERED: - task_attr = MSG_ORDERED_TAG; - break; - case FCP_PTA_ACA: - task_attr = MSG_ACA_TAG; - break; - case FCP_PTA_SIMPLE: /* Fallthrough */ - default: - task_attr = MSG_SIMPLE_TAG; - } - - - task_attr = fcp->fc_pri_ta & FCP_PTA_MASK; - data_len = ntohl(fcp->fc_dl); - cmd->cdb = fcp->fc_cdb; - } /* * Check for FCP task management flags */ @@ -594,6 +552,40 @@ static void ft_send_work(struct work_struct *work) ft_send_tm(cmd); return; } + + switch (fcp->fc_flags & (FCP_CFL_RDDATA | FCP_CFL_WRDATA)) { + case 0: + data_dir = DMA_NONE; + break; + case FCP_CFL_RDDATA: + data_dir = DMA_FROM_DEVICE; + break; + case FCP_CFL_WRDATA: + data_dir = DMA_TO_DEVICE; + break; + case FCP_CFL_WRDATA | FCP_CFL_RDDATA: + goto err; /* TBD not supported by tcm_fc yet */ + } + /* + * Locate the SAM Task Attr from fc_pri_ta + */ + switch (fcp->fc_pri_ta & FCP_PTA_MASK) { + case FCP_PTA_HEADQ: + task_attr = MSG_HEAD_TAG; + break; + case FCP_PTA_ORDERED: + task_attr = MSG_ORDERED_TAG; + break; + case FCP_PTA_ACA: + task_attr = MSG_ACA_TAG; + break; + case FCP_PTA_SIMPLE: /* Fallthrough */ + default: + task_attr = MSG_SIMPLE_TAG; + } + + cmd->cdb = fcp->fc_cdb; + fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); /* * Use a single se_cmd->cmd_kref as we expect to release se_cmd @@ -601,7 +593,7 @@ static void ft_send_work(struct work_struct *work) */ target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, cmd->cdb, &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), - data_len, task_attr, data_dir, 0); + ntohl(fcp->fc_dl), task_attr, data_dir, 0); pr_debug("r_ctl %x alloc target_submit_cmd\n", fh->fh_r_ctl); return; -- cgit v1.2.3 From 35b2cdc4fea1f0d13e1602c07e62c797c9fe5ed4 Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 19 Jan 2012 13:39:16 -0800 Subject: tcm_fc: Remove cmd->cdb data member It's used only for debug output. Debug output may want to make use of fcp->fc_cdb directly. Signed-off-by: Andy Grover Cc: Kiran Patil Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tcm_fc.h | 1 - drivers/target/tcm_fc/tfc_cmd.c | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h index 559f3bd6868..7906b9f8eba 100644 --- a/drivers/target/tcm_fc/tcm_fc.h +++ b/drivers/target/tcm_fc/tcm_fc.h @@ -117,7 +117,6 @@ struct ft_cmd { struct fc_seq *seq; /* sequence in exchange mgr */ struct se_cmd se_cmd; /* Local TCM I/O descriptor */ struct fc_frame *req_frame; - unsigned char *cdb; /* pointer to CDB inside frame */ u32 write_data_len; /* data received on writes */ struct work_struct work; /* Local sense buffer */ diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 6b8d854cc71..a76661178d6 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -59,8 +59,6 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller) se_cmd = &cmd->se_cmd; pr_debug("%s: cmd %p sess %p seq %p se_cmd %p\n", caller, cmd, cmd->sess, cmd->seq, se_cmd); - pr_debug("%s: cmd %p cdb %p\n", - caller, cmd, cmd->cdb); pr_debug("%s: cmd %p data_nents %u len %u se_cmd_flags <0x%x>\n", caller, cmd, se_cmd->t_data_nents, @@ -80,8 +78,6 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller) caller, cmd, ep->sid, ep->did, ep->oxid, ep->rxid, sp->id, ep->esb_stat); } - print_hex_dump(KERN_INFO, "ft_dump_cmd ", DUMP_PREFIX_NONE, - 16, 4, cmd->cdb, MAX_COMMAND_SIZE, 0); } static void ft_free_cmd(struct ft_cmd *cmd) @@ -584,14 +580,12 @@ static void ft_send_work(struct work_struct *work) task_attr = MSG_SIMPLE_TAG; } - cmd->cdb = fcp->fc_cdb; - fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); /* * Use a single se_cmd->cmd_kref as we expect to release se_cmd * directly from ft_check_stop_free callback in response path. */ - target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, cmd->cdb, + target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, fcp->fc_cdb, &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), ntohl(fcp->fc_dl), task_attr, data_dir, 0); pr_debug("r_ctl %x alloc target_submit_cmd\n", fh->fh_r_ctl); -- cgit v1.2.3 From c8e31f26feeb03dc6f51bff68135cc58431e099b Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 19 Jan 2012 13:39:17 -0800 Subject: target: Add SCF_SCSI_TMR_CDB usage and drop se_tmr_req_cache Change the test for if a cmd is a tmr request to checking if SCF_SCSI_TMR_CDB (a new flag) is set in cmd->se_cmd_flags. Also remove se_tmr_req_cache usage in favor of kzalloc usage, and make core_tmr_alloc_req() return int + setup se_cmd->se_tmr_req directly and fix up various fabric module usages Cc: Andy Grover Signed-off-by: Nicholas Bellinger --- drivers/infiniband/ulp/srpt/ib_srpt.c | 4 ++-- drivers/target/iscsi/iscsi_target_util.c | 7 +++--- drivers/target/loopback/tcm_loop.c | 13 ++++------- drivers/target/target_core_tmr.c | 15 +++++++----- drivers/target/target_core_transport.c | 26 +++++++-------------- drivers/target/tcm_fc/tfc_cmd.c | 6 ++--- include/target/target_core_base.h | 39 ++++++++++++++++---------------- include/target/target_core_fabric.h | 2 +- 8 files changed, 51 insertions(+), 61 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index e1e6b5b03c9..3290a57b248 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1878,8 +1878,8 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED; goto process_tmr; } - cmd->se_tmr_req = core_tmr_alloc_req(cmd, NULL, tcm_tmr, GFP_KERNEL); - if (!cmd->se_tmr_req) { + res = core_tmr_alloc_req(cmd, NULL, tcm_tmr, GFP_KERNEL); + if (res < 0) { send_ioctx->cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; send_ioctx->cmd.se_tmr_req->response = TMR_FUNCTION_REJECTED; goto process_tmr; diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 11287e1ece1..4eba86d2bd8 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -229,6 +229,7 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr( { struct iscsi_cmd *cmd; struct se_cmd *se_cmd; + int rc; u8 tcm_function; cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); @@ -286,10 +287,8 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr( goto out; } - se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, - cmd->tmr_req, tcm_function, - GFP_KERNEL); - if (!se_cmd->se_tmr_req) + rc = core_tmr_alloc_req(se_cmd, cmd->tmr_req, tcm_function, GFP_KERNEL); + if (rc < 0) goto out; cmd->tmr_req->se_tmr_req = se_cmd->se_tmr_req; diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index c47ff7f59e5..7cfbcb00b3c 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -187,7 +187,7 @@ static int tcm_loop_check_stop_free(struct se_cmd *se_cmd) * pointer. These will be released directly in tcm_loop_device_reset() * with transport_generic_free_cmd(). */ - if (se_cmd->se_tmr_req) + if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) return 0; /* * Release the struct se_cmd, which will make a callback to release @@ -324,7 +324,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) struct tcm_loop_nexus *tl_nexus; struct tcm_loop_tmr *tl_tmr = NULL; struct tcm_loop_tpg *tl_tpg; - int ret = FAILED; + int ret = FAILED, rc; /* * Locate the tcm_loop_hba_t pointer */ @@ -365,12 +365,9 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, 0, DMA_NONE, MSG_SIMPLE_TAG, &tl_cmd->tl_sense_buf[0]); - /* - * Allocate the LUN_RESET TMR - */ - se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, tl_tmr, - TMR_LUN_RESET, GFP_KERNEL); - if (IS_ERR(se_cmd->se_tmr_req)) + + rc = core_tmr_alloc_req(se_cmd, tl_tmr, TMR_LUN_RESET, GFP_KERNEL); + if (rc < 0) goto release; /* * Locate the underlying TCM struct se_lun from sc->device->lun diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index a5c2e41debf..5d3eb9e6c2e 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -40,7 +40,7 @@ #include "target_core_alua.h" #include "target_core_pr.h" -struct se_tmr_req *core_tmr_alloc_req( +int core_tmr_alloc_req( struct se_cmd *se_cmd, void *fabric_tmr_ptr, u8 function, @@ -48,17 +48,20 @@ struct se_tmr_req *core_tmr_alloc_req( { struct se_tmr_req *tmr; - tmr = kmem_cache_zalloc(se_tmr_req_cache, gfp_flags); + tmr = kzalloc(sizeof(struct se_tmr_req), gfp_flags); if (!tmr) { pr_err("Unable to allocate struct se_tmr_req\n"); - return ERR_PTR(-ENOMEM); + return -ENOMEM; } + + se_cmd->se_cmd_flags |= SCF_SCSI_TMR_CDB; + se_cmd->se_tmr_req = tmr; tmr->task_cmd = se_cmd; tmr->fabric_tmr_ptr = fabric_tmr_ptr; tmr->function = function; INIT_LIST_HEAD(&tmr->tmr_list); - return tmr; + return 0; } EXPORT_SYMBOL(core_tmr_alloc_req); @@ -69,7 +72,7 @@ void core_tmr_release_req( unsigned long flags; if (!dev) { - kmem_cache_free(se_tmr_req_cache, tmr); + kfree(tmr); return; } @@ -77,7 +80,7 @@ void core_tmr_release_req( list_del(&tmr->tmr_list); spin_unlock_irqrestore(&dev->se_tmr_lock, flags); - kmem_cache_free(se_tmr_req_cache, tmr); + kfree(tmr); } static void core_tmr_handle_tas_abort( diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index affbd4d1446..c10c3653eab 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -58,7 +58,6 @@ static int sub_api_initialized; static struct workqueue_struct *target_completion_wq; static struct kmem_cache *se_sess_cache; -struct kmem_cache *se_tmr_req_cache; struct kmem_cache *se_ua_cache; struct kmem_cache *t10_pr_reg_cache; struct kmem_cache *t10_alua_lu_gp_cache; @@ -82,21 +81,13 @@ static void target_complete_ok_work(struct work_struct *work); int init_se_kmem_caches(void) { - se_tmr_req_cache = kmem_cache_create("se_tmr_cache", - sizeof(struct se_tmr_req), __alignof__(struct se_tmr_req), - 0, NULL); - if (!se_tmr_req_cache) { - pr_err("kmem_cache_create() for struct se_tmr_req" - " failed\n"); - goto out; - } se_sess_cache = kmem_cache_create("se_sess_cache", sizeof(struct se_session), __alignof__(struct se_session), 0, NULL); if (!se_sess_cache) { pr_err("kmem_cache_create() for struct se_session" " failed\n"); - goto out_free_tmr_req_cache; + goto out; } se_ua_cache = kmem_cache_create("se_ua_cache", sizeof(struct se_ua), __alignof__(struct se_ua), @@ -169,8 +160,6 @@ out_free_ua_cache: kmem_cache_destroy(se_ua_cache); out_free_sess_cache: kmem_cache_destroy(se_sess_cache); -out_free_tmr_req_cache: - kmem_cache_destroy(se_tmr_req_cache); out: return -ENOMEM; } @@ -178,7 +167,6 @@ out: void release_se_kmem_caches(void) { destroy_workqueue(target_completion_wq); - kmem_cache_destroy(se_tmr_req_cache); kmem_cache_destroy(se_sess_cache); kmem_cache_destroy(se_ua_cache); kmem_cache_destroy(t10_pr_reg_cache); @@ -553,7 +541,7 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd) void transport_cmd_finish_abort(struct se_cmd *cmd, int remove) { - if (!cmd->se_tmr_req) + if (!(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) transport_lun_remove_cmd(cmd); if (transport_cmd_check_stop_to_fabric(cmd)) @@ -3367,7 +3355,7 @@ static void transport_release_cmd(struct se_cmd *cmd) { BUG_ON(!cmd->se_tfo); - if (cmd->se_tmr_req) + if (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) core_tmr_release_req(cmd->se_tmr_req); if (cmd->t_task_cdb != cmd->__t_task_cdb) kfree(cmd->t_task_cdb); @@ -3956,7 +3944,7 @@ queue_full: void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) { if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) { - if (wait_for_tasks && cmd->se_tmr_req) + if (wait_for_tasks && (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) transport_wait_for_tasks(cmd); transport_release_cmd(cmd); @@ -4282,7 +4270,8 @@ bool transport_wait_for_tasks(struct se_cmd *cmd) unsigned long flags; spin_lock_irqsave(&cmd->t_state_lock, flags); - if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && !(cmd->se_tmr_req)) { + if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && + !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) { spin_unlock_irqrestore(&cmd->t_state_lock, flags); return false; } @@ -4290,7 +4279,8 @@ bool transport_wait_for_tasks(struct se_cmd *cmd) * Only perform a possible wait_for_tasks if SCF_SUPPORTED_SAM_OPCODE * has been set in transport_set_supported_SAM_opcode(). */ - if (!(cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) && !cmd->se_tmr_req) { + if (!(cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) && + !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) { spin_unlock_irqrestore(&cmd->t_state_lock, flags); return false; } diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index a76661178d6..bdf25593b81 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -356,6 +356,7 @@ static void ft_send_tm(struct ft_cmd *cmd) struct se_tmr_req *tmr; struct fcp_cmnd *fcp; struct ft_sess *sess; + int rc; u8 tm_func; transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops, @@ -392,13 +393,12 @@ static void ft_send_tm(struct ft_cmd *cmd) } pr_debug("alloc tm cmd fn %d\n", tm_func); - tmr = core_tmr_alloc_req(&cmd->se_cmd, cmd, tm_func, GFP_KERNEL); - if (!tmr) { + rc = core_tmr_alloc_req(&cmd->se_cmd, cmd, tm_func, GFP_KERNEL); + if (rc < 0) { pr_debug("alloc failed\n"); ft_send_resp_code_and_free(cmd, FCP_TMF_FAILED); return; } - cmd->se_cmd.se_tmr_req = tmr; switch (fcp->fc_tm_flags) { case FCP_TMF_LUN_RESET: diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 41dd91b9890..9d514e06625 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -169,7 +169,8 @@ enum se_cmd_flags_table { SCF_EMULATED_TASK_SENSE = 0x00000004, SCF_SCSI_DATA_SG_IO_CDB = 0x00000008, SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010, - SCF_SCSI_NON_DATA_CDB = 0x00000040, + SCF_SCSI_NON_DATA_CDB = 0x00000020, + SCF_SCSI_TMR_CDB = 0x00000040, SCF_SCSI_CDB_EXCEPTION = 0x00000080, SCF_SCSI_RESERVATION_CONFLICT = 0x00000100, SCF_FUA = 0x00000200, @@ -498,6 +499,24 @@ struct se_task { struct completion task_stop_comp; }; +struct se_tmr_req { + /* Task Management function to be performed */ + u8 function; + /* Task Management response to send */ + u8 response; + int call_transport; + /* Reference to ITT that Task Mgmt should be performed */ + u32 ref_task_tag; + /* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */ + u64 ref_task_lun; + void *fabric_tmr_ptr; + struct se_cmd *task_cmd; + struct se_cmd *ref_cmd; + struct se_device *tmr_dev; + struct se_lun *tmr_lun; + struct list_head tmr_list; +}; + struct se_cmd { /* SAM response code being sent to initiator */ u8 scsi_status; @@ -586,24 +605,6 @@ struct se_cmd { }; -struct se_tmr_req { - /* Task Management function to be performed */ - u8 function; - /* Task Management response to send */ - u8 response; - int call_transport; - /* Reference to ITT that Task Mgmt should be performed */ - u32 ref_task_tag; - /* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */ - u64 ref_task_lun; - void *fabric_tmr_ptr; - struct se_cmd *task_cmd; - struct se_cmd *ref_cmd; - struct se_device *tmr_dev; - struct se_lun *tmr_lun; - struct list_head tmr_list; -}; - struct se_ua { u8 ua_asc; u8 ua_ascq; diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index d36fad317e7..c5c16efe396 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -139,7 +139,7 @@ void target_wait_for_sess_cmds(struct se_session *, int); int core_alua_check_nonop_delay(struct se_cmd *); -struct se_tmr_req *core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t); +int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t); void core_tmr_release_req(struct se_tmr_req *); int transport_generic_handle_tmr(struct se_cmd *); int transport_lookup_tmr_lun(struct se_cmd *, u32); -- cgit v1.2.3 From 5ebddd48ffc5b54f96a8041704de3890ee629d8f Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 19 Jan 2012 13:39:18 -0800 Subject: tcm_fc: Move core->fc code conversion earlier in ft_send_tm() No dependencies on rest of code, let's get tm_func set asap. Signed-off-by: Andy Grover Cc: Kiran Patil Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_cmd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index bdf25593b81..d4c95cc2ae5 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -353,17 +353,11 @@ static void ft_send_resp_code_and_free(struct ft_cmd *cmd, */ static void ft_send_tm(struct ft_cmd *cmd) { - struct se_tmr_req *tmr; struct fcp_cmnd *fcp; struct ft_sess *sess; int rc; u8 tm_func; - transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops, - cmd->sess->se_sess, 0, DMA_NONE, 0, - &cmd->ft_sense_buffer[0]); - target_get_sess_cmd(cmd->sess->se_sess, &cmd->se_cmd, false); - fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); switch (fcp->fc_tm_flags) { @@ -392,6 +386,11 @@ static void ft_send_tm(struct ft_cmd *cmd) return; } + transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops, + cmd->sess->se_sess, 0, DMA_NONE, 0, + &cmd->ft_sense_buffer[0]); + target_get_sess_cmd(cmd->sess->se_sess, &cmd->se_cmd, false); + pr_debug("alloc tm cmd fn %d\n", tm_func); rc = core_tmr_alloc_req(&cmd->se_cmd, cmd, tm_func, GFP_KERNEL); if (rc < 0) { -- cgit v1.2.3 From 06fb6313d975c144850a3381ffa792c752d5473d Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 19 Jan 2012 13:39:19 -0800 Subject: tcm_fc: Call lookup_tmr_lun() for all TM types Don't see a reason to differentiate, so drop the fabric specific switch statement in ft_send_tm() ahead of conversion to use target_submit_tmr(). Signed-off-by: Andy Grover Cc: Kiran Patil Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_cmd.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index d4c95cc2ae5..3926f4a66cb 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -399,33 +399,19 @@ static void ft_send_tm(struct ft_cmd *cmd) return; } - switch (fcp->fc_tm_flags) { - case FCP_TMF_LUN_RESET: - if (transport_lookup_tmr_lun(&cmd->se_cmd, scsilun_to_int(&fcp->fc_lun)) < 0) { - /* - * Make sure to clean up newly allocated TMR request - * since "unable to handle TMR request because failed - * to get to LUN" - */ - pr_debug("Failed to get LUN for TMR func %d, " - "se_cmd %p, unpacked_lun %d\n", - tm_func, &cmd->se_cmd, scsilun_to_int(&fcp->fc_lun)); - ft_dump_cmd(cmd, __func__); - sess = cmd->sess; - transport_send_check_condition_and_sense(&cmd->se_cmd, - cmd->se_cmd.scsi_sense_reason, 0); - ft_sess_put(sess); - return; - } - break; - case FCP_TMF_TGT_RESET: - case FCP_TMF_CLR_TASK_SET: - case FCP_TMF_ABT_TASK_SET: - case FCP_TMF_CLR_ACA: - break; - default: + rc = transport_lookup_tmr_lun(&cmd->se_cmd, scsilun_to_int(&fcp->fc_lun)); + if (rc < 0) { + pr_debug("Failed to get LUN for TMR func %d, " + "se_cmd %p, unpacked_lun %d\n", + tm_func, &cmd->se_cmd, scsilun_to_int(&fcp->fc_lun)); + ft_dump_cmd(cmd, __func__); + sess = cmd->sess; + transport_send_check_condition_and_sense(&cmd->se_cmd, + cmd->se_cmd.scsi_sense_reason, 0); + ft_sess_put(sess); return; } + transport_generic_handle_tmr(&cmd->se_cmd); } -- cgit v1.2.3 From a1321f71e87930579afc4a4029cce128c23f3fd3 Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 19 Jan 2012 13:39:20 -0800 Subject: tcm_fc: Use transport_generic_free_cmd for ft_sess_put in ft_send_tm transport_generic_free_cmd will end up calling ft_sess_put, so it should work just the same. Signed-off-by: Andy Grover Cc: Kiran Patil Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 3926f4a66cb..a08119f5703 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -408,7 +408,7 @@ static void ft_send_tm(struct ft_cmd *cmd) sess = cmd->sess; transport_send_check_condition_and_sense(&cmd->se_cmd, cmd->se_cmd.scsi_sense_reason, 0); - ft_sess_put(sess); + transport_generic_free_cmd(&cmd->se_cmd, 0); return; } -- cgit v1.2.3 From 59dcb5ec47965d8d22428db67cbea33a9ec4f347 Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 19 Jan 2012 13:39:22 -0800 Subject: tcm_fc: Convert ft_send_tm to use target_submit_tmr Change ft_send_tm() make use of the new target_submit_tmr helper Signed-off-by: Andy Grover Cc: Kiran Patil Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_cmd.c | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index a08119f5703..ed69c0deb10 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -354,8 +354,6 @@ static void ft_send_resp_code_and_free(struct ft_cmd *cmd, static void ft_send_tm(struct ft_cmd *cmd) { struct fcp_cmnd *fcp; - struct ft_sess *sess; - int rc; u8 tm_func; fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); @@ -386,33 +384,9 @@ static void ft_send_tm(struct ft_cmd *cmd) return; } - transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops, - cmd->sess->se_sess, 0, DMA_NONE, 0, - &cmd->ft_sense_buffer[0]); - target_get_sess_cmd(cmd->sess->se_sess, &cmd->se_cmd, false); - - pr_debug("alloc tm cmd fn %d\n", tm_func); - rc = core_tmr_alloc_req(&cmd->se_cmd, cmd, tm_func, GFP_KERNEL); - if (rc < 0) { - pr_debug("alloc failed\n"); - ft_send_resp_code_and_free(cmd, FCP_TMF_FAILED); - return; - } - - rc = transport_lookup_tmr_lun(&cmd->se_cmd, scsilun_to_int(&fcp->fc_lun)); - if (rc < 0) { - pr_debug("Failed to get LUN for TMR func %d, " - "se_cmd %p, unpacked_lun %d\n", - tm_func, &cmd->se_cmd, scsilun_to_int(&fcp->fc_lun)); - ft_dump_cmd(cmd, __func__); - sess = cmd->sess; - transport_send_check_condition_and_sense(&cmd->se_cmd, - cmd->se_cmd.scsi_sense_reason, 0); - transport_generic_free_cmd(&cmd->se_cmd, 0); - return; - } - - transport_generic_handle_tmr(&cmd->se_cmd); + target_submit_tmr(&cmd->se_cmd, cmd->sess->se_sess, + &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), + cmd, tm_func, 0); } /* -- cgit v1.2.3 From 00ad4c4e81ba8bfcc52c42ec9d72ff84a081fb82 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Sat, 25 Feb 2012 01:43:04 -0800 Subject: tcm_fc: Handle target_submit_tmr allocation failure This patch makes ft_send_tm() handle target_submit_tmr() allocation failures via an ft_send_resp_code_and_free() w/ FCP_TMF_FAILED status. Cc: Andy Grover Cc: Kiran Patil Cc: Arun Easi Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_cmd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index ed69c0deb10..be3319af5d8 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -354,6 +354,7 @@ static void ft_send_resp_code_and_free(struct ft_cmd *cmd, static void ft_send_tm(struct ft_cmd *cmd) { struct fcp_cmnd *fcp; + int rc; u8 tm_func; fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); @@ -384,9 +385,11 @@ static void ft_send_tm(struct ft_cmd *cmd) return; } - target_submit_tmr(&cmd->se_cmd, cmd->sess->se_sess, + rc = target_submit_tmr(&cmd->se_cmd, cmd->sess->se_sess, &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), cmd, tm_func, 0); + if (rc < 0) + ft_send_resp_code_and_free(cmd, FCP_TMF_FAILED); } /* -- cgit v1.2.3 From c0974f89385970455a60a999ae4fc0a783cf458d Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Sat, 25 Feb 2012 05:10:04 -0800 Subject: target: Allow target_submit_tmr interrupt context + pass ABORT_TASK tag This patch allows target_submit_tmr() to pass gfp_t for se_cmd->se_tmr_req allocation, and also set up se_cmd->se_tmr_req->ref_task_tag for passed tag with TMR_ABORT_TASK. Also update tcm_fc(fcoe) parameter usgae and add ref_task_tag FIXME for TMR_ABORT_TASK usage, Cc: Andy Grover Cc: Kiran Patil Cc: Arun Easi Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_transport.c | 10 ++++++++-- drivers/target/tcm_fc/tfc_cmd.c | 3 ++- include/target/target_core_fabric.h | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index ca1a40dc488..3533ad64428 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1713,6 +1713,8 @@ static void target_complete_tmr_failure(struct work_struct *work) * @unpacked_lun: unpacked LUN to reference for struct se_lun * @fabric_context: fabric context for TMR req * @tm_type: Type of TM request + * @gfp: gfp type for caller + * @tag: referenced task tag for TMR_ABORT_TASK * @flags: submit cmd flags * * Callable from all contexts. @@ -1720,7 +1722,8 @@ static void target_complete_tmr_failure(struct work_struct *work) int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, unsigned char *sense, u32 unpacked_lun, - void *fabric_tmr_ptr, unsigned char tm_type, int flags) + void *fabric_tmr_ptr, unsigned char tm_type, + gfp_t gfp, unsigned int tag, int flags) { struct se_portal_group *se_tpg; int ret; @@ -1734,10 +1737,13 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, * FIXME: Currently expect caller to handle se_cmd->se_tmr_req * allocation failure. */ - ret = core_tmr_alloc_req(se_cmd, fabric_tmr_ptr, tm_type, GFP_KERNEL); + ret = core_tmr_alloc_req(se_cmd, fabric_tmr_ptr, tm_type, gfp); if (ret < 0) return -ENOMEM; + if (tm_type == TMR_ABORT_TASK) + se_cmd->se_tmr_req->ref_task_tag = tag; + /* See target_submit_cmd for commentary */ target_get_sess_cmd(se_sess, se_cmd, (flags & TARGET_SCF_ACK_KREF)); diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index be3319af5d8..17ffc82274a 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -385,9 +385,10 @@ static void ft_send_tm(struct ft_cmd *cmd) return; } + /* FIXME: Add referenced task tag for ABORT_TASK */ rc = target_submit_tmr(&cmd->se_cmd, cmd->sess->se_sess, &cmd->ft_sense_buffer[0], scsilun_to_int(&fcp->fc_lun), - cmd, tm_func, 0); + cmd, tm_func, GFP_KERNEL, 0, 0); if (rc < 0) ft_send_resp_code_and_free(cmd, FCP_TMF_FAILED); } diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 77a3b6e4f44..e5d8c47892b 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -118,7 +118,8 @@ void target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *, unsigned char *, u32, u32, int, int, int); int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, unsigned char *sense, u32 unpacked_lun, - void *fabric_tmr_ptr, unsigned char tm_type, int flags); + void *fabric_tmr_ptr, unsigned char tm_type, + gfp_t, unsigned int, int); int transport_handle_cdb_direct(struct se_cmd *); int transport_generic_handle_cdb_map(struct se_cmd *); int transport_generic_handle_data(struct se_cmd *); -- cgit v1.2.3 From c7ec05c82bfd6acf1fd800d628591500805f3179 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Tue, 28 Feb 2012 00:22:12 -0800 Subject: target: Drop unused legacy target_core_fabric_ops API callers This patch drops the following unused legacy API callers from target_core_fabric.h: *) TFO->fall_back_to_erl0() *) TFO->stop_session() *) TFO->sess_logged_in() *) TFO->is_state_remove() This patch also removes the stub usage in loopback, tcm_fc, iscsi_target, and ib_srpt fabric modules. Signed-off-by: Nicholas Bellinger --- drivers/infiniband/ulp/srpt/ib_srpt.c | 28 ------------------ drivers/target/iscsi/iscsi_target_configfs.c | 43 ---------------------------- drivers/target/loopback/tcm_loop.c | 33 --------------------- drivers/target/target_core_configfs.c | 16 ----------- drivers/target/tcm_fc/tcm_fc.h | 4 --- drivers/target/tcm_fc/tfc_cmd.c | 5 ---- drivers/target/tcm_fc/tfc_conf.c | 4 --- drivers/target/tcm_fc/tfc_sess.c | 19 ------------ include/target/target_core_fabric.h | 4 --- 9 files changed, 156 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 3290a57b248..6735b63d96f 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -3520,25 +3520,6 @@ static void srpt_close_session(struct se_session *se_sess) WARN_ON(res <= 0); } -/** - * To do: Find out whether stop_session() has a meaning for transports - * other than iSCSI. - */ -static void srpt_stop_session(struct se_session *se_sess, int sess_sleep, - int conn_sleep) -{ -} - -static void srpt_reset_nexus(struct se_session *sess) -{ - printk(KERN_ERR "This is the SRP protocol, not iSCSI\n"); -} - -static int srpt_sess_logged_in(struct se_session *se_sess) -{ - return true; -} - /** * srpt_sess_get_index() - Return the value of scsiAttIntrPortIndex (SCSI-MIB). * @@ -3583,11 +3564,6 @@ static u16 srpt_get_fabric_sense_len(void) return 0; } -static int srpt_is_state_remove(struct se_cmd *se_cmd) -{ - return 0; -} - /** * srpt_parse_i_port_id() - Parse an initiator port ID. * @name: ASCII representation of a 128-bit initiator port ID. @@ -3957,9 +3933,6 @@ static struct target_core_fabric_ops srpt_template = { .check_stop_free = srpt_check_stop_free, .shutdown_session = srpt_shutdown_session, .close_session = srpt_close_session, - .stop_session = srpt_stop_session, - .fall_back_to_erl0 = srpt_reset_nexus, - .sess_logged_in = srpt_sess_logged_in, .sess_get_index = srpt_sess_get_index, .sess_get_initiator_sid = NULL, .write_pending = srpt_write_pending, @@ -3972,7 +3945,6 @@ static struct target_core_fabric_ops srpt_template = { .queue_tm_rsp = srpt_queue_response, .get_fabric_sense_len = srpt_get_fabric_sense_len, .set_fabric_sense_len = srpt_set_fabric_sense_len, - .is_state_remove = srpt_is_state_remove, /* * Setup function pointers for generic logic in * target_core_fabric_configfs.c diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 1174f74f4fb..00c58cc82c8 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -1503,28 +1503,6 @@ static int iscsi_get_cmd_state(struct se_cmd *se_cmd) return cmd->i_state; } -static int iscsi_is_state_remove(struct se_cmd *se_cmd) -{ - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); - - return (cmd->i_state == ISTATE_REMOVE); -} - -static int lio_sess_logged_in(struct se_session *se_sess) -{ - struct iscsi_session *sess = se_sess->fabric_sess_ptr; - int ret; - /* - * Called with spin_lock_bh(&tpg_lock); and - * spin_lock(&se_tpg->session_lock); held. - */ - spin_lock(&sess->conn_lock); - ret = (sess->session_state != TARG_SESS_STATE_LOGGED_IN); - spin_unlock(&sess->conn_lock); - - return ret; -} - static u32 lio_sess_get_index(struct se_session *se_sess) { struct iscsi_session *sess = se_sess->fabric_sess_ptr; @@ -1718,23 +1696,6 @@ static void lio_tpg_close_session(struct se_session *se_sess) iscsit_close_session(sess); } -static void lio_tpg_stop_session( - struct se_session *se_sess, - int sess_sleep, - int conn_sleep) -{ - struct iscsi_session *sess = se_sess->fabric_sess_ptr; - - iscsit_stop_session(sess, sess_sleep, conn_sleep); -} - -static void lio_tpg_fall_back_to_erl0(struct se_session *se_sess) -{ - struct iscsi_session *sess = se_sess->fabric_sess_ptr; - - iscsit_fall_back_to_erl0(sess); -} - static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg) { struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; @@ -1798,9 +1759,6 @@ int iscsi_target_register_configfs(void) fabric->tf_ops.release_cmd = &lio_release_cmd; fabric->tf_ops.shutdown_session = &lio_tpg_shutdown_session; fabric->tf_ops.close_session = &lio_tpg_close_session; - fabric->tf_ops.stop_session = &lio_tpg_stop_session; - fabric->tf_ops.fall_back_to_erl0 = &lio_tpg_fall_back_to_erl0; - fabric->tf_ops.sess_logged_in = &lio_sess_logged_in; fabric->tf_ops.sess_get_index = &lio_sess_get_index; fabric->tf_ops.sess_get_initiator_sid = &lio_sess_get_initiator_sid; fabric->tf_ops.write_pending = &lio_write_pending; @@ -1814,7 +1772,6 @@ int iscsi_target_register_configfs(void) fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp; fabric->tf_ops.set_fabric_sense_len = &lio_set_fabric_sense_len; fabric->tf_ops.get_fabric_sense_len = &lio_get_fabric_sense_len; - fabric->tf_ops.is_state_remove = &iscsi_is_state_remove; /* * Setup function pointers for generic logic in target_core_fabric_configfs.c */ diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 041673e9d2d..026dffa0ed5 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -736,22 +736,6 @@ static u32 tcm_loop_get_inst_index(struct se_portal_group *se_tpg) return 1; } -static int tcm_loop_is_state_remove(struct se_cmd *se_cmd) -{ - /* - * Assume struct scsi_cmnd is not in remove state.. - */ - return 0; -} - -static int tcm_loop_sess_logged_in(struct se_session *se_sess) -{ - /* - * Assume that TL Nexus is always active - */ - return 1; -} - static u32 tcm_loop_sess_get_index(struct se_session *se_sess) { return 1; @@ -785,19 +769,6 @@ static void tcm_loop_close_session(struct se_session *se_sess) return; }; -static void tcm_loop_stop_session( - struct se_session *se_sess, - int sess_sleep, - int conn_sleep) -{ - return; -} - -static void tcm_loop_fall_back_to_erl0(struct se_session *se_sess) -{ - return; -} - static int tcm_loop_write_pending(struct se_cmd *se_cmd) { /* @@ -1391,9 +1362,6 @@ static int tcm_loop_register_configfs(void) fabric->tf_ops.release_cmd = &tcm_loop_release_cmd; fabric->tf_ops.shutdown_session = &tcm_loop_shutdown_session; fabric->tf_ops.close_session = &tcm_loop_close_session; - fabric->tf_ops.stop_session = &tcm_loop_stop_session; - fabric->tf_ops.fall_back_to_erl0 = &tcm_loop_fall_back_to_erl0; - fabric->tf_ops.sess_logged_in = &tcm_loop_sess_logged_in; fabric->tf_ops.sess_get_index = &tcm_loop_sess_get_index; fabric->tf_ops.sess_get_initiator_sid = NULL; fabric->tf_ops.write_pending = &tcm_loop_write_pending; @@ -1410,7 +1378,6 @@ static int tcm_loop_register_configfs(void) fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp; fabric->tf_ops.set_fabric_sense_len = &tcm_loop_set_fabric_sense_len; fabric->tf_ops.get_fabric_sense_len = &tcm_loop_get_fabric_sense_len; - fabric->tf_ops.is_state_remove = &tcm_loop_is_state_remove; tf_cg = &fabric->tf_group; /* diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 2ecde0d4d4e..72bd7f5d679 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -421,18 +421,6 @@ static int target_fabric_tf_ops_check( pr_err("Missing tfo->close_session()\n"); return -EINVAL; } - if (!tfo->stop_session) { - pr_err("Missing tfo->stop_session()\n"); - return -EINVAL; - } - if (!tfo->fall_back_to_erl0) { - pr_err("Missing tfo->fall_back_to_erl0()\n"); - return -EINVAL; - } - if (!tfo->sess_logged_in) { - pr_err("Missing tfo->sess_logged_in()\n"); - return -EINVAL; - } if (!tfo->sess_get_index) { pr_err("Missing tfo->sess_get_index()\n"); return -EINVAL; @@ -477,10 +465,6 @@ static int target_fabric_tf_ops_check( pr_err("Missing tfo->get_fabric_sense_len()\n"); return -EINVAL; } - if (!tfo->is_state_remove) { - pr_err("Missing tfo->is_state_remove()\n"); - return -EINVAL; - } /* * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn() * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h index 7906b9f8eba..524b9768398 100644 --- a/drivers/target/tcm_fc/tcm_fc.h +++ b/drivers/target/tcm_fc/tcm_fc.h @@ -141,11 +141,8 @@ extern struct target_fabric_configfs *ft_configfs; void ft_sess_put(struct ft_sess *); int ft_sess_shutdown(struct se_session *); void ft_sess_close(struct se_session *); -void ft_sess_stop(struct se_session *, int, int); -int ft_sess_logged_in(struct se_session *); u32 ft_sess_get_index(struct se_session *); u32 ft_sess_get_port_name(struct se_session *, unsigned char *, u32); -void ft_sess_set_erl0(struct se_session *); void ft_lport_add(struct fc_lport *, void *); void ft_lport_del(struct fc_lport *, void *); @@ -163,7 +160,6 @@ int ft_write_pending_status(struct se_cmd *); u32 ft_get_task_tag(struct se_cmd *); int ft_get_cmd_state(struct se_cmd *); int ft_queue_tm_resp(struct se_cmd *); -int ft_is_state_remove(struct se_cmd *); /* * other internal functions. diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 17ffc82274a..b831461156b 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -244,11 +244,6 @@ int ft_get_cmd_state(struct se_cmd *se_cmd) return 0; } -int ft_is_state_remove(struct se_cmd *se_cmd) -{ - return 0; /* XXX TBD */ -} - /* * FC sequence response handler for follow-on sequences (data) and aborts. */ diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index 73852fbc857..f357039349b 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c @@ -529,9 +529,6 @@ static struct target_core_fabric_ops ft_fabric_ops = { .release_cmd = ft_release_cmd, .shutdown_session = ft_sess_shutdown, .close_session = ft_sess_close, - .stop_session = ft_sess_stop, - .fall_back_to_erl0 = ft_sess_set_erl0, - .sess_logged_in = ft_sess_logged_in, .sess_get_index = ft_sess_get_index, .sess_get_initiator_sid = NULL, .write_pending = ft_write_pending, @@ -544,7 +541,6 @@ static struct target_core_fabric_ops ft_fabric_ops = { .queue_tm_rsp = ft_queue_tm_resp, .get_fabric_sense_len = ft_get_fabric_sense_len, .set_fabric_sense_len = ft_set_fabric_sense_len, - .is_state_remove = ft_is_state_remove, /* * Setup function pointers for generic logic in * target_core_fabric_configfs.c diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c index 4c0507cf808..a1d1f3c8644 100644 --- a/drivers/target/tcm_fc/tfc_sess.c +++ b/drivers/target/tcm_fc/tfc_sess.c @@ -338,20 +338,6 @@ void ft_sess_close(struct se_session *se_sess) synchronize_rcu(); /* let transport deregister happen */ } -void ft_sess_stop(struct se_session *se_sess, int sess_sleep, int conn_sleep) -{ - struct ft_sess *sess = se_sess->fabric_sess_ptr; - - pr_debug("port_id %x\n", sess->port_id); -} - -int ft_sess_logged_in(struct se_session *se_sess) -{ - struct ft_sess *sess = se_sess->fabric_sess_ptr; - - return sess->port_id != -1; -} - u32 ft_sess_get_index(struct se_session *se_sess) { struct ft_sess *sess = se_sess->fabric_sess_ptr; @@ -367,11 +353,6 @@ u32 ft_sess_get_port_name(struct se_session *se_sess, return ft_format_wwn(buf, len, sess->port_name); } -void ft_sess_set_erl0(struct se_session *se_sess) -{ - /* XXX TBD called when out of memory */ -} - /* * libfc ops involving sessions. */ diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 032c48753cf..10c69080960 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -58,9 +58,6 @@ struct target_core_fabric_ops { */ int (*shutdown_session)(struct se_session *); void (*close_session)(struct se_session *); - void (*stop_session)(struct se_session *, int, int); - void (*fall_back_to_erl0)(struct se_session *); - int (*sess_logged_in)(struct se_session *); u32 (*sess_get_index)(struct se_session *); /* * Used only for SCSI fabrics that contain multi-value TransportIDs @@ -78,7 +75,6 @@ struct target_core_fabric_ops { int (*queue_tm_rsp)(struct se_cmd *); u16 (*set_fabric_sense_len)(struct se_cmd *, u32); u16 (*get_fabric_sense_len)(void); - int (*is_state_remove)(struct se_cmd *); /* * fabric module calls for target_core_fabric_configfs.c */ -- cgit v1.2.3 From 031ed4d565b31880a4136bb7366bc89f5b1dba7d Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Fri, 9 Mar 2012 23:45:38 -0800 Subject: tcm_fc: Fix fc_exch memory leak in ft_send_resp_status This patch fixes a bug in tcm_fc where fc_exch memory from fc_exch_mgr->ep_pool is currently being leaked by ft_send_resp_status() usage. Following current code in ft_queue_status() response path, using lport->tt.seq_send() needs to be followed by a lport->tt.exch_done() in order to release fc_exch memory back into libfc_em kmem_cache. ft_send_resp_status() code is currently used in pre submit se_cmd ft_send_work() error exceptions, TM request setup exceptions, and main TM response callback path in ft_queue_tm_resp(). This bugfix addresses the leak in these cases. Cc: Mark D Rustad Cc: Kiran Patil Cc: Robert Love Cc: Andy Grover Cc: stable@vger.kernel.org Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_cmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index b831461156b..62dec9715ce 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -315,10 +315,12 @@ static void ft_send_resp_status(struct fc_lport *lport, fc_fill_reply_hdr(fp, rx_fp, FC_RCTL_DD_CMD_STATUS, 0); sp = fr_seq(fp); - if (sp) + if (sp) { lport->tt.seq_send(lport, sp, fp); - else + lport->tt.exch_done(sp); + } else { lport->tt.frame_send(lport, fp); + } } /* -- cgit v1.2.3 From 9765b1f327951e643a97f43924d1fbeb4e90ffba Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Sat, 10 Mar 2012 14:50:19 -0800 Subject: target: Bump core version to v4.1.0-rc2-ml + fabric versions Bump core version to v4.1.0-rc2-ml, and for versions from the following mainline fabric modules: loopback: v2.1-rc2 tcm_fc: v0.4 iscsi-target: v4.1.0-rc2 Signed-off-by: Nicholas Bellinger --- drivers/target/iscsi/iscsi_target_core.h | 2 +- drivers/target/loopback/tcm_loop.h | 2 +- drivers/target/tcm_fc/tcm_fc.h | 2 +- include/target/target_core_base.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h index 0ec3b77a0c2..2aaee7efa68 100644 --- a/drivers/target/iscsi/iscsi_target_core.h +++ b/drivers/target/iscsi/iscsi_target_core.h @@ -9,7 +9,7 @@ #include #include -#define ISCSIT_VERSION "v4.1.0-rc1" +#define ISCSIT_VERSION "v4.1.0-rc2" #define ISCSI_MAX_DATASN_MISSING_COUNT 16 #define ISCSI_TX_THREAD_TCP_TIMEOUT 2 #define ISCSI_RX_THREAD_TCP_TIMEOUT 2 diff --git a/drivers/target/loopback/tcm_loop.h b/drivers/target/loopback/tcm_loop.h index fc9bade9641..7b54893db66 100644 --- a/drivers/target/loopback/tcm_loop.h +++ b/drivers/target/loopback/tcm_loop.h @@ -1,4 +1,4 @@ -#define TCM_LOOP_VERSION "v2.1-rc1" +#define TCM_LOOP_VERSION "v2.1-rc2" #define TL_WWN_ADDR_LEN 256 #define TL_TPGS_PER_HBA 32 diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h index 524b9768398..830657908db 100644 --- a/drivers/target/tcm_fc/tcm_fc.h +++ b/drivers/target/tcm_fc/tcm_fc.h @@ -17,7 +17,7 @@ #ifndef __TCM_FC_H__ #define __TCM_FC_H__ -#define FT_VERSION "0.3" +#define FT_VERSION "0.4" #define FT_NAMELEN 32 /* length of ASCII WWPNs including pad */ #define FT_TPG_NAMELEN 32 /* max length of TPG name */ diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 469678d74bb..c3334094c66 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -9,7 +9,7 @@ #include #include -#define TARGET_CORE_MOD_VERSION "v4.1.0-rc1-ml" +#define TARGET_CORE_MOD_VERSION "v4.1.0-rc2-ml" #define TARGET_CORE_VERSION TARGET_CORE_MOD_VERSION /* Maximum Number of LUNs per Target Portal Group */ -- cgit v1.2.3 From 281689051a628e5341ce1efcfafde9d60f2f6fbb Mon Sep 17 00:00:00 2001 From: Jörn Engel Date: Thu, 15 Mar 2012 15:06:58 -0400 Subject: target: remove obvious warnings Get rid of a bunch of write-only variables. In a number of cases I suspect actual bugs to be present, so I left all of those for a second look. (nab: fix lio-core patch fuzz) Signed-off-by: Joern Engel Signed-off-by: Nicholas Bellinger --- drivers/target/iscsi/iscsi_target.c | 11 ----------- drivers/target/iscsi/iscsi_target_login.c | 4 +--- drivers/target/iscsi/iscsi_target_nego.c | 8 +------- drivers/target/loopback/tcm_loop.c | 2 -- drivers/target/target_core_configfs.c | 2 -- drivers/target/target_core_device.c | 2 -- drivers/target/target_core_pr.c | 9 +-------- drivers/target/target_core_stat.c | 12 ------------ drivers/target/target_core_tpg.c | 7 +++---- drivers/target/tcm_fc/tfc_sess.c | 2 -- 10 files changed, 6 insertions(+), 53 deletions(-) (limited to 'drivers/target/tcm_fc') diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index d3b54ecbfcd..b8fbc299d4e 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1469,14 +1469,12 @@ static int iscsit_handle_nop_out( unsigned char *ping_data = NULL; int cmdsn_ret, niov = 0, ret = 0, rx_got, rx_size; u32 checksum, data_crc, padding = 0, payload_length; - u64 lun; struct iscsi_cmd *cmd = NULL; struct kvec *iov = NULL; struct iscsi_nopout *hdr; hdr = (struct iscsi_nopout *) buf; payload_length = ntoh24(hdr->dlength); - lun = get_unaligned_le64(&hdr->lun); hdr->itt = be32_to_cpu(hdr->itt); hdr->ttt = be32_to_cpu(hdr->ttt); hdr->cmdsn = be32_to_cpu(hdr->cmdsn); @@ -1686,13 +1684,11 @@ static int iscsit_handle_task_mgt_cmd( struct se_tmr_req *se_tmr; struct iscsi_tmr_req *tmr_req; struct iscsi_tm *hdr; - u32 payload_length; int out_of_order_cmdsn = 0; int ret; u8 function; hdr = (struct iscsi_tm *) buf; - payload_length = ntoh24(hdr->dlength); hdr->itt = be32_to_cpu(hdr->itt); hdr->rtt = be32_to_cpu(hdr->rtt); hdr->cmdsn = be32_to_cpu(hdr->cmdsn); @@ -2204,14 +2200,10 @@ static int iscsit_handle_snack( struct iscsi_conn *conn, unsigned char *buf) { - u32 unpacked_lun; - u64 lun; struct iscsi_snack *hdr; hdr = (struct iscsi_snack *) buf; hdr->flags &= ~ISCSI_FLAG_CMD_FINAL; - lun = get_unaligned_le64(&hdr->lun); - unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun); hdr->itt = be32_to_cpu(hdr->itt); hdr->ttt = be32_to_cpu(hdr->ttt); hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); @@ -3511,7 +3503,6 @@ int iscsi_target_tx_thread(void *arg) struct iscsi_cmd *cmd = NULL; struct iscsi_conn *conn; struct iscsi_queue_req *qr = NULL; - struct se_cmd *se_cmd; struct iscsi_thread_set *ts = arg; /* * Allow ourselves to be interrupted by SIGINT so that a @@ -3694,8 +3685,6 @@ check_rsp_state: goto transport_err; } - se_cmd = &cmd->se_cmd; - if (map_sg && !conn->conn_ops->IFMarker) { if (iscsit_fe_sendpage_sg(cmd, conn) < 0) { conn->tx_response_queue = 0; diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 18cffff9b45..1046b6259c8 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -882,7 +882,7 @@ fail: static int __iscsi_target_login_thread(struct iscsi_np *np) { u8 buffer[ISCSI_HDR_LEN], iscsi_opcode, zero_tsih = 0; - int err, ret = 0, ip_proto, sock_type, set_sctp_conn_flag, stop; + int err, ret = 0, set_sctp_conn_flag, stop; struct iscsi_conn *conn = NULL; struct iscsi_login *login; struct iscsi_portal_group *tpg = NULL; @@ -895,8 +895,6 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) flush_signals(current); set_sctp_conn_flag = 0; sock = np->np_socket; - ip_proto = np->np_ip_proto; - sock_type = np->np_sock_type; spin_lock_bh(&np->np_thread_lock); if (np->np_thread_state == ISCSI_NP_THREAD_RESET) { diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index 37a20baa1a8..2dba448cac1 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -173,13 +173,11 @@ static int iscsi_target_check_login_request( struct iscsi_conn *conn, struct iscsi_login *login) { - int req_csg, req_nsg, rsp_csg, rsp_nsg; + int req_csg, req_nsg; u32 payload_length; struct iscsi_login_req *login_req; - struct iscsi_login_rsp *login_rsp; login_req = (struct iscsi_login_req *) login->req; - login_rsp = (struct iscsi_login_rsp *) login->rsp; payload_length = ntoh24(login_req->dlength); switch (login_req->opcode & ISCSI_OPCODE_MASK) { @@ -203,9 +201,7 @@ static int iscsi_target_check_login_request( } req_csg = (login_req->flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2; - rsp_csg = (login_rsp->flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2; req_nsg = (login_req->flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK); - rsp_nsg = (login_rsp->flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK); if (req_csg != login->current_stage) { pr_err("Initiator unexpectedly changed login stage" @@ -753,12 +749,10 @@ static int iscsi_target_locate_portal( struct iscsi_session *sess = conn->sess; struct iscsi_tiqn *tiqn; struct iscsi_login_req *login_req; - struct iscsi_targ_login_rsp *login_rsp; u32 payload_length; int sessiontype = 0, ret = 0; login_req = (struct iscsi_login_req *) login->req; - login_rsp = (struct iscsi_targ_login_rsp *) login->rsp; payload_length = ntoh24(login_req->dlength); login->first_request = 1; diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 026dffa0ed5..22f4fe77237 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -1312,7 +1312,6 @@ static struct configfs_attribute *tcm_loop_wwn_attrs[] = { static int tcm_loop_register_configfs(void) { struct target_fabric_configfs *fabric; - struct config_group *tf_cg; int ret; /* * Set the TCM Loop HBA counter to zero @@ -1379,7 +1378,6 @@ static int tcm_loop_register_configfs(void) fabric->tf_ops.set_fabric_sense_len = &tcm_loop_set_fabric_sense_len; fabric->tf_ops.get_fabric_sense_len = &tcm_loop_get_fabric_sense_len; - tf_cg = &fabric->tf_group; /* * Setup function pointers for generic logic in target_core_fabric_configfs.c */ diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 72bd7f5d679..cbb66537d23 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -2853,7 +2853,6 @@ static void target_core_drop_subdev( struct se_subsystem_dev *se_dev = container_of(to_config_group(item), struct se_subsystem_dev, se_dev_group); struct se_hba *hba; - struct se_subsystem_api *t; struct config_item *df_item; struct config_group *dev_cg, *tg_pt_gp_cg, *dev_stat_grp; int i; @@ -2861,7 +2860,6 @@ static void target_core_drop_subdev( hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item); mutex_lock(&hba->hba_access_mutex); - t = hba->transport; dev_stat_grp = &se_dev->dev_stat_grps.stat_group; for (i = 0; dev_stat_grp->default_groups[i]; i++) { diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 3be7279865b..aa626774638 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -647,7 +647,6 @@ int target_report_luns(struct se_task *se_task) { struct se_cmd *se_cmd = se_task->task_se_cmd; struct se_dev_entry *deve; - struct se_lun *se_lun; struct se_session *se_sess = se_cmd->se_sess; unsigned char *buf; u32 lun_count = 0, offset = 8, i; @@ -672,7 +671,6 @@ int target_report_luns(struct se_task *se_task) deve = se_sess->se_node_acl->device_list[i]; if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) continue; - se_lun = deve->se_lun; /* * We determine the correct LUN LIST LENGTH even once we * have reached the initial allocation length. diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index de3e4f2f60b..5926b171dba 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -2416,9 +2416,7 @@ static int core_scsi3_pro_reserve( u64 res_key) { struct se_session *se_sess = cmd->se_sess; - struct se_dev_entry *se_deve; struct se_lun *se_lun = cmd->se_lun; - struct se_portal_group *se_tpg; struct t10_pr_registration *pr_reg, *pr_res_holder; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; char i_buf[PR_REG_ISID_ID_LEN]; @@ -2431,8 +2429,6 @@ static int core_scsi3_pro_reserve( cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; return -EINVAL; } - se_tpg = se_sess->se_tpg; - se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; /* * Locate the existing *pr_reg via struct se_node_acl pointers */ @@ -2990,7 +2986,6 @@ static int core_scsi3_pro_preempt( int abort) { struct se_device *dev = cmd->se_dev; - struct se_dev_entry *se_deve; struct se_node_acl *pr_reg_nacl; struct se_session *se_sess = cmd->se_sess; LIST_HEAD(preempt_and_abort_list); @@ -3005,7 +3000,6 @@ static int core_scsi3_pro_preempt( return -EINVAL; } - se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl, se_sess); if (!pr_reg_n) { @@ -3341,7 +3335,7 @@ static int core_scsi3_emulate_pro_register_and_move( { struct se_session *se_sess = cmd->se_sess; struct se_device *dev = cmd->se_dev; - struct se_dev_entry *se_deve, *dest_se_deve = NULL; + struct se_dev_entry *dest_se_deve = NULL; struct se_lun *se_lun = cmd->se_lun; struct se_node_acl *pr_res_nacl, *pr_reg_nacl, *dest_node_acl = NULL; struct se_port *se_port; @@ -3366,7 +3360,6 @@ static int core_scsi3_emulate_pro_register_and_move( memset(i_buf, 0, PR_REG_ISID_ID_LEN); se_tpg = se_sess->se_tpg; tf_ops = se_tpg->se_tpg_tfo; - se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; /* * Follow logic from spc4r17 Section 5.7.8, Table 50 -- * Register behaviors for a REGISTER AND MOVE service action diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index 7ce1bfa5c54..3d44beb0cf1 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c @@ -954,7 +954,6 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_in_cmds( { struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); struct se_port *sep; - struct se_portal_group *tpg; ssize_t ret; spin_lock(&lun->lun_sep_lock); @@ -963,7 +962,6 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_in_cmds( spin_unlock(&lun->lun_sep_lock); return -ENODEV; } - tpg = sep->sep_tpg; ret = snprintf(page, PAGE_SIZE, "%llu\n", sep->sep_stats.cmd_pdus); spin_unlock(&lun->lun_sep_lock); @@ -976,7 +974,6 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_write_mbytes( { struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); struct se_port *sep; - struct se_portal_group *tpg; ssize_t ret; spin_lock(&lun->lun_sep_lock); @@ -985,7 +982,6 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_write_mbytes( spin_unlock(&lun->lun_sep_lock); return -ENODEV; } - tpg = sep->sep_tpg; ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(sep->sep_stats.rx_data_octets >> 20)); @@ -999,7 +995,6 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_read_mbytes( { struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); struct se_port *sep; - struct se_portal_group *tpg; ssize_t ret; spin_lock(&lun->lun_sep_lock); @@ -1008,7 +1003,6 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_read_mbytes( spin_unlock(&lun->lun_sep_lock); return -ENODEV; } - tpg = sep->sep_tpg; ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(sep->sep_stats.tx_data_octets >> 20)); @@ -1022,7 +1016,6 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_hs_in_cmds( { struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); struct se_port *sep; - struct se_portal_group *tpg; ssize_t ret; spin_lock(&lun->lun_sep_lock); @@ -1031,7 +1024,6 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_hs_in_cmds( spin_unlock(&lun->lun_sep_lock); return -ENODEV; } - tpg = sep->sep_tpg; /* FIXME: scsiTgtPortHsInCommands */ ret = snprintf(page, PAGE_SIZE, "%u\n", 0); @@ -1275,7 +1267,6 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_dev( struct se_node_acl *nacl = lacl->se_lun_nacl; struct se_dev_entry *deve; struct se_lun *lun; - struct se_portal_group *tpg; ssize_t ret; spin_lock_irq(&nacl->device_list_lock); @@ -1284,7 +1275,6 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_dev( spin_unlock_irq(&nacl->device_list_lock); return -ENODEV; } - tpg = nacl->se_tpg; lun = deve->se_lun; /* scsiDeviceIndex */ ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_se_dev->dev_index); @@ -1643,7 +1633,6 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_dev( struct se_node_acl *nacl = lacl->se_lun_nacl; struct se_dev_entry *deve; struct se_lun *lun; - struct se_portal_group *tpg; ssize_t ret; spin_lock_irq(&nacl->device_list_lock); @@ -1652,7 +1641,6 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_dev( spin_unlock_irq(&nacl->device_list_lock); return -ENODEV; } - tpg = nacl->se_tpg; lun = deve->se_lun; /* scsiDeviceIndex */ ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_se_dev->dev_index); diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index c0fecde02fd..70c3ffb981e 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -359,7 +359,7 @@ void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *nacl) void core_tpg_clear_object_luns(struct se_portal_group *tpg) { - int i, ret; + int i; struct se_lun *lun; spin_lock(&tpg->tpg_lun_lock); @@ -371,7 +371,7 @@ void core_tpg_clear_object_luns(struct se_portal_group *tpg) continue; spin_unlock(&tpg->tpg_lun_lock); - ret = core_dev_del_lun(tpg, lun->unpacked_lun); + core_dev_del_lun(tpg, lun->unpacked_lun); spin_lock(&tpg->tpg_lun_lock); } spin_unlock(&tpg->tpg_lun_lock); @@ -483,12 +483,11 @@ int core_tpg_del_initiator_node_acl( LIST_HEAD(sess_list); struct se_session *sess, *sess_tmp; unsigned long flags; - int dynamic_acl = 0, rc; + int rc; spin_lock_irq(&tpg->acl_node_lock); if (acl->dynamic_node_acl) { acl->dynamic_node_acl = 0; - dynamic_acl = 1; } list_del(&acl->acl_list); tpg->num_node_acls--; diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c index a1d1f3c8644..b30f92bdc1a 100644 --- a/drivers/target/tcm_fc/tfc_sess.c +++ b/drivers/target/tcm_fc/tfc_sess.c @@ -319,11 +319,9 @@ int ft_sess_shutdown(struct se_session *se_sess) void ft_sess_close(struct se_session *se_sess) { struct ft_sess *sess = se_sess->fabric_sess_ptr; - struct fc_lport *lport; u32 port_id; mutex_lock(&ft_lport_lock); - lport = sess->tport->lport; port_id = sess->port_id; if (port_id == -1) { mutex_unlock(&ft_lport_lock); -- cgit v1.2.3