From 391ae476909396200c450906592939a432b36432 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 25 Nov 2012 08:12:26 +0000 Subject: [PATCH] Increment session refcount in scst_pre_rx_mgmt_cmd() instead of scst_post_rx_mgmt_cmd() (merge r4423 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@4626 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla_os.c | 2 +- scst/src/scst_targ.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index d75c23fb1..53e304560 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -1768,7 +1768,7 @@ size_t qla2xxx_del_vtarget(u64 *port_name) /* We only allow support on Channel 0 !!! */ list_for_each_entry(vport, &fc_host->vports, peers) { if ((vport->channel == 0) && - (vport->port_name == *port_name)) { + (vport->port_name == *port_name)) { match = 1; break; } diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 77b22414d..5852ea60e 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -209,6 +209,8 @@ struct scst_cmd *scst_rx_cmd(struct scst_session *sess, goto out; cmd->sess = sess; + scst_sess_get(sess); + cmd->tgt = sess->tgt; cmd->tgtt = sess->tgt->tgtt; @@ -218,7 +220,6 @@ struct scst_cmd *scst_rx_cmd(struct scst_session *sess, SCST_LOAD_SENSE(scst_sense_lun_not_supported)); TRACE_DBG("cmd %p, sess %p", cmd, sess); - scst_sess_get(sess); out: TRACE_EXIT(); @@ -5947,6 +5948,10 @@ static struct scst_mgmt_cmd *scst_pre_rx_mgmt_cmd(struct scst_session } mcmd->sess = sess; + scst_sess_get(sess); + + atomic_inc(&sess->sess_cmd_count); + mcmd->fn = fn; mcmd->state = SCST_MCMD_STATE_INIT; mcmd->tgt_priv = tgt_priv; @@ -5969,8 +5974,6 @@ static int scst_post_rx_mgmt_cmd(struct scst_session *sess, TRACE_ENTRY(); - scst_sess_get(sess); - if (unlikely(sess->shut_phase != SCST_SESS_SPH_READY)) { PRINT_CRIT_ERROR("New mgmt cmd while shutting down the " "session %p shut_phase %ld", sess, sess->shut_phase); @@ -5980,7 +5983,6 @@ static int scst_post_rx_mgmt_cmd(struct scst_session *sess, local_irq_save(flags); spin_lock(&sess->sess_list_lock); - atomic_inc(&sess->sess_cmd_count); if (unlikely(sess->init_phase != SCST_SESS_IPH_READY)) { switch (sess->init_phase) {