From patchwork Fri Jun 23 09:10:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9806023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D5FBE60349 for ; Fri, 23 Jun 2017 09:10:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C811128583 for ; Fri, 23 Jun 2017 09:10:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCB4028630; Fri, 23 Jun 2017 09:10:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B85628583 for ; Fri, 23 Jun 2017 09:10:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754409AbdFWJK3 (ORCPT ); Fri, 23 Jun 2017 05:10:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47558 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754377AbdFWJK2 (ORCPT ); Fri, 23 Jun 2017 05:10:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FF287D4E0; Fri, 23 Jun 2017 09:10:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FF287D4E0 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mchristi@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9FF287D4E0 Received: from rh2.redhat.com (ovpn-120-27.rdu2.redhat.com [10.10.120.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id EED3818C69; Fri, 23 Jun 2017 09:10:21 +0000 (UTC) From: Mike Christie To: bart.vanassche@wdc.com, target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [RFC PATCH 3/4] target: use ida for acl index Date: Fri, 23 Jun 2017 04:10:16 -0500 Message-Id: <1498209017-25110-4-git-send-email-mchristi@redhat.com> In-Reply-To: <1498209017-25110-1-git-send-email-mchristi@redhat.com> References: <1498209017-25110-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 23 Jun 2017 09:10:22 +0000 (UTC) Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This just uses a ida for the acl index, so we avoid collisions if we ever rollover. Signed-off-by: Mike Christie --- drivers/target/target_core_tpg.c | 13 ++++++++++++- include/target/target_core_base.h | 1 - 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 1b2b60e..61d3f2b 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -47,6 +47,7 @@ extern struct se_device *g_lun0_dev; static DEFINE_SPINLOCK(tpg_lock); static LIST_HEAD(tpg_list); +static DEFINE_IDA(acl_index_ida); /* __core_tpg_get_initiator_node_acl(): * @@ -187,12 +188,18 @@ static struct se_node_acl *target_alloc_node_acl(struct se_portal_group *tpg, { struct se_node_acl *acl; u32 queue_depth; + int ret; acl = kzalloc(max(sizeof(*acl), tpg->se_tpg_tfo->node_acl_size), GFP_KERNEL); if (!acl) return NULL; + ret = ida_simple_get_cyclic(&acl_index_ida, 0, 0, GFP_KERNEL); + if (ret < 0) + goto free_acl; + acl->acl_index = ret; + INIT_LIST_HEAD(&acl->acl_list); INIT_LIST_HEAD(&acl->acl_sess_list); INIT_HLIST_HEAD(&acl->lun_entry_hlist); @@ -210,11 +217,14 @@ static struct se_node_acl *target_alloc_node_acl(struct se_portal_group *tpg, snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); acl->se_tpg = tpg; - acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); tpg->se_tpg_tfo->set_default_node_attributes(acl); return acl; + +free_acl: + kfree(acl); + return NULL; } static void target_add_node_acl(struct se_node_acl *acl) @@ -382,6 +392,7 @@ void core_tpg_del_initiator_node_acl(struct se_node_acl *acl) core_tpg_wait_for_nacl_pr_ref(acl); core_free_device_list_for_node(acl, tpg); + ida_simple_remove(&acl_index_ida, acl->acl_index); pr_debug("%s_TPG[%hu] - Deleted ACL with TCQ Depth: %d for %s" " Initiator Node: %s\n", tpg->se_tpg_tfo->get_fabric_name(), diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 19ec189..d275a39 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -219,7 +219,6 @@ enum tcm_tmrsp_table { */ typedef enum { SCSI_INST_INDEX, - SCSI_AUTH_INTR_INDEX, SCSI_INDEX_TYPE_MAX } scsi_index_t;