From patchwork Thu Apr 19 07:46:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 10349253 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 498D860365 for ; Thu, 19 Apr 2018 07:46:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DA442899E for ; Thu, 19 Apr 2018 07:46:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32532289A3; Thu, 19 Apr 2018 07:46:17 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 DB20B289A2 for ; Thu, 19 Apr 2018 07:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752455AbeDSHqQ (ORCPT ); Thu, 19 Apr 2018 03:46:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44374 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751903AbeDSHqP (ORCPT ); Thu, 19 Apr 2018 03:46:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7AFA7D83F; Thu, 19 Apr 2018 07:46:14 +0000 (UTC) Received: from gblock1.localdomain (ovpn-12-40.pek2.redhat.com [10.72.12.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05F3A2026985; Thu, 19 Apr 2018 07:46:12 +0000 (UTC) From: xiubli@redhat.com To: mchristi@redhat.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCHv4 2/3] target: adjust and export target_for_each_device visible to modules Date: Thu, 19 Apr 2018 03:46:03 -0400 Message-Id: <1524123964-21347-3-git-send-email-xiubli@redhat.com> In-Reply-To: <1524123964-21347-1-git-send-email-xiubli@redhat.com> References: <1524123964-21347-1-git-send-email-xiubli@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 19 Apr 2018 07:46:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 19 Apr 2018 07:46:14 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'xiubli@redhat.com' RCPT:'' Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xiubo Li Make the target_for_each_device could list all the devices not only configured as needed. Signed-off-by: Xiubo Li --- drivers/target/target_core_device.c | 10 +--------- drivers/target/target_core_internal.h | 2 -- drivers/target/target_core_xcopy.c | 3 +++ include/target/target_core_backend.h | 3 +++ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index e27db4d..58508a2 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -913,15 +913,6 @@ static int target_devices_idr_iter(int id, void *p, void *data) struct devices_idr_iter *iter = data; struct se_device *dev = p; - /* - * We add the device early to the idr, so it can be used - * by backend modules during configuration. We do not want - * to allow other callers to access partially setup devices, - * so we skip them here. - */ - if (!(dev->dev_flags & DF_CONFIGURED)) - return 0; - return iter->fn(dev, iter->data); } @@ -947,6 +938,7 @@ int target_for_each_device(int (*fn)(struct se_device *dev, void *data), mutex_unlock(&device_mutex); return ret; } +EXPORT_SYMBOL(target_for_each_device); int target_configure_device(struct se_device *dev) { diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index 73e8157..2f22aee 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h @@ -89,8 +89,6 @@ void core_dev_free_initiator_node_lun_acl(struct se_portal_group *, struct se_device *target_alloc_device(struct se_hba *hba, const char *name); int target_configure_device(struct se_device *dev); void target_free_device(struct se_device *); -int target_for_each_device(int (*fn)(struct se_device *dev, void *data), - void *data); /* target_core_configfs.c */ extern struct configfs_item_operations target_core_dev_item_ops; diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index 9ee89e0..cb9cc1e 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -67,6 +67,9 @@ static int target_xcopy_locate_se_dev_e4_iter(struct se_device *se_dev, unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN]; int rc; + if (!(se_dev->dev_flags & DF_CONFIGURED)) + return 0; + if (!se_dev->dev_attrib.emulate_3pc) return 0; diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 5df7059..7451d65 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -109,6 +109,9 @@ sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd, struct se_device *target_find_device(int id, bool do_depend); +int target_for_each_device(int (*fn)(struct se_device *dev, void *data), + void *data); + bool target_sense_desc_format(struct se_device *dev); sector_t target_to_linux_sector(struct se_device *dev, sector_t lb); bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,