From patchwork Fri Jun 16 21:47:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9793787 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 9448760326 for ; Fri, 16 Jun 2017 21:47:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86CB12869C for ; Fri, 16 Jun 2017 21:47:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BAC3286A8; Fri, 16 Jun 2017 21:47:45 +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 1959F2869C for ; Fri, 16 Jun 2017 21:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752041AbdFPVro (ORCPT ); Fri, 16 Jun 2017 17:47:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42966 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbdFPVro (ORCPT ); Fri, 16 Jun 2017 17:47:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E362963E3F; Fri, 16 Jun 2017 21:47:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E362963E3F Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mchristi@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E362963E3F Received: from rh2.redhat.com (ovpn-122-182.rdu2.redhat.com [10.10.122.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26A0560461; Fri, 16 Jun 2017 21:47:43 +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 11/11] target: move rcu call to the core target code Date: Fri, 16 Jun 2017 16:47:30 -0500 Message-Id: <1497649650-7605-12-git-send-email-mchristi@redhat.com> In-Reply-To: <1497649650-7605-1-git-send-email-mchristi@redhat.com> References: <1497649650-7605-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 16 Jun 2017 21:47:44 +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 With the last patch to tcmu, there is no need to have each backend module do their own rcu calls for freeing the device. This patch moves it to target core. Signed-off-by: Mike Christie --- drivers/target/target_core_device.c | 9 ++++++++- drivers/target/target_core_file.c | 8 +------- drivers/target/target_core_iblock.c | 8 +------- drivers/target/target_core_pscsi.c | 8 +------- drivers/target/target_core_user.c | 8 +------- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 9c45602..d2becd0 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -1059,6 +1059,13 @@ int target_configure_device(struct se_device *dev) return ret; } +static void target_free_device_call_rcu(struct rcu_head *p) +{ + struct se_device *dev = container_of(p, struct se_device, rcu_head); + + dev->transport->free_device(dev); +} + void target_free_device(struct se_device *dev) { struct se_hba *hba = dev->se_hba; @@ -1087,7 +1094,7 @@ void target_free_device(struct se_device *dev) if (dev->transport->free_prot) dev->transport->free_prot(dev); - dev->transport->free_device(dev); + call_rcu(&dev->rcu_head, target_free_device_call_rcu); } int core_dev_setup_virtual_lun0(void) diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 50f2355..c8c2207 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -227,19 +227,13 @@ static int fd_configure_device(struct se_device *dev) return ret; } -static void fd_dev_call_rcu(struct rcu_head *p) +static void fd_free_device(struct se_device *dev) { - struct se_device *dev = container_of(p, struct se_device, rcu_head); struct fd_dev *fd_dev = FD_DEV(dev); kfree(fd_dev); } -static void fd_free_device(struct se_device *dev) -{ - call_rcu(&dev->rcu_head, fd_dev_call_rcu); -} - static void fd_destroy_device(struct se_device *dev) { struct fd_dev *fd_dev = FD_DEV(dev); diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index a5e16f7..bc36d7b 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -180,19 +180,13 @@ static int iblock_configure_device(struct se_device *dev) return ret; } -static void iblock_dev_call_rcu(struct rcu_head *p) +static void iblock_free_device(struct se_device *dev) { - struct se_device *dev = container_of(p, struct se_device, rcu_head); struct iblock_dev *ib_dev = IBLOCK_DEV(dev); kfree(ib_dev); } -static void iblock_free_device(struct se_device *dev) -{ - call_rcu(&dev->rcu_head, iblock_dev_call_rcu); -} - static void iblock_destroy_device(struct se_device *dev) { struct iblock_dev *ib_dev = IBLOCK_DEV(dev); diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 7d944b2..b29518c 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -554,19 +554,13 @@ static int pscsi_configure_device(struct se_device *dev) return -ENODEV; } -static void pscsi_dev_call_rcu(struct rcu_head *p) +static void pscsi_free_device(struct se_device *dev) { - struct se_device *dev = container_of(p, struct se_device, rcu_head); struct pscsi_dev_virt *pdv = PSCSI_DEV(dev); kfree(pdv); } -static void pscsi_free_device(struct se_device *dev) -{ - call_rcu(&dev->rcu_head, pscsi_dev_call_rcu); -} - static void pscsi_destroy_device(struct se_device *dev) { struct pscsi_dev_virt *pdv = PSCSI_DEV(dev); diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index c53cbaf..624d9bb 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1529,19 +1529,13 @@ static void tcmu_blocks_release(struct tcmu_dev *udev) mutex_unlock(&udev->cmdr_lock); } -static void tcmu_dev_call_rcu(struct rcu_head *p) +static void tcmu_free_device(struct se_device *dev) { - struct se_device *dev = container_of(p, struct se_device, rcu_head); struct tcmu_dev *udev = TCMU_DEV(dev); kfree(udev); } -static void tcmu_free_device(struct se_device *dev) -{ - call_rcu(&dev->rcu_head, tcmu_dev_call_rcu); -} - static void tcmu_destroy_device(struct se_device *dev) { struct tcmu_dev *udev = TCMU_DEV(dev);