From patchwork Sat Jul 8 07:52:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9831419 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 C0DC4602BD for ; Sat, 8 Jul 2017 07:52:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB8A1283C5 for ; Sat, 8 Jul 2017 07:52:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CA0F284E4; Sat, 8 Jul 2017 07:52:42 +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 1C98D283C5 for ; Sat, 8 Jul 2017 07:52:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752123AbdGHHwi (ORCPT ); Sat, 8 Jul 2017 03:52:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45900 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078AbdGHHwi (ORCPT ); Sat, 8 Jul 2017 03:52:38 -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 582FFC057FA5; Sat, 8 Jul 2017 07:52:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 582FFC057FA5 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mchristi@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 582FFC057FA5 Received: from rh2.redhat.com (ovpn-120-18.rdu2.redhat.com [10.10.120.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7710E60600; Sat, 8 Jul 2017 07:52:36 +0000 (UTC) From: Mike Christie To: target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [PATCH] tcmu: export supported device features in configfs Date: Sat, 8 Jul 2017 02:52:34 -0500 Message-Id: <1499500354-6452-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.32]); Sat, 08 Jul 2017 07:52:37 +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 Userspace tools like targetcli are not able to dynamically detect if a tcmu device supports kernel features ALUA or PGRs. In some kernels it can create ALUA groups, but writing/reading ALUA files can lead to nice error codes but also crashes and hangs. This patch, made over Nicks's for next branch, adds a device configfs attribute to report the kernel features the device supports, so tools can check that before attempting to activate some of these features that were partially supported in older kernels. It can also be used for future feautes like possibly inquiry suppport if we do end up moving that to the kernel so we can properly report port info. Signed-off-by: Mike Christie --- drivers/target/target_core_user.c | 13 +++++++++++++ include/uapi/linux/target_core_user.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 2f1fa92..b891824 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -111,6 +111,7 @@ struct tcmu_dev { char *name; struct se_hba *hba; + uint64_t features; #define TCMU_DEV_BIT_OPEN 0 #define TCMU_DEV_BIT_BROKEN 1 @@ -1104,6 +1105,7 @@ static struct se_device *tcmu_alloc_device(struct se_hba *hba, const char *name) udev->hba = hba; udev->cmd_time_out = TCMU_TIME_OUT; + udev->features |= (TCMU_KERN_ALUA | TCMU_KERN_PGR); init_waitqueue_head(&udev->wait_cmdr); mutex_init(&udev->cmdr_lock); @@ -1882,11 +1884,22 @@ static ssize_t tcmu_emulate_write_cache_store(struct config_item *item, } CONFIGFS_ATTR(tcmu_, emulate_write_cache); +static ssize_t tcmu_features_show(struct config_item *item, char *page) +{ + struct se_dev_attrib *da = container_of(to_config_group(item), + struct se_dev_attrib, da_group); + struct tcmu_dev *udev = TCMU_DEV(da->da_dev); + + return snprintf(page, PAGE_SIZE, "0x%llx\n", udev->features); +} +CONFIGFS_ATTR_RO(tcmu_, features); + static struct configfs_attribute *tcmu_attrib_attrs[] = { &tcmu_attr_cmd_time_out, &tcmu_attr_dev_config, &tcmu_attr_dev_size, &tcmu_attr_emulate_write_cache, + &tcmu_attr_features, NULL, }; diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h index 24a1c4e..03de6e9 100644 --- a/include/uapi/linux/target_core_user.h +++ b/include/uapi/linux/target_core_user.h @@ -154,4 +154,7 @@ enum tcmu_genl_attr { }; #define TCMU_ATTR_MAX (__TCMU_ATTR_MAX - 1) +#define TCMU_KERN_ALUA (1ULL << 0) +#define TCMU_KERN_PGR (1ULL << 1) + #endif