From: Christoph Hellwig <hch@infradead.org>
To: "Nicholas A. Bellinger" <nab@daterainc.com>
Cc: 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>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagig@mellanox.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Nicholas Bellinger <nab@linux-iscsi.org>
Subject: Re: [PATCH-v2 1/9] target: Convert se_node_acl->device_list[] to RCU hlist
Date: Fri, 22 May 2015 01:24:11 -0700 [thread overview]
Message-ID: <20150522082411.GB5384@infradead.org> (raw)
In-Reply-To: <1432275071-28882-2-git-send-email-nab@daterainc.com>
> - spin_lock_irqsave(&se_sess->se_node_acl->device_list_lock, flags);
> - se_cmd->se_deve = se_sess->se_node_acl->device_list[unpacked_lun];
> - if (se_cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
> - struct se_dev_entry *deve = se_cmd->se_deve;
> -
> + rcu_read_lock();
> + deve = target_nacl_find_deve(nacl, unpacked_lun);
> + if (deve) {
> deve->total_cmds++;
This update will now be racy, ditto for the read/write_bytes update
later.
> +bool target_lun_is_rdonly(struct se_cmd *cmd)
> +{
> + struct se_session *se_sess = cmd->se_sess;
> + struct se_dev_entry *deve;
> + bool ret;
> +
> + if (cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY)
> + return true;
> +
> + rcu_read_lock();
> + deve = target_nacl_find_deve(se_sess->se_node_acl, cmd->orig_fe_lun);
> + ret = (deve && deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY);
> + rcu_read_unlock();
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(target_lun_is_rdonly);
This should be a separate prep patch like, like it was in my original
version. I also still think you want this whole patch:
http://git.infradead.org/users/hch/scsi.git/commitdiff/e9a71bda1a120e0488c5c4e4b2f17f14333e2dc6
as storing a pointer to the dev entry without a refcount is bound to
cause trouble. I don't have a tree with all the patches applied
available, but I doubt it fully gets that right.
> +void target_pr_kref_release(struct kref *kref)
> +{
> + struct se_dev_entry *deve = container_of(kref, struct se_dev_entry,
> + pr_kref);
> + complete(&deve->pr_comp);
> }
>
> /* core_enable_device_list_for_node():
> + kref_put(&orig->pr_kref, target_pr_kref_release);
> + wait_for_completion(&orig->pr_comp);
>
> + kref_put(&orig->pr_kref, target_pr_kref_release);
> /*
> - * Disable struct se_dev_entry LUN ACL mapping
> + * Before fireing off RCU callback, wait for any in process SPEC_I_PT=1
> + * or REGISTER_AND_MOVE PR operation to complete.
> */
> + wait_for_completion(&orig->pr_comp);
> + kfree_rcu(orig, rcu_head);
The release callback should just call kfree_rcu, no need to wait for the
release in the caller.
Also can you drop the _pr from the name? It's a generic refcount now
even if the PR code is the only consumer so far.
> +void target_pr_kref_release(struct kref *);
Instead of exporting the release function it would be much more obvious
to have a
void target_deve_put(struct se_dev_entry *deve)
{
kref_put(&deve->pr_kref, target_deve_release);
}
helper. Probably paired with one for the get side.
> static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve)
> {
> - struct se_lun_acl *lun_acl = se_deve->se_lun_acl;
> + struct se_lun_acl *lun_acl;
> struct se_node_acl *nacl;
> struct se_portal_group *tpg;
> +
> + if (!se_deve) {
> + pr_err("core_scsi3_lunacl_undepend_item passed NULL se_deve\n");
> + dump_stack();
> + return;
> + }
How could this happen and how is it related to this patch?
> - if (!deve->se_lun || !deve->se_lun_acl) {
> - spin_unlock_irq(&nacl->device_list_lock);
> + rcu_read_lock();
> + deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
> + if (!deve) {
> + rcu_read_unlock();
> return -ENODEV;
So previously a lot of these files returned -ENODEV when not having
an explicit node ACL, and now they don't. If that was intentional
it should be documented in the changelog, or preferably moved into
a preparation patch of its own.
> + struct se_node_acl *se_node_acl;
Where is this field coming from? It's not documented in the changelog
and doesn't seem to be actually used either.
next prev parent reply other threads:[~2015-05-22 8:24 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 [this message]
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
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=20150522082411.GB5384@infradead.org \
--to=hch@infradead.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=nab@linux-iscsi.org \
--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