From f80d2f0846b7b9ceb1f2a5951229ee4391edaebd Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 25 Jan 2019 10:34:43 -0800 Subject: scsi: target/core: Remove the write_pending_status() callback function Due to the patch that makes TMF handling synchronous the write_pending_status() callback function is no longer called. Hence remove it. Acked-by: Felipe Balbi Reviewed-by: Sagi Grimberg Reviewed-by: Andy Grover Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: Bryant G. Ly Cc: Nicholas Bellinger Cc: Mike Christie Cc: Himanshu Madhani Cc: Quinn Tran Cc: Saurav Kashyap Cc: Michael S. Tsirkin Cc: Juergen Gross Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target_configfs.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'drivers/target/iscsi') diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index a5481dfeae8d..cac94c94ef5d 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -1389,18 +1389,6 @@ static int lio_write_pending(struct se_cmd *se_cmd) return 0; } -static int lio_write_pending_status(struct se_cmd *se_cmd) -{ - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); - int ret; - - spin_lock_bh(&cmd->istate_lock); - ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT); - spin_unlock_bh(&cmd->istate_lock); - - return ret; -} - static int lio_queue_status(struct se_cmd *se_cmd) { struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); @@ -1564,7 +1552,6 @@ const struct target_core_fabric_ops iscsi_ops = { .sess_get_index = lio_sess_get_index, .sess_get_initiator_sid = lio_sess_get_initiator_sid, .write_pending = lio_write_pending, - .write_pending_status = lio_write_pending_status, .set_default_node_attributes = lio_set_default_node_attributes, .get_cmd_state = iscsi_get_cmd_state, .queue_data_in = lio_queue_data_in, -- cgit 1.4.1 From b53655b80cfcf33c0b753cf17dc3d42a97299c2f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 25 Jan 2019 10:34:52 -0800 Subject: scsi: target/iscsi: Remove an incorrect comment The single iscsit_start_nopin_response_timer() caller does not hold any locks. Hence remove the comment above this function. Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target_util.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/target/iscsi') diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 86987da86dd6..762448e2f8b7 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -956,9 +956,6 @@ void iscsit_mod_nopin_response_timer(struct iscsi_conn *conn) spin_unlock_bh(&conn->nopin_timer_lock); } -/* - * Called with conn->nopin_timer_lock held. - */ void iscsit_start_nopin_response_timer(struct iscsi_conn *conn) { struct iscsi_session *sess = conn->sess; -- cgit 1.4.1 From 618baaf7881e4ed25197369505378685b7b7a05d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 25 Jan 2019 10:34:53 -0800 Subject: scsi: target/iscsi: Convert comments about locking into runtime checks Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target.c | 10 ++++------ drivers/target/iscsi/iscsi_target_erl0.c | 5 ++--- drivers/target/iscsi/iscsi_target_erl1.c | 16 +++++++--------- drivers/target/iscsi/iscsi_target_util.c | 16 +++++++--------- drivers/target/target_core_alua.c | 5 ++--- drivers/target/target_core_device.c | 6 +++--- drivers/target/target_core_pr.c | 15 ++++++--------- 7 files changed, 31 insertions(+), 42 deletions(-) (limited to 'drivers/target/iscsi') diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 984941e036c8..98984c3adfba 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -308,9 +308,6 @@ bool iscsit_check_np_match( return false; } -/* - * Called with mutex np_lock held - */ static struct iscsi_np *iscsit_get_np( struct sockaddr_storage *sockaddr, int network_transport) @@ -318,6 +315,8 @@ static struct iscsi_np *iscsit_get_np( struct iscsi_np *np; bool match; + lockdep_assert_held(&np_lock); + list_for_each_entry(np, &g_np_list, np_list) { spin_lock_bh(&np->np_thread_lock); if (np->np_thread_state != ISCSI_NP_THREAD_ACTIVE) { @@ -2655,9 +2654,6 @@ static int iscsit_handle_immediate_data( return IMMEDIATE_DATA_NORMAL_OPERATION; } -/* - * Called with sess->conn_lock held. - */ /* #warning iscsi_build_conn_drop_async_message() only sends out on connections with active network interface */ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) @@ -2666,6 +2662,8 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) struct iscsi_conn *conn_p; bool found = false; + lockdep_assert_held(&conn->sess->conn_lock); + /* * Only send a Asynchronous Message on connections whos network * interface is still functional. diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index 1193cf884a28..8890c0721053 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c @@ -802,14 +802,13 @@ void iscsit_start_time2retain_handler(struct iscsi_session *sess) jiffies + sess->sess_ops->DefaultTime2Retain * HZ); } -/* - * Called with spin_lock_bh(&struct se_portal_group->session_lock) held - */ int iscsit_stop_time2retain_timer(struct iscsi_session *sess) { struct iscsi_portal_group *tpg = sess->tpg; struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; + lockdep_assert_held(&se_tpg->session_lock); + if (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED) return -1; diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index 1b54a9c70851..38210ab09887 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -797,14 +797,14 @@ static struct iscsi_ooo_cmdsn *iscsit_allocate_ooo_cmdsn(void) return ooo_cmdsn; } -/* - * Called with sess->cmdsn_mutex held. - */ static int iscsit_attach_ooo_cmdsn( struct iscsi_session *sess, struct iscsi_ooo_cmdsn *ooo_cmdsn) { struct iscsi_ooo_cmdsn *ooo_tail, *ooo_tmp; + + lockdep_assert_held(&sess->cmdsn_mutex); + /* * We attach the struct iscsi_ooo_cmdsn entry to the out of order * list in increasing CmdSN order. @@ -871,15 +871,14 @@ void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *conn) mutex_unlock(&sess->cmdsn_mutex); } -/* - * Called with sess->cmdsn_mutex held. - */ int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess) { int ooo_count = 0; struct iscsi_cmd *cmd = NULL; struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp; + lockdep_assert_held(&sess->cmdsn_mutex); + list_for_each_entry_safe(ooo_cmdsn, ooo_cmdsn_tmp, &sess->sess_ooo_cmdsn_list, ooo_list) { if (ooo_cmdsn->cmdsn != sess->exp_cmd_sn) @@ -1232,9 +1231,6 @@ void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd) spin_unlock_bh(&cmd->dataout_timeout_lock); } -/* - * Called with cmd->dataout_timeout_lock held. - */ void iscsit_start_dataout_timer( struct iscsi_cmd *cmd, struct iscsi_conn *conn) @@ -1242,6 +1238,8 @@ void iscsit_start_dataout_timer( struct iscsi_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); + lockdep_assert_held(&cmd->dataout_timeout_lock); + if (cmd->dataout_timer_flags & ISCSI_TF_RUNNING) return; diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 762448e2f8b7..58886d4b33cb 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -56,9 +56,6 @@ extern struct list_head g_tiqn_list; extern spinlock_t tiqn_lock; -/* - * Called with cmd->r2t_lock held. - */ int iscsit_add_r2t_to_list( struct iscsi_cmd *cmd, u32 offset, @@ -68,6 +65,8 @@ int iscsit_add_r2t_to_list( { struct iscsi_r2t *r2t; + lockdep_assert_held(&cmd->r2t_lock); + r2t = kmem_cache_zalloc(lio_r2t_cache, GFP_ATOMIC); if (!r2t) { pr_err("Unable to allocate memory for struct iscsi_r2t.\n"); @@ -128,11 +127,10 @@ struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *cmd) return NULL; } -/* - * Called with cmd->r2t_lock held. - */ void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsi_cmd *cmd) { + lockdep_assert_held(&cmd->r2t_lock); + list_del(&r2t->r2t_list); kmem_cache_free(lio_r2t_cache, r2t); } @@ -1013,13 +1011,13 @@ void iscsit_handle_nopin_timeout(struct timer_list *t) iscsit_dec_conn_usage_count(conn); } -/* - * Called with conn->nopin_timer_lock held. - */ void __iscsit_start_nopin_timer(struct iscsi_conn *conn) { struct iscsi_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); + + lockdep_assert_held(&conn->nopin_timer_lock); + /* * NOPIN timeout is disabled. */ diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 6b0d9beacf90..e09f0cf86bed 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -910,9 +910,6 @@ static int core_alua_write_tpg_metadata( return (ret < 0) ? -EIO : 0; } -/* - * Called with tg_pt_gp->tg_pt_gp_transition_mutex held - */ static int core_alua_update_tpg_primary_metadata( struct t10_alua_tg_pt_gp *tg_pt_gp) { @@ -921,6 +918,8 @@ static int core_alua_update_tpg_primary_metadata( char *path; int len, rc; + lockdep_assert_held(&tg_pt_gp->tg_pt_gp_transition_mutex); + md_buf = kzalloc(ALUA_MD_BUF_LEN, GFP_KERNEL); if (!md_buf) { pr_err("Unable to allocate buf for ALUA metadata\n"); diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 93c56f4a9911..1f8482b6473b 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -404,9 +404,6 @@ int core_enable_device_list_for_node( return 0; } -/* - * Called with se_node_acl->lun_entry_mutex held. - */ void core_disable_device_list_for_node( struct se_lun *lun, struct se_dev_entry *orig, @@ -418,6 +415,9 @@ void core_disable_device_list_for_node( * reference to se_device->dev_group. */ struct se_device *dev = rcu_dereference_raw(lun->lun_se_dev); + + lockdep_assert_held(&nacl->lun_entry_mutex); + /* * If the MappedLUN entry is being disabled, the entry in * lun->lun_deve_list must be removed now before clearing the diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 397f38cb7f4e..1597a9ebadca 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -1290,9 +1290,6 @@ static int core_scsi3_check_implicit_release( return ret; } -/* - * Called with struct t10_reservation->registration_lock held. - */ static void __core_scsi3_free_registration( struct se_device *dev, struct t10_pr_registration *pr_reg, @@ -1308,6 +1305,8 @@ static void __core_scsi3_free_registration( struct se_dev_entry *deve; char i_buf[PR_REG_ISID_ID_LEN]; + lockdep_assert_held(&pr_tmpl->registration_lock); + memset(i_buf, 0, PR_REG_ISID_ID_LEN); core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); @@ -2450,9 +2449,6 @@ core_scsi3_emulate_pro_reserve(struct se_cmd *cmd, int type, int scope, } } -/* - * Called with struct se_device->dev_reservation_lock held. - */ static void __core_scsi3_complete_pro_release( struct se_device *dev, struct se_node_acl *se_nacl, @@ -2464,6 +2460,8 @@ static void __core_scsi3_complete_pro_release( char i_buf[PR_REG_ISID_ID_LEN]; int pr_res_type = 0, pr_res_scope = 0; + lockdep_assert_held(&dev->dev_reservation_lock); + memset(i_buf, 0, PR_REG_ISID_ID_LEN); core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); /* @@ -2760,9 +2758,6 @@ core_scsi3_emulate_pro_clear(struct se_cmd *cmd, u64 res_key) return 0; } -/* - * Called with struct se_device->dev_reservation_lock held. - */ static void __core_scsi3_complete_pro_preempt( struct se_device *dev, struct t10_pr_registration *pr_reg, @@ -2775,6 +2770,8 @@ static void __core_scsi3_complete_pro_preempt( const struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo; char i_buf[PR_REG_ISID_ID_LEN]; + lockdep_assert_held(&dev->dev_reservation_lock); + memset(i_buf, 0, PR_REG_ISID_ID_LEN); core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); /* -- cgit 1.4.1 From 0300b1147e528fe6f6b0632b0ef353a87810dabf Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 25 Jan 2019 10:34:54 -0800 Subject: scsi: target/iscsi: Fix spelling of "unsolicited" Change "unsoliticed" into "unsolicited". Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Sagi Grimberg Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/infiniband/ulp/isert/ib_isert.c | 2 +- drivers/target/iscsi/cxgbit/cxgbit_target.c | 2 +- drivers/target/iscsi/iscsi_target.c | 8 ++++---- drivers/target/iscsi/iscsi_target.h | 2 +- drivers/target/iscsi/iscsi_target_erl1.c | 2 +- include/target/iscsi/iscsi_transport.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/target/iscsi') diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index e3dd13798d79..989f1ac4245c 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -1186,7 +1186,7 @@ sequence_cmd: rc = iscsit_sequence_cmd(conn, cmd, buf, hdr->cmdsn); if (!rc && dump_payload == false && unsol_data) - iscsit_set_unsoliticed_dataout(cmd); + iscsit_set_unsolicited_dataout(cmd); else if (dump_payload && imm_data) target_put_sess_cmd(&cmd->se_cmd); diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c index 25eb3891e34b..29b350a0b58f 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_target.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c @@ -960,7 +960,7 @@ after_immediate_data: target_put_sess_cmd(&cmd->se_cmd); return 0; } else if (cmd->unsolicited_data) { - iscsit_set_unsoliticed_dataout(cmd); + iscsit_set_unsolicited_dataout(cmd); } } else if (immed_ret == IMMEDIATE_DATA_ERL1_CRC_FAILURE) { diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 98984c3adfba..7059ffdb0c20 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1194,7 +1194,7 @@ attach_cmd: } EXPORT_SYMBOL(iscsit_setup_scsi_cmd); -void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *cmd) +void iscsit_set_unsolicited_dataout(struct iscsi_cmd *cmd) { iscsit_set_dataout_sequence_values(cmd); @@ -1202,7 +1202,7 @@ void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *cmd) iscsit_start_dataout_timer(cmd, cmd->conn); spin_unlock_bh(&cmd->dataout_timeout_lock); } -EXPORT_SYMBOL(iscsit_set_unsoliticed_dataout); +EXPORT_SYMBOL(iscsit_set_unsolicited_dataout); int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr) @@ -1236,7 +1236,7 @@ int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, */ if (!cmd->immediate_data) { if (!cmd->sense_reason && cmd->unsolicited_data) - iscsit_set_unsoliticed_dataout(cmd); + iscsit_set_unsolicited_dataout(cmd); if (!cmd->sense_reason) return 0; @@ -1308,7 +1308,7 @@ after_immediate_data: target_put_sess_cmd(&cmd->se_cmd); return rc; } else if (cmd->unsolicited_data) - iscsit_set_unsoliticed_dataout(cmd); + iscsit_set_unsolicited_dataout(cmd); } else if (immed_ret == IMMEDIATE_DATA_ERL1_CRC_FAILURE) { /* diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index 48bac0acf8c7..c95f56a3ce31 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h @@ -31,7 +31,7 @@ extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *, struct iscsi_portal_group *, bool); extern int iscsit_del_np(struct iscsi_np *); extern int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8, unsigned char *); -extern void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *); +extern void iscsit_set_unsolicited_dataout(struct iscsi_cmd *); extern int iscsit_logout_closesession(struct iscsi_cmd *, struct iscsi_conn *); extern int iscsit_logout_closeconnection(struct iscsi_cmd *, struct iscsi_conn *); extern int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *, struct iscsi_conn *); diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index 38210ab09887..c27335c29640 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -979,7 +979,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) if (cmd->se_cmd.transport_state & CMD_T_ABORTED) return 0; - iscsit_set_unsoliticed_dataout(cmd); + iscsit_set_unsolicited_dataout(cmd); } return transport_handle_cdb_direct(&cmd->se_cmd); diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h index 91948bc5b185..8b4b8ce2c1ae 100644 --- a/include/target/iscsi/iscsi_transport.h +++ b/include/target/iscsi/iscsi_transport.h @@ -53,7 +53,7 @@ extern void iscsit_put_transport(struct iscsit_transport *); */ extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *, unsigned char *); -extern void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *); +extern void iscsit_set_unsolicited_dataout(struct iscsi_cmd *); extern int iscsit_process_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *, struct iscsi_scsi_req *); extern int -- cgit 1.4.1 From 1e65cc1631c187c4607e9a2067769791be529ce6 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 25 Jan 2019 10:34:55 -0800 Subject: scsi: target/iscsi: Rename a function and a function pointer Having both a function and a function pointer member with the same name (iscsit_release_cmd) is confusing. Hence rename the function pointer member. Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/cxgbit/cxgbit.h | 2 +- drivers/target/iscsi/cxgbit/cxgbit_ddp.c | 2 +- drivers/target/iscsi/cxgbit/cxgbit_main.c | 2 +- drivers/target/iscsi/iscsi_target_util.c | 4 ++-- include/target/iscsi/iscsi_transport.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/target/iscsi') diff --git a/drivers/target/iscsi/cxgbit/cxgbit.h b/drivers/target/iscsi/cxgbit/cxgbit.h index 417b9e66b0cd..3cca22e19964 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit.h +++ b/drivers/target/iscsi/cxgbit/cxgbit.h @@ -345,7 +345,7 @@ struct cxgbit_device *cxgbit_find_device(struct net_device *, u8 *); int cxgbit_ddp_init(struct cxgbit_device *); int cxgbit_setup_conn_pgidx(struct cxgbit_sock *, u32); int cxgbit_reserve_ttt(struct cxgbit_sock *, struct iscsi_cmd *); -void cxgbit_release_cmd(struct iscsi_conn *, struct iscsi_cmd *); +void cxgbit_unmap_cmd(struct iscsi_conn *, struct iscsi_cmd *); static inline struct cxgbi_ppm *cdev2ppm(struct cxgbit_device *cdev) diff --git a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c index 76a262674c8d..d57fd3ed3fa5 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c @@ -263,7 +263,7 @@ out: r2t->targ_xfer_tag = ttinfo->tag; } -void cxgbit_release_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd) +void cxgbit_unmap_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd) { struct cxgbit_cmd *ccmd = iscsit_priv_cmd(cmd); diff --git a/drivers/target/iscsi/cxgbit/cxgbit_main.c b/drivers/target/iscsi/cxgbit/cxgbit_main.c index c011c826fc26..4a7bb0b49d17 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_main.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_main.c @@ -678,7 +678,7 @@ static struct iscsit_transport cxgbit_transport = { .iscsit_get_r2t_ttt = cxgbit_get_r2t_ttt, .iscsit_get_rx_pdu = cxgbit_get_rx_pdu, .iscsit_validate_params = cxgbit_validate_params, - .iscsit_release_cmd = cxgbit_release_cmd, + .iscsit_unmap_cmd = cxgbit_unmap_cmd, .iscsit_aborted_task = iscsit_aborted_task, .iscsit_get_sup_prot_ops = cxgbit_get_sup_prot_ops, }; diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 58886d4b33cb..3ac494f63a0b 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -760,8 +760,8 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues) iscsit_remove_cmd_from_response_queue(cmd, conn); } - if (conn && conn->conn_transport->iscsit_release_cmd) - conn->conn_transport->iscsit_release_cmd(conn, cmd); + if (conn && conn->conn_transport->iscsit_unmap_cmd) + conn->conn_transport->iscsit_unmap_cmd(conn, cmd); } void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h index 8b4b8ce2c1ae..75bee29fd7dd 100644 --- a/include/target/iscsi/iscsi_transport.h +++ b/include/target/iscsi/iscsi_transport.h @@ -26,7 +26,7 @@ struct iscsit_transport { void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsi_cmd *); int (*iscsit_xmit_pdu)(struct iscsi_conn *, struct iscsi_cmd *, struct iscsi_datain_req *, const void *, u32); - void (*iscsit_release_cmd)(struct iscsi_conn *, struct iscsi_cmd *); + void (*iscsit_unmap_cmd)(struct iscsi_conn *, struct iscsi_cmd *); void (*iscsit_get_rx_pdu)(struct iscsi_conn *); int (*iscsit_validate_params)(struct iscsi_conn *); void (*iscsit_get_r2t_ttt)(struct iscsi_conn *, struct iscsi_cmd *, -- cgit 1.4.1 From 32e36bfbcf31452a854263e7c7f32fbefc4b44d8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 25 Jan 2019 10:34:56 -0800 Subject: scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock When using SCSI passthrough in combination with the iSCSI target driver then cmd->t_state_lock may be obtained from interrupt context. Hence, all code that obtains cmd->t_state_lock from thread context must disable interrupts first. This patch avoids that lockdep reports the following: WARNING: inconsistent lock state 4.18.0-dbg+ #1 Not tainted -------------------------------- inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage. iscsi_ttx/1800 [HC1[1]:SC0[2]:HE0:SE0] takes: 000000006e7b0ceb (&(&cmd->t_state_lock)->rlock){?...}, at: target_complete_cmd+0x47/0x2c0 [target_core_mod] {HARDIRQ-ON-W} state was registered at: lock_acquire+0xd2/0x260 _raw_spin_lock+0x32/0x50 iscsit_close_connection+0x97e/0x1020 [iscsi_target_mod] iscsit_take_action_for_connection_exit+0x108/0x200 [iscsi_target_mod] iscsi_target_rx_thread+0x180/0x190 [iscsi_target_mod] kthread+0x1cf/0x1f0 ret_from_fork+0x24/0x30 irq event stamp: 1281 hardirqs last enabled at (1279): [] __local_bh_enable_ip+0xa9/0x160 hardirqs last disabled at (1281): [] interrupt_entry+0xb5/0xd0 softirqs last enabled at (1278): [] lock_sock_nested+0x51/0xc0 softirqs last disabled at (1280): [] ip6_finish_output2+0x124/0xe40 [ipv6] other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&(&cmd->t_state_lock)->rlock); lock(&(&cmd->t_state_lock)->rlock); *** DEADLOCK *** 3 locks held by iscsi_ttx/1800: *0: 00000000c3b711b7 (sk_lock-AF_INET6){+.+.}, at: tcp_sendmsg+0x1e/0x50 *1: 00000000fa81046f (rcu_read_lock){....}, at: inet6_csk_xmit+0xc7/0x2e0 [ipv6] *2: 00000000c091d70d (rcu_read_lock_bh){....}, at: ip6_finish_output2+0x124/0xe40 [ipv6] stack backtrace: CPU: 0 PID: 1800 Comm: iscsi_ttx Not tainted 4.18.0-dbg+ #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 Call Trace: dump_stack+0xa4/0xf5 print_usage_bug+0x25b/0x27b mark_lock+0x70f/0x7b0 __lock_acquire+0xbc2/0x1b50 lock_acquire+0xd2/0x260 _raw_spin_lock_irqsave+0x4a/0x60 target_complete_cmd+0x47/0x2c0 [target_core_mod] target_complete_cmd_with_length+0x70/0xa0 [target_core_mod] pscsi_req_done+0x335/0x530 [target_core_pscsi] __blk_mq_end_request+0xa5/0x140 scsi_end_request+0x112/0x320 [scsi_mod] scsi_io_completion+0x183/0xa30 [scsi_mod] scsi_finish_command+0x1c0/0x280 [scsi_mod] scsi_softirq_done+0x19a/0x230 [scsi_mod] __blk_mq_complete_request_remote+0x2f/0x40 flush_smp_call_function_queue+0x12a/0x220 generic_smp_call_function_single_interrupt+0x13/0x30 smp_call_function_single_interrupt+0x7a/0x350 call_function_single_interrupt+0xf/0x20 RIP: 0010:__asan_load4+0x1e/0x80 debug_lockdep_rcu_enabled+0x26/0x40 ip6_finish_output2+0x15a/0xe40 [ipv6] ip6_finish_output+0x308/0x440 [ipv6] ip6_output+0x11d/0x3b0 [ipv6] ip6_xmit+0x639/0xc50 [ipv6] inet6_csk_xmit+0x198/0x2e0 [ipv6] __tcp_transmit_skb+0xc1b/0x15b0 tcp_write_xmit+0x42e/0x1f20 __tcp_push_pending_frames+0x59/0x150 tcp_push+0x189/0x270 tcp_sendmsg_locked+0x7b9/0x1680 tcp_sendmsg+0x2c/0x50 inet_sendmsg+0x71/0x250 sock_sendmsg+0x4c/0x60 tx_data+0x12b/0x1f0 [iscsi_target_mod] iscsit_send_tx_data+0x77/0xe0 [iscsi_target_mod] iscsit_xmit_pdu+0x2c5/0x740 [iscsi_target_mod] iscsit_response_queue+0x941/0xd40 [iscsi_target_mod] iscsi_target_tx_thread+0x23b/0x350 [iscsi_target_mod] kthread+0x1cf/0x1f0 ret_from_fork+0x24/0x30 Fixes: 064cdd2d91c2 ("target: Fix race between iscsi-target connection shutdown + ABORT_TASK") Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/target/iscsi') diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 7059ffdb0c20..408d77eb717c 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4038,9 +4038,9 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) struct se_cmd *se_cmd = &cmd->se_cmd; if (se_cmd->se_tfo != NULL) { - spin_lock(&se_cmd->t_state_lock); + spin_lock_irq(&se_cmd->t_state_lock); se_cmd->transport_state |= CMD_T_FABRIC_STOP; - spin_unlock(&se_cmd->t_state_lock); + spin_unlock_irq(&se_cmd->t_state_lock); } } spin_unlock_bh(&conn->cmd_lock); -- cgit 1.4.1 From 658c31224de24ec0e00987b7d0c93128f455331f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 25 Jan 2019 10:34:57 -0800 Subject: scsi: target/iscsi: Simplify iscsit_dump_data_payload() Use a single loop to dump immediate data, padding and digest instead of using separate rx_data() calls for each type of data. Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target_erl1.c | 41 +++++++------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) (limited to 'drivers/target/iscsi') diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index c27335c29640..e02e1aaf63c5 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -48,14 +48,20 @@ int iscsit_dump_data_payload( u32 buf_len, int dump_padding_digest) { - char *buf, pad_bytes[4]; + char *buf; int ret = DATAOUT_WITHIN_COMMAND_RECOVERY, rx_got; - u32 length, padding, offset = 0, size; + u32 length, offset = 0, size; struct kvec iov; if (conn->sess->sess_ops->RDMAExtensions) return 0; + if (dump_padding_digest) { + buf_len = ALIGN(buf_len, 4); + if (conn->conn_ops->DataDigest) + buf_len += ISCSI_CRC_LEN; + } + length = min(buf_len, OFFLOAD_BUF_SIZE); buf = kzalloc(length, GFP_ATOMIC); @@ -75,41 +81,12 @@ int iscsit_dump_data_payload( rx_got = rx_data(conn, &iov, 1, size); if (rx_got != size) { ret = DATAOUT_CANNOT_RECOVER; - goto out; + break; } offset += size; } - if (!dump_padding_digest) - goto out; - - padding = ((-buf_len) & 3); - if (padding != 0) { - iov.iov_len = padding; - iov.iov_base = pad_bytes; - - rx_got = rx_data(conn, &iov, 1, padding); - if (rx_got != padding) { - ret = DATAOUT_CANNOT_RECOVER; - goto out; - } - } - - if (conn->conn_ops->DataDigest) { - u32 data_crc; - - iov.iov_len = ISCSI_CRC_LEN; - iov.iov_base = &data_crc; - - rx_got = rx_data(conn, &iov, 1, ISCSI_CRC_LEN); - if (rx_got != ISCSI_CRC_LEN) { - ret = DATAOUT_CANNOT_RECOVER; - goto out; - } - } - -out: kfree(buf); return ret; } -- cgit 1.4.1 From 47eefded1f70c1b6c77bee18bd1bf5d17642dcb9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 25 Jan 2019 10:34:58 -0800 Subject: scsi: target/iscsi: Simplify iscsit_handle_text_cmd() Treat text_in and padding as a single buffer instead of two buffers. Cc: Nicholas Bellinger Cc: Mike Christie Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'drivers/target/iscsi') diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 408d77eb717c..e14ac29209c8 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -2240,28 +2240,25 @@ iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, rx_size = payload_length; if (payload_length) { u32 checksum = 0, data_crc = 0; - u32 padding = 0, pad_bytes = 0; + u32 padding = 0; int niov = 0, rx_got; - struct kvec iov[3]; + struct kvec iov[2]; - text_in = kzalloc(payload_length, GFP_KERNEL); + rx_size = ALIGN(payload_length, 4); + text_in = kzalloc(rx_size, GFP_KERNEL); if (!text_in) goto reject; cmd->text_in_ptr = text_in; - memset(iov, 0, 3 * sizeof(struct kvec)); + memset(iov, 0, sizeof(iov)); iov[niov].iov_base = text_in; - iov[niov++].iov_len = payload_length; + iov[niov++].iov_len = rx_size; - padding = ((-payload_length) & 3); - if (padding != 0) { - iov[niov].iov_base = &pad_bytes; - iov[niov++].iov_len = padding; - rx_size += padding; + padding = rx_size - payload_length; + if (padding) pr_debug("Receiving %u additional bytes" " for padding.\n", padding); - } if (conn->conn_ops->DataDigest) { iov[niov].iov_base = &checksum; iov[niov++].iov_len = ISCSI_CRC_LEN; @@ -2273,9 +2270,9 @@ iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, goto reject; if (conn->conn_ops->DataDigest) { - iscsit_do_crypto_hash_buf(conn->conn_rx_hash, text_in, - payload_length, padding, - &pad_bytes, &data_crc); + iscsit_do_crypto_hash_buf(conn->conn_rx_hash, + text_in, rx_size, 0, NULL, + &data_crc); if (checksum != data_crc) { pr_err("Text data CRC32C DataDigest" -- cgit 1.4.1