From patchwork Mon Jul 23 19:07:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 10540751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50E99112B for ; Mon, 23 Jul 2018 19:07:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21D7A25EF7 for ; Mon, 23 Jul 2018 19:07:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 168D22624B; Mon, 23 Jul 2018 19:07:58 +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 9BBC325EF7 for ; Mon, 23 Jul 2018 19:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388089AbeGWUKc (ORCPT ); Mon, 23 Jul 2018 16:10:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58380 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388069AbeGWUKc (ORCPT ); Mon, 23 Jul 2018 16:10:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CEF127264F; Mon, 23 Jul 2018 19:07:54 +0000 (UTC) Received: from rh2.redhat.com (ovpn-121-13.rdu2.redhat.com [10.10.121.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65595111CB8C; Mon, 23 Jul 2018 19:07:54 +0000 (UTC) From: Mike Christie To: xiubli@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [PATCH 3/9] target: add helper to check if dev is configured Date: Mon, 23 Jul 2018 14:07:45 -0500 Message-Id: <1532372871-7128-4-git-send-email-mchristi@redhat.com> In-Reply-To: <1532372871-7128-1-git-send-email-mchristi@redhat.com> References: <1532372871-7128-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 23 Jul 2018 19:07:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 23 Jul 2018 19:07:54 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mchristi@redhat.com' RCPT:'' 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 adds a helper function to check if a device is configured and it converts the target users to use it. The next patch will add a backend module user so those types of modules do not have to know the lio core details. Signed-off-by: Mike Christie --- drivers/target/target_core_configfs.c | 8 ++++---- drivers/target/target_core_device.c | 6 +++--- drivers/target/target_core_fabric_configfs.c | 3 ++- include/target/target_core_backend.h | 4 ++++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 93d3ff3..f6b1549 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -810,7 +810,7 @@ static ssize_t pi_prot_type_store(struct config_item *item, dev->transport->name); return -ENOSYS; } - if (!(dev->dev_flags & DF_CONFIGURED)) { + if (!target_dev_configured(dev)) { pr_err("DIF protection requires device to be configured\n"); return -ENODEV; } @@ -859,7 +859,7 @@ static ssize_t pi_prot_format_store(struct config_item *item, dev->transport->name); return -ENOSYS; } - if (!(dev->dev_flags & DF_CONFIGURED)) { + if (!target_dev_configured(dev)) { pr_err("DIF protection format requires device to be configured\n"); return -ENODEV; } @@ -1948,7 +1948,7 @@ static ssize_t target_dev_enable_show(struct config_item *item, char *page) { struct se_device *dev = to_device(item); - return snprintf(page, PAGE_SIZE, "%d\n", !!(dev->dev_flags & DF_CONFIGURED)); + return snprintf(page, PAGE_SIZE, "%d\n", target_dev_configured(dev)); } static ssize_t target_dev_enable_store(struct config_item *item, @@ -2473,7 +2473,7 @@ static ssize_t target_tg_pt_gp_alua_access_state_store(struct config_item *item, " tg_pt_gp ID: %hu\n", tg_pt_gp->tg_pt_gp_valid_id); return -EINVAL; } - if (!(dev->dev_flags & DF_CONFIGURED)) { + if (!target_dev_configured(dev)) { pr_err("Unable to set alua_access_state while device is" " not configured\n"); return -ENODEV; diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 73675ee..47b5ef1 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -900,7 +900,7 @@ static int target_devices_idr_iter(int id, void *p, void *data) * to allow other callers to access partially setup devices, * so we skip them here. */ - if (!(dev->dev_flags & DF_CONFIGURED)) + if (!target_dev_configured(dev)) return 0; iter->prev_item = config_item_get_unless_zero(&dev->dev_group.cg_item); @@ -940,7 +940,7 @@ int target_configure_device(struct se_device *dev) struct se_hba *hba = dev->se_hba; int ret, id; - if (dev->dev_flags & DF_CONFIGURED) { + if (target_dev_configured(dev)) { pr_err("se_dev->se_dev_ptr already set for storage" " object\n"); return -EEXIST; @@ -1045,7 +1045,7 @@ void target_free_device(struct se_device *dev) WARN_ON(!list_empty(&dev->dev_sep_list)); - if (dev->dev_flags & DF_CONFIGURED) { + if (target_dev_configured(dev)) { destroy_workqueue(dev->tmr_wq); dev->transport->destroy_device(dev); diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index 1fa436e..aa2f4f6 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c @@ -34,6 +34,7 @@ #include #include +#include #include #include "target_core_internal.h" @@ -642,7 +643,7 @@ static int target_fabric_port_link( } dev = container_of(to_config_group(se_dev_ci), struct se_device, dev_group); - if (!(dev->dev_flags & DF_CONFIGURED)) { + if (!target_dev_configured(dev)) { pr_err("se_device not configured yet, cannot port link\n"); return -ENODEV; } diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index c3ac472..51b6f50 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -111,6 +111,10 @@ sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd, bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, struct request_queue *q); +static inline bool target_dev_configured(struct se_device *se_dev) +{ + return !!(se_dev->dev_flags & DF_CONFIGURED); +} /* Only use get_unaligned_be24() if reading p - 1 is allowed. */ static inline uint32_t get_unaligned_be24(const uint8_t *const p)