From patchwork Wed Jun 21 21:33:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9803001 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 44627600C5 for ; Wed, 21 Jun 2017 21:33:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E8A627FB1 for ; Wed, 21 Jun 2017 21:33:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 234002853C; Wed, 21 Jun 2017 21:33:30 +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 8AADF28111 for ; Wed, 21 Jun 2017 21:33:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751934AbdFUVdV (ORCPT ); Wed, 21 Jun 2017 17:33:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45702 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751798AbdFUVdV (ORCPT ); Wed, 21 Jun 2017 17:33:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8E3680F9D; Wed, 21 Jun 2017 21:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E8E3680F9D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mchristi@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E8E3680F9D Received: from rh2.redhat.com (ovpn-123-144.rdu2.redhat.com [10.10.123.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E8145D961; Wed, 21 Jun 2017 21:33:20 +0000 (UTC) From: Mike Christie To: bryantly@linux.vnet.ibm.com, pkalever@redhat.com, target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [PATCH 08/12] target: remove g_device_list Date: Wed, 21 Jun 2017 16:33:07 -0500 Message-Id: <1498080791-13565-9-git-send-email-mchristi@redhat.com> In-Reply-To: <1498080791-13565-1-git-send-email-mchristi@redhat.com> References: <1498080791-13565-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 21 Jun 2017 21:33:21 +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 g_device_list is no longer needed because we now use the idr code for lookups and seaches. Signed-off-by: Mike Christie Reviewed-by: Bart Van Assche --- drivers/target/target_core_device.c | 30 ++++++++++++------------------ drivers/target/target_core_internal.h | 3 --- include/target/target_core_base.h | 1 - 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 85b526b..4052b22 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -49,8 +49,8 @@ #include "target_core_pr.h" #include "target_core_ua.h" -DEFINE_MUTEX(g_device_mutex); -LIST_HEAD(g_device_list); +DEFINE_MUTEX(device_mutex); +LIST_HEAD(device_list); DEFINE_IDR(devices_idr); static struct se_hba *lun0_hba; @@ -773,7 +773,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) INIT_LIST_HEAD(&dev->delayed_cmd_list); INIT_LIST_HEAD(&dev->state_list); INIT_LIST_HEAD(&dev->qf_cmd_list); - INIT_LIST_HEAD(&dev->g_dev_node); spin_lock_init(&dev->execute_task_lock); spin_lock_init(&dev->delayed_cmd_lock); spin_lock_init(&dev->dev_reservation_lock); @@ -895,11 +894,11 @@ struct se_device *target_find_device(int id, bool do_depend) { struct se_device *dev; - mutex_lock(&g_device_mutex); + mutex_lock(&device_mutex); dev = idr_find(&devices_idr, id); if (dev && do_depend && target_depend_item(&dev->dev_group.cg_item)) dev = NULL; - mutex_unlock(&g_device_mutex); + mutex_unlock(&device_mutex); return dev; } EXPORT_SYMBOL(target_find_device); @@ -943,9 +942,9 @@ int target_for_each_device(int (*fn)(struct se_device *dev, void *data), iter.fn = fn; iter.data = data; - mutex_lock(&g_device_mutex); + mutex_lock(&device_mutex); ret = idr_for_each(&devices_idr, target_devices_idr_iter, &iter); - mutex_unlock(&g_device_mutex); + mutex_unlock(&device_mutex); return ret; } @@ -964,13 +963,13 @@ int target_configure_device(struct se_device *dev) * Add early so modules like tcmu can use during its * configuration. */ - mutex_lock(&g_device_mutex); + mutex_lock(&device_mutex); /* * Use cyclic to try and avoid collisions with devices * that were recently removed. */ id = idr_alloc_cyclic(&devices_idr, dev, 0, INT_MAX, GFP_KERNEL); - mutex_unlock(&g_device_mutex); + mutex_unlock(&device_mutex); if (id < 0) { ret = -ENOMEM; goto out; @@ -1036,10 +1035,6 @@ int target_configure_device(struct se_device *dev) hba->dev_count++; spin_unlock(&hba->device_lock); - mutex_lock(&g_device_mutex); - list_add_tail(&dev->g_dev_node, &g_device_list); - mutex_unlock(&g_device_mutex); - dev->dev_flags |= DF_CONFIGURED; return 0; @@ -1047,9 +1042,9 @@ int target_configure_device(struct se_device *dev) out_free_alua: core_alua_free_lu_gp_mem(dev); out_free_index: - mutex_lock(&g_device_mutex); + mutex_lock(&device_mutex); idr_remove(&devices_idr, dev->dev_index); - mutex_unlock(&g_device_mutex); + mutex_unlock(&device_mutex); out: se_release_vpd_for_dev(dev); return ret; @@ -1066,10 +1061,9 @@ void target_free_device(struct se_device *dev) dev->transport->destroy_device(dev); - mutex_lock(&g_device_mutex); + mutex_lock(&device_mutex); idr_remove(&devices_idr, dev->dev_index); - list_del(&dev->g_dev_node); - mutex_unlock(&g_device_mutex); + mutex_unlock(&device_mutex); spin_lock(&hba->device_lock); hba->dev_count--; diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index 1d3ac02..f30e8ac 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h @@ -56,9 +56,6 @@ struct target_fabric_configfs { extern struct t10_alua_lu_gp *default_lu_gp; /* target_core_device.c */ -extern struct mutex g_device_mutex; -extern struct list_head g_device_list; - int core_alloc_rtpi(struct se_lun *lun, struct se_device *dev); struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16); void target_pr_kref_release(struct kref *); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 51a92f1..516764f 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -796,7 +796,6 @@ struct se_device { struct list_head delayed_cmd_list; struct list_head state_list; struct list_head qf_cmd_list; - struct list_head g_dev_node; /* Pointer to associated SE HBA */ struct se_hba *se_hba; /* T10 Inquiry and VPD WWN Information */