Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1308151

Re: [PATCH-v2 4/4] target: Obtain se_node_acl->acl_kref during get_initiator_node_acl

From Christoph Hellwig <hch@lst.de>
Newsgroups linux.kernel
Subject Re: [PATCH-v2 4/4] target: Obtain se_node_acl->acl_kref during get_initiator_node_acl
Date 2016-01-13 09:20 +0100
Message-ID <qQoOS-5ih-15@gated-at.bofh.it> (permalink)
References <qPuWm-F7-17@gated-at.bofh.it> <qPuWm-F7-23@gated-at.bofh.it> <qQ8K6-2Id-13@gated-at.bofh.it> <qQoFc-5eg-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Jan 13, 2016 at 12:00:28AM -0800, Nicholas A. Bellinger wrote:
> diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
> index 52ae8ba..62f02ea 100644
> --- a/drivers/target/target_core_tpg.c
> +++ b/drivers/target/target_core_tpg.c
> @@ -75,16 +75,9 @@ struct se_node_acl *core_tpg_get_initiator_node_acl(
>         unsigned char *initiatorname)
>  {
>         struct se_node_acl *acl;
> -       /*
> -        * Obtain the acl_kref now, which will be dropped upon the
> -        * release of se_sess memory within transport_free_session().
> -        */
> +
>         mutex_lock(&tpg->acl_node_mutex);
>         acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname);
> -       if (acl) {
> -               if (!kref_get_unless_zero(&acl->acl_kref))
> -                       acl = NULL;
> -       }

nah, please keep the kref_get_unless_zero here, it's needed.  It's
just the misleding comment I was complaining about :)

> @@ -3435,10 +3436,14 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
>  
>                         if ((tpg->tpg_attrib.generate_node_acls == 0) &&
>                             (tpg->tpg_attrib.demo_mode_discovery == 0) &&
> -                           (!core_tpg_get_initiator_node_acl(&tpg->tpg_se_tpg,
> -                               cmd->conn->sess->sess_ops->InitiatorName))) {
> +                           (!(se_acl = core_tpg_get_initiator_node_acl(&tpg->tpg_se_tpg,
> +                               cmd->conn->sess->sess_ops->InitiatorName)))) {
>                                 continue;
>                         }
> +                       if (se_acl) {
> +                               target_put_nacl(se_acl);
> +                               se_acl = NULL;
> +                       }


Seems like with the current code we don't need to keep the ACL,
so a new helper like:

bool target_tpg_has_node_acl(struct se_portal_group *tpg,
	const char *initiatorname)
{
	struct se_node_acl *acl;

	acl = core_tpg_get_initiator_node_acl(tpg, initiatorname);
	if (acl) {
		target_put_nacl(se_acl);
		return true;
	}

	return false;
}

or fully open coded as:

bool target_tpg_has_node_acl(struct se_portal_group *tpg,
		 const char *initiatorname)
{
	struct se_node_acl *acl;
	bool found = false;

	mutex_lock(&tpg->acl_node_mutex);
	list_for_each_entry(acl, &tpg->acl_node_list, acl_list) {
		if (!strcmp(acl->initiatorname, initiatorname)) {
			found = true;
			break;
		}
	}
	mutex_unlock(&tpg->acl_node_mutex);

	return found;
}

might be better to keep the code readable.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH-v2 0/4] target: Close se_node_acl lookup race "Nicholas A. Bellinger" <nab@daterainc.com> - 2016-01-10 21:40 +0100
  [PATCH-v2 4/4] target: Obtain se_node_acl->acl_kref during get_initiator_node_acl "Nicholas A. Bellinger" <nab@daterainc.com> - 2016-01-10 21:40 +0100
    Re: [PATCH-v2 4/4] target: Obtain se_node_acl->acl_kref during  get_initiator_node_acl Christoph Hellwig <hch@lst.de> - 2016-01-12 16:10 +0100
      Re: [PATCH-v2 4/4] target: Obtain se_node_acl->acl_kref during  get_initiator_node_acl "Nicholas A. Bellinger" <nab@linux-iscsi.org> - 2016-01-13 09:10 +0100
        Re: [PATCH-v2 4/4] target: Obtain se_node_acl->acl_kref during  get_initiator_node_acl Christoph Hellwig <hch@lst.de> - 2016-01-13 09:20 +0100
          Re: [PATCH-v2 4/4] target: Obtain se_node_acl->acl_kref during  get_initiator_node_acl "Nicholas A. Bellinger" <nab@linux-iscsi.org> - 2016-01-13 09:40 +0100
            Re: [PATCH-v2 4/4] target: Obtain se_node_acl->acl_kref during  get_initiator_node_acl Christoph Hellwig <hch@lst.de> - 2016-01-13 09:50 +0100
  [PATCH-v2 1/4] tcm_fc: Convert acl lookup to modern get_initiator_node_acl usage "Nicholas A. Bellinger" <nab@daterainc.com> - 2016-01-10 21:40 +0100
    Re: [PATCH-v2 1/4] tcm_fc: Convert acl lookup to modern  get_initiator_node_acl usage Christoph Hellwig <hch@lst.de> - 2016-01-12 16:10 +0100
      Re: [PATCH-v2 1/4] tcm_fc: Convert acl lookup to modern  get_initiator_node_acl usage "Nicholas A. Bellinger" <nab@linux-iscsi.org> - 2016-01-13 08:20 +0100
  [PATCH-v2 3/4] target: Fix change depth se_session reference usage "Nicholas A. Bellinger" <nab@daterainc.com> - 2016-01-10 21:40 +0100
    Re: [PATCH-v2 3/4] target: Fix change depth se_session reference  usage Christoph Hellwig <hch@lst.de> - 2016-01-12 16:10 +0100
      Re: [PATCH-v2 3/4] target: Fix change depth se_session reference  usage "Nicholas A. Bellinger" <nab@linux-iscsi.org> - 2016-01-13 08:40 +0100
        Re: [PATCH-v2 3/4] target: Fix change depth se_session reference  usage Christoph Hellwig <hch@lst.de> - 2016-01-13 09:30 +0100
          Re: [PATCH-v2 3/4] target: Fix change depth se_session reference  usage "Nicholas A. Bellinger" <nab@linux-iscsi.org> - 2016-01-13 10:00 +0100
    Re: [PATCH-v2 3/4] target: Fix change depth se_session reference  usage Christoph Hellwig <hch@lst.de> - 2016-01-13 09:30 +0100
      Re: [PATCH-v2 3/4] target: Fix change depth se_session reference  usage "Nicholas A. Bellinger" <nab@linux-iscsi.org> - 2016-01-13 10:00 +0100
    Re: [PATCH-v2 3/4] target: Fix change depth se_session reference  usage Sagi Grimberg <sagig@dev.mellanox.co.il> - 2016-01-13 17:50 +0100
  [PATCH-v2 2/4] ib_srpt: Convert acl lookup to modern get_initiator_node_acl usage "Nicholas A. Bellinger" <nab@daterainc.com> - 2016-01-10 21:40 +0100
    Re: [PATCH-v2 2/4] ib_srpt: Convert acl lookup to modern  get_initiator_node_acl usage Sagi Grimberg <sagig@dev.mellanox.co.il> - 2016-01-13 17:40 +0100

csiph-web