All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@logfs.org>
To: Roland Dreier <roland@purestorage.com>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	target-devel@vger.kernel.org, Arun Easi <arun.easi@qlogic.com>,
	linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] qla_target: Check refcount in find_sess_by_*
Date: Thu, 17 May 2012 15:28:30 -0400	[thread overview]
Message-ID: <20120517192830.GC18067@logfs.org> (raw)
In-Reply-To: <CAL1RGDUmT4xOQQkAE5eq-XXZa5b64SeTZjfcWdeuMiUu=DRarg@mail.gmail.com>

On Thu, 17 May 2012 13:49:38 -0700, Roland Dreier wrote:
> 
> > Mmmmm, I'd still like to try to avoid (another) atomic op in the fast
> > path w/ hardware_lock held if at all possible..
> 
> atomic_read() is not an atomic op.

Or more importantly it doesn't force the cacheline out of shared mode,
which is the performance killer to avoid.

> > Also thinking more about the case in your comment, I'm starting to
> > wonder if tcm_qla2xxx_free_session() should be obtaining hardware_lock +
> > clearing the s_id and loop_id lookup entries earlier than currently
> > done..
> >
> > That is, target_wait_for_sess_cmds() is called before clearing the
> > nodeacl pointers from s_id + loop_id in tcm_qla2xxx_free_session(),
> > which means that we still perform se_node_acl lookups in the case where
> > the individual tcm_qla2xxx endpoint was not also being shutdown as
> > well..
> >
> > So that said, I think your work-around is OK to address the current BUG,
> > but the s_id + loop_id clearing order in tcm_qla2xxx_free_session()
> > would be having an effect here as well..
> 
> Yes, in fact we need to clear the session from all lookup tables
> even earlier than ->free_session.  We need to make sure that as
> soon as target_release_session() is called, that session will no
> longer be used for any new commands.
> 
> So qla_tgt_unreg_sess() needs to clear the session from the
> "by loop_id" table as well as the "by fc_id" table.

Not even that is sufficient.  We need to atomically drop the refcount
and remove the session from all lookup tables.  Call stack is:

tcm_qla2xxx_free_session  <-- removes from lookup tables
qla_tgt_free_session_done
---                       <-- move to workqueue, dropping hardware_lock
qla_tgt_unreg_sess
tcm_qla2xxx_close_session <-- takes hardware_lock
target_release_session
target_put_session        <-- drops refcount

Since the lookup tables are protected by hardware_lock, we would have
to either take the hardware_lock _before_ dropping the reference count
or do atomic_dec_and_lock().  Both of which requires knowledge about
the qla2xxx hardware_lock in generic target code.

Jörn

--
Tough times don't last, but tough people do.
-- Nigerian proverb

  reply	other threads:[~2012-05-17 19:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120511143341.GA18753@logfs.org>
     [not found] ` <20120517162600.GA18067@logfs.org>
2012-05-17 19:46   ` [PATCH] qla_target: Check refcount in find_sess_by_* Nicholas A. Bellinger
2012-05-17 20:49     ` Roland Dreier
2012-05-17 19:28       ` Jörn Engel [this message]
2012-05-17 21:05         ` Jörn Engel
2012-05-17 21:10           ` Jörn Engel
2012-05-18  2:02           ` Nicholas A. Bellinger
2012-05-18  1:15             ` Jörn Engel
2012-05-18  6:09               ` Nicholas A. Bellinger
2012-05-18 22:49                 ` Jörn Engel
2012-05-19  1:26                   ` Nicholas A. Bellinger
2012-05-21 22:18                     ` Nicholas A. Bellinger
2012-05-17 21:24       ` Nicholas A. Bellinger
2012-05-17 19:56         ` Jörn Engel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120517192830.GC18067@logfs.org \
    --to=joern@logfs.org \
    --cc=arun.easi@qlogic.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=roland@purestorage.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.