From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: Christoph Hellwig <hch@lst.de>
Cc: "Nicholas A. Bellinger" <nab@daterainc.com>,
target-devel <target-devel@vger.kernel.org>,
linux-scsi <linux-scsi@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Hannes Reinecke <hare@suse.de>,
Sagi Grimberg <sagig@mellanox.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry->pr_reg reservation check
Date: Mon, 25 May 2015 15:54:58 -0700 [thread overview]
Message-ID: <1432594498.722.36.camel@haakon3.risingtidesystems.com> (raw)
In-Reply-To: <20150522115203.GA29155@lst.de>
On Fri, 2015-05-22 at 13:52 +0200, Christoph Hellwig wrote:
> >
> > -/*
> > - * this function can be called with struct se_device->dev_reservation_lock
> > - * when register_move = 1
> > - */
> > static void __core_scsi3_add_registration(
> > struct se_device *dev,
> > struct se_node_acl *nacl,
> > @@ -1023,6 +1021,7 @@ static void __core_scsi3_add_registration(
> > const struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
> > struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe;
> > struct t10_reservation *pr_tmpl = &dev->t10_pr;
> > + struct se_dev_entry *deve;
> >
> > /*
> > * Increment PRgeneration counter for struct se_device upon a successful
> > @@ -1039,10 +1038,16 @@ static void __core_scsi3_add_registration(
> >
> > spin_lock(&pr_tmpl->registration_lock);
> > list_add_tail(&pr_reg->pr_reg_list, &pr_tmpl->registration_list);
> > - pr_reg->pr_reg_deve->def_pr_registered = 1;
> >
> > __core_scsi3_dump_registration(tfo, dev, nacl, pr_reg, register_type);
> > spin_unlock(&pr_tmpl->registration_lock);
> > +
> > + mutex_lock(&nacl->lun_entry_mutex);
> > + deve = target_nacl_find_deve(nacl, pr_reg->pr_res_mapped_lun);
> > + if (deve)
> > + set_bit(1, &deve->pr_reg);
> > + mutex_unlock(&nacl->lun_entry_mutex);
>
> Why can't we rely on pr_reg->pr_reg_deve here? The way the it's
> set up is a bit convoluted, but unless I miss something it needs to
> have a reference if it's set (and it it doesn't that needs to be fixed
> ASAP).
>
So pr_reg->pr_reg_deve is only referenced in the context of ALL_TG_PT=1,
I_PORT=1 and REGISTER_AND_MOVE registration, when pr_reg->pr_kref is
already held.
>
> Also even if we would need a target_nacl_find_deve call here it could
> be done under rcu_read_lock as lun_entry_hlist isn't modified.
>
Probably not. Changing these to rcu_read_lock.
> > + mutex_lock(&nacl->lun_entry_mutex);
> > + deve = target_nacl_find_deve(nacl_tmp, pr_reg_tmp->pr_res_mapped_lun);
> > + if (deve)
> > + set_bit(1, &deve->pr_reg);
> > + mutex_unlock(&nacl->lun_entry_mutex);
> > +
>
It should be fine to dereference pr_reg_tmp->pr_reg_deve directly here.
>
> > @@ -1258,6 +1269,8 @@ static void __core_scsi3_free_registration(
> > */
> > if (dec_holders)
> > core_scsi3_put_pr_reg(pr_reg);
> > +
> > + spin_unlock(&pr_tmpl->registration_lock);
> > /*
> > * Wait until all reference from any other I_T nexuses for this
> > * *pr_reg have been released. Because list_del() is called above,
> > @@ -1265,13 +1278,18 @@ static void __core_scsi3_free_registration(
> > * count back to zero, and we release *pr_reg.
> > */
> > while (atomic_read(&pr_reg->pr_res_holders) != 0) {
> > - spin_unlock(&pr_tmpl->registration_lock);
> > pr_debug("SPC-3 PR [%s] waiting for pr_res_holders\n",
> > tfo->get_fabric_name());
> > cpu_relax();
> > - spin_lock(&pr_tmpl->registration_lock);
> > }
> >
> > + mutex_lock(&nacl->lun_entry_mutex);
> > + deve = target_nacl_find_deve(nacl, pr_reg->pr_res_mapped_lun);
> > + if (deve)
> > + clear_bit(1, &deve->pr_reg);
> > + mutex_unlock(&nacl->lun_entry_mutex);
>
> And here.
This is not going to work, because __core_scsi3_free_registration() can
be invoked via core_disable_device_list_for_node() ->
core_scsi3_free_pr_reg_from_nacl(), after the kfree_rcu() for
se_dev_entry has occurred.
So keeping the extra lookup for this one particular case, and dropping
the rest.
next prev parent reply other threads:[~2015-05-25 22:55 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 6:11 [PATCH-v2 0/9] target: se_node_acl + se_lun RCU conversions Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 1/9] target: Convert se_node_acl->device_list[] to RCU hlist Nicholas A. Bellinger
2015-05-22 8:24 ` Christoph Hellwig
2015-05-22 8:55 ` Nicholas A. Bellinger
2015-05-22 11:31 ` Christoph Hellwig
2015-05-25 22:14 ` Nicholas A. Bellinger
2015-05-26 4:11 ` Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry->pr_reg reservation check Nicholas A. Bellinger
2015-05-22 8:26 ` Christoph Hellwig
2015-05-22 9:05 ` Nicholas A. Bellinger
2015-05-22 11:34 ` Christoph Hellwig
2015-05-25 22:25 ` Nicholas A. Bellinger
2015-05-22 10:12 ` Bart Van Assche
2015-05-25 21:59 ` Nicholas A. Bellinger
2015-05-22 11:52 ` Christoph Hellwig
2015-05-25 22:54 ` Nicholas A. Bellinger [this message]
2015-05-22 6:11 ` [PATCH-v2 3/9] target/pr: Change alloc_registration to avoid pr_reg_tg_pt_lun Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 4/9] target/pr: cleanup core_scsi3_pr_seq_non_holder Nicholas A. Bellinger
2015-05-22 8:26 ` Christoph Hellwig
2015-05-22 6:11 ` [PATCH-v2 5/9] target: Convert se_portal_group->tpg_lun_list[] to RCU hlist Nicholas A. Bellinger
2015-05-22 8:31 ` Christoph Hellwig
2015-05-22 8:48 ` Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 6/9] target: Convert se_tpg->acl_node_lock to ->acl_node_mutex Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 7/9] target: Convert core_tpg_deregister to use list splice Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 8/9] target: Drop unused se_lun->lun_acl_list Nicholas A. Bellinger
2015-05-22 6:11 ` [PATCH-v2 9/9] target: Only reset specific dynamic entries during lun_group creation Nicholas A. Bellinger
2015-05-22 6:23 ` [PATCH-v2 0/9] target: se_node_acl + se_lun RCU conversions Hannes Reinecke
2015-05-22 8:07 ` Christoph Hellwig
2015-05-22 8:18 ` Nicholas A. Bellinger
2015-05-22 10:15 ` Bart Van Assche
2015-05-25 22:01 ` Nicholas A. Bellinger
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=1432594498.722.36.camel@haakon3.risingtidesystems.com \
--to=nab@linux-iscsi.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nab@daterainc.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=sagig@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®