diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index 5c580936c..9c2dc0a4b 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -398,6 +398,10 @@ static int add_session(void __user *ptr) TRACE_ENTRY(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target_mgmt_mutex); +#endif + info = kzalloc(sizeof(*info), GFP_KERNEL); if (info == NULL) { PRINT_ERROR("Can't alloc info (size %zd)", sizeof(*info)); diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index 2dd303495..ffedc9b57 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -92,6 +92,10 @@ void conn_info_show(struct seq_file *seq, struct iscsi_session *session) struct sock *sk; char buf[64]; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target->target_mutex); +#endif + list_for_each_entry(conn, &session->conn_list, conn_list_entry) { sk = conn->sock->sk; switch (sk->sk_family) { @@ -271,6 +275,10 @@ static int conn_sysfs_add(struct iscsi_conn *conn) TRACE_ENTRY(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&conn->target->target_mutex); +#endif + iscsi_get_initiator_ip(conn, addr, sizeof(addr)); restart: @@ -339,6 +347,10 @@ struct iscsi_conn *conn_lookup(struct iscsi_session *session, u16 cid) { struct iscsi_conn *conn; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&session->target->target_mutex); +#endif + /* * We need to find the latest conn to correctly handle * multi-reinstatements @@ -806,6 +818,10 @@ int conn_free(struct iscsi_conn *conn) TRACE_MGMT_DBG("Freeing conn %p (sess=%p, %#Lx %u)", conn, session, (long long unsigned int)session->sid, conn->cid); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&conn->target->target_mutex); +#endif + del_timer_sync(&conn->rsp_timer); #ifndef CONFIG_SCST_PROC @@ -857,6 +873,10 @@ static int iscsi_conn_alloc(struct iscsi_session *session, struct iscsi_conn *conn; int res = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&session->target->target_mutex); +#endif + conn = kmem_cache_zalloc(iscsi_conn_cache, GFP_KERNEL); if (!conn) { res = -ENOMEM; @@ -961,6 +981,10 @@ int __add_conn(struct iscsi_session *session, struct iscsi_kern_conn_info *info) int err; bool reinstatement = false; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&session->target->target_mutex); +#endif + conn = conn_lookup(session, info->cid); if ((conn != NULL) && !test_bit(ISCSI_CONN_SHUTTINGDOWN, &conn->conn_aflags)) { diff --git a/iscsi-scst/kernel/param.c b/iscsi-scst/kernel/param.c index 10d8d844d..aaa476010 100644 --- a/iscsi-scst/kernel/param.c +++ b/iscsi-scst/kernel/param.c @@ -242,6 +242,10 @@ static int iscsi_tgt_params_set(struct iscsi_session *session, struct iscsi_tgt_params *params = &session->tgt_params; int32_t *iparams = info->target_params; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&session->target->target_mutex); +#endif + if (set) { struct iscsi_conn *conn; @@ -308,6 +312,10 @@ int iscsi_params_set(struct iscsi_target *target, int err; struct iscsi_session *session; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target->target_mutex); +#endif + if (info->sid == 0) { PRINT_ERROR("sid must not be %d", 0); err = -EINVAL; diff --git a/iscsi-scst/kernel/session.c b/iscsi-scst/kernel/session.c index 0ddf38a91..03ddb858e 100644 --- a/iscsi-scst/kernel/session.c +++ b/iscsi-scst/kernel/session.c @@ -26,6 +26,10 @@ struct iscsi_session *session_lookup(struct iscsi_target *target, u64 sid) { struct iscsi_session *session; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target->target_mutex); +#endif + list_for_each_entry(session, &target->session_list, session_list_entry) { if (session->sid == sid) @@ -43,6 +47,10 @@ static int iscsi_session_alloc(struct iscsi_target *target, struct iscsi_session *session; char *name = NULL; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target_mgmt_mutex); +#endif + session = kmem_cache_zalloc(iscsi_sess_cache, GFP_KERNEL); if (!session) return -ENOMEM; @@ -131,6 +139,10 @@ void sess_reinst_finished(struct iscsi_session *sess) TRACE_MGMT_DBG("Enabling reinstate successor sess %p", sess); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&sess->target->target_mutex); +#endif + sBUG_ON(!sess->sess_reinstating); list_for_each_entry(c, &sess->conn_list, conn_list_entry) { @@ -154,6 +166,10 @@ int __add_session(struct iscsi_target *target, TRACE_MGMT_DBG("Adding session SID %llx", info->sid); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target_mgmt_mutex); +#endif + err = iscsi_session_alloc(target, info, &new_sess); if (err != 0) goto out; @@ -303,6 +319,10 @@ int session_free(struct iscsi_session *session, bool del) TRACE_MGMT_DBG("Freeing session %p (SID %llx)", session, session->sid); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&session->target->target_mutex); +#endif + sBUG_ON(!list_empty(&session->conn_list)); if (unlikely(atomic_read(&session->active_cmds) != 0)) { PRINT_CRIT_ERROR("active_cmds not 0 (%d)!!", @@ -357,6 +377,10 @@ int __del_session(struct iscsi_target *target, u64 sid) { struct iscsi_session *session; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target->target_mutex); +#endif + session = session_lookup(target, sid); if (!session) return -ENOENT; @@ -377,6 +401,10 @@ void iscsi_sess_force_close(struct iscsi_session *sess) TRACE_ENTRY(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&sess->target->target_mutex); +#endif + PRINT_INFO("Deleting session %llx with initiator %s (%p)", (long long unsigned int)sess->sid, sess->initiator_name, sess); @@ -397,6 +425,10 @@ static void iscsi_session_info_show(struct seq_file *seq, { struct iscsi_session *session; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target->target_mutex); +#endif + list_for_each_entry(session, &target->session_list, session_list_entry) { seq_printf(seq, "\tsid:%llx initiator:%s (reinstating %s)\n", diff --git a/iscsi-scst/kernel/target.c b/iscsi-scst/kernel/target.c index bad7c1444..848c4c981 100644 --- a/iscsi-scst/kernel/target.c +++ b/iscsi-scst/kernel/target.c @@ -35,6 +35,10 @@ struct iscsi_target *target_lookup_by_id(u32 id) { struct iscsi_target *target; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target_mgmt_mutex); +#endif + list_for_each_entry(target, &target_list, target_list_entry) { if (target->tid == id) return target; @@ -47,6 +51,10 @@ static struct iscsi_target *target_lookup_by_name(const char *name) { struct iscsi_target *target; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target_mgmt_mutex); +#endif + list_for_each_entry(target, &target_list, target_list_entry) { if (!strcmp(target->name, name)) return target; @@ -64,6 +72,10 @@ static int iscsi_target_create(struct iscsi_kern_target_info *info, u32 tid, TRACE_MGMT_DBG("Creating target tid %u, name %s", tid, name); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target_mgmt_mutex); +#endif + len = strlen(name); if (!len) { PRINT_ERROR("The length of the target name is zero %u", tid); @@ -133,6 +145,10 @@ int __add_target(struct iscsi_kern_target_info *info) struct iscsi_kern_attr __user *attrs_ptr; #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target_mgmt_mutex); +#endif + if (nr_targets > MAX_NR_TARGETS) { err = -EBUSY; goto out; @@ -247,6 +263,10 @@ int __del_target(u32 id) struct iscsi_target *target; int err; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target_mgmt_mutex); +#endif + target = target_lookup_by_id(id); if (!target) { err = -ENOENT; @@ -283,6 +303,10 @@ void target_del_session(struct iscsi_target *target, TRACE_MGMT_DBG("Deleting session %p", session); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target->target_mutex); +#endif + if (!list_empty(&session->conn_list)) { struct iscsi_conn *conn, *tc; list_for_each_entry_safe(conn, tc, &session->conn_list, @@ -307,6 +331,10 @@ void target_del_all_sess(struct iscsi_target *target, int flags) TRACE_ENTRY(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&target->target_mutex); +#endif + if (!list_empty(&target->session_list)) { TRACE_MGMT_DBG("Deleting all sessions from target %p", target); list_for_each_entry_safe(session, ts, &target->session_list,