From cdb13cfc5feaf89f627f3b40ae3b0aeff577c925 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 8 Aug 2012 18:00:51 +0000 Subject: [PATCH] Cleanups git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4456 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla_def.h | 10 +++++++--- scst/include/scst.h | 4 ++-- scst/src/scst_lib.c | 8 +++++--- scst/src/scst_priv.h | 2 +- scst/src/scst_sysfs.c | 2 +- scst/src/scst_targ.c | 7 ++++--- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/qla2x00t/qla_def.h b/qla2x00t/qla_def.h index c7ccd6faf..53246d453 100644 --- a/qla2x00t/qla_def.h +++ b/qla2x00t/qla_def.h @@ -2427,8 +2427,9 @@ typedef struct scsi_qla_host { uint16_t atio_q_length; /* - * Protected by tgt_mutex AND hardware_lock for writing and - * tgt_mutex OR hardware_lock for reading. + * Processing Q2T tgt reference. NULL on not enabled targets. Protected + * by tgt_mutex AND hardware_lock for writing and tgt_mutex OR + * hardware_lock for reading. */ struct q2t_tgt *tgt; @@ -2701,7 +2702,10 @@ typedef struct scsi_qla_host { struct mutex tgt_host_action_mutex; - /* Protected by tgt_host_action_mutex */ + /* + * Main Q2T tgt reference, which always points to the target, if the + * target mode addon loaded. Protected by tgt_host_action_mutex. + */ struct q2t_tgt *q2t_tgt; struct list_head ha_list_entry; diff --git a/scst/include/scst.h b/scst/include/scst.h index c848e99e6..8d30b43e6 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1662,8 +1662,8 @@ struct scst_session { /* Name of attached initiator */ const char *initiator_name; - /* Session name: initiator name + optional _%d. */ - const char *name; + /* Unique session name: initiator name + optional _%d. */ + const char *sess_name; /* List entry of sessions per target */ struct list_head sess_list_entry; diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 6fe04b6ba..e62ccf07a 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5086,8 +5086,10 @@ void scst_free_session(struct scst_session *sess) mutex_lock(&scst_mutex); scst_sess_free_tgt_devs(sess); + TRACE_DBG("Removing sess %p from the list", sess); list_del(&sess->sess_list_entry); + TRACE_DBG("Removing session %p from acg %s", sess, sess->acg->acg_name); list_del(&sess->acg_sess_list_entry); @@ -5115,8 +5117,8 @@ void scst_free_session(struct scst_session *sess) kfree(sess->transport_id); kfree(sess->initiator_name); - if (sess->name != sess->initiator_name) - kfree(sess->name); + if (sess->sess_name != sess->initiator_name) + kfree(sess->sess_name); kmem_cache_free(scst_sess_cachep, sess); @@ -8641,7 +8643,7 @@ int scst_parse_descriptors(struct scst_cmd *cmd) break; default: sBUG_ON(1); - res = false; + res = -1; break; } diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 1b360d8ad..af18bbd4d 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -348,7 +348,7 @@ int scst_assign_dev_handler(struct scst_device *dev, struct scst_dev_type *handler); struct scst_session *scst_alloc_session(struct scst_tgt *tgt, gfp_t gfp_mask, - const char *initiator_name); + const char *initiator_name); void scst_free_session(struct scst_session *sess); void scst_free_session_callback(struct scst_session *sess); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 84770fda3..9d49514d7 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -3602,7 +3602,7 @@ int scst_sess_sysfs_create(struct scst_session *sess) TRACE_ENTRY(); - name = sess->name; + name = sess->sess_name; TRACE_DBG("Adding session %s to sysfs", name); res = kobject_init_and_add(&sess->sess_kobj, &scst_session_ktype, diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index f3818ffc8..6f3e187a4 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -6412,6 +6412,7 @@ bool scst_initiator_has_luns(struct scst_tgt *tgt, const char *initiator_name) } EXPORT_SYMBOL_GPL(scst_initiator_has_luns); +/* Supposed to be called under scst_mutex */ static char *scst_get_unique_sess_name(struct list_head *sess_list, const char *initiator_name) { @@ -6426,7 +6427,7 @@ static char *scst_get_unique_sess_name(struct list_head *sess_list, restart: list_for_each_entry(s, sess_list, sess_list_entry) { - if (s->name && strcmp(name, s->name) == 0) { + if (s->sess_name && strcmp(name, s->sess_name) == 0) { TRACE_DBG("Duplicated session from the same initiator " "%s found", name); @@ -6485,9 +6486,9 @@ static int scst_init_session(struct scst_session *sess) } res = -ENOMEM; - sess->name = scst_get_unique_sess_name(&sess->tgt->sess_list, + sess->sess_name = scst_get_unique_sess_name(&sess->tgt->sess_list, sess->initiator_name); - if (!sess->name) + if (!sess->sess_name) goto failed; res = scst_sess_sysfs_create(sess);