From patchwork Mon Apr 27 15:08:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bodo Stroesser X-Patchwork-Id: 11512413 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2446813B2 for ; Mon, 27 Apr 2020 15:08:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEC0D206B9 for ; Mon, 27 Apr 2020 15:08:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ts.fujitsu.com header.i=@ts.fujitsu.com header.b="IuAhspuP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbgD0PId (ORCPT ); Mon, 27 Apr 2020 11:08:33 -0400 Received: from mail1.bemta26.messagelabs.com ([85.158.142.113]:61000 "EHLO mail1.bemta26.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgD0PIc (ORCPT ); Mon, 27 Apr 2020 11:08:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ts.fujitsu.com; s=200619tsfj; t=1588000110; i=@ts.fujitsu.com; bh=kMG0yUaaspA//KQ9VSeFJDQKXrDiLpr0wGyQrmXds5g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=IuAhspuPuBp/FEeqcbD/+FKqdSLwZY8cZysdADvUQsWxc5zbfJfjw8XaN3yMPYfcS fbh9p8XbLJSLzl96WUauPesfGTiQDdreBuH4WwIBTDcJaVxs5co97wg4Hfq30d4YBP BdVYtrcXff+tsypdLV/FJKWGVgqnICwHtoXIznoNlq26X1EwnKyRRmzghaMn+XGvgL LwkNso8GoVTYZAlvRqRGwi+OTEebCnDT8aU1UFDMflMaXXt2yKkc12ts1tn2tBl4ID kxd00j1YQh/OA6A4HYYk8WGgiyorp9e48ZoDf1DvigZWzKyskz79C1nssc7773Fojg R4JguR7+7Ajeg== Received: from [100.113.6.103] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta.az-b.eu-central-1.aws.symcld.net id 2F/E7-40482-D65F6AE5; Mon, 27 Apr 2020 15:08:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRWlGSWpSXmKPExsViZ8MRopv7dVm cwYpWHYuv/6ezWKxcfZTJovv6DjaL5cf/MVmsP7KB0aJ16VsmBzaP3Tcb2Dw+Pr3F4vF+31U2 j82nqz0+b5ILYI1izcxLyq9IYM2YdXw6a8Fj9oqT7U2sDYwf2LoYuTiEBCYzShz+O5kRwpnOK HHjwRL2LkZODjYBA4kVk+6zgNgiAjYSfYeXMoEUMQs0MUrcerUeqJ2DQ1ggVOLRb3eQGhYBVY lTi86zgIR5BewkPpzKAglLCMhLdByYDDaGU8Be4szF62CdQkAlHx/oTWDkXsDIsIrRIqkoMz2 jJDcxM0fX0MBA19DQWNdE18JcL7FKN0kvtVQ3OTWvpCgRKKmXWF6sV1yZm5yTopeXWrKJERhS KYUs4TsYdy5/r3eIUZKDSUmU9+TqZXFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHinfgbKCRalp qdWpGXmAMMbJi3BwaMkwpvwBSjNW1yQmFucmQ6ROsVoz/Fm7ZJFzBxt9+4CyZkLDq5m5rjffm g1sxBLXn5eqpQ4rx1ImwBIW0ZpHtxQWDxeYpSVEuZlZGBgEOIpSC3KzSxBlX/FKM7BqCTMOwv kNp7MvBK43a+AzmICOqtKfjHIWSWJCCmpBqaDixecZZn9UOtw7Vq7bpnAlQ/6Tmiw/+marrJt 0Q8z25x/XZcvnr+1U/RYvuDde4aTaz+LLvaTtVrE8PVo9nSjx8udlRWPLah5ynFa+0Wg37bl0 9oE/nnIWkhm5m82j+djDuV7df57/2oR52UTVjqckD9dFpZwTTXI/2LytadsAULTq97zl/Wy7L eefO/yxsc2HdoXl/Lufn8ht6jygMLjnotqxzvrf3ed74uvSEzxqLmT+kTStP7+rLhbMW3sWyI 2vrxZqca+Yd08y+uXU/Wu3SuMvi6694VAtu+f5gr511075S5wb/rSYtkc3x3WHPz1TeJyx3ru mewsL24GhG1dmOJ8/m+xQIX2r+JVctuVWIozEg21mIuKEwFkanI/QgMAAA== X-Env-Sender: bstroesser@ts.fujitsu.com X-Msg-Ref: server-13.tower-245.messagelabs.com!1588000109!51129!1 X-Originating-IP: [62.60.8.84] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.50.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15394 invoked from network); 27 Apr 2020 15:08:29 -0000 Received: from unknown (HELO mailhost3.uk.fujitsu.com) (62.60.8.84) by server-13.tower-245.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Apr 2020 15:08:29 -0000 Received: from x-serv01 ([172.17.38.52]) by mailhost3.uk.fujitsu.com (8.14.5/8.14.5) with SMTP id 03RF8QuV031886; Mon, 27 Apr 2020 16:08:26 +0100 Received: from VTC.emeia.fujitsu.local (unknown [172.17.38.7]) by x-serv01 (Postfix) with ESMTP id E863D20708; Mon, 27 Apr 2020 17:08:25 +0200 (CEST) From: Bodo Stroesser To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: mchristi@redhat.com, ddiss@suse.de, hch@lst.de, martin.petersen@oracle.com, Bodo Stroesser Subject: [PATCH 1/4] target: add missing emulate_pr attribute to passthrough backends Date: Mon, 27 Apr 2020 17:08:20 +0200 Message-Id: <20200427150823.15350-2-bstroesser@ts.fujitsu.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20200427150823.15350-1-bstroesser@ts.fujitsu.com> References: <20200427150823.15350-1-bstroesser@ts.fujitsu.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org In commit b49d6f7885306ee636d5c1af52170f3069ccf5f7 the new attribute emulate_pr was added. passthrough_parse_cdb() uses the attribute's value to distinguish, whether reservation commands should be rejected or not. But the new attribute was not added to passthrough_attrib_attrs, so in pscsi and tcmu - the users of passthrough_parse_cdb() - the attribute is not available to change parser's behavior. Signed-off-by: Bodo Stroesser --- drivers/target/target_core_configfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index ff82b21fdcce..d8589bb39c53 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1203,6 +1203,7 @@ struct configfs_attribute *passthrough_attrib_attrs[] = { &attr_hw_block_size, &attr_hw_max_sectors, &attr_hw_queue_depth, + &attr_emulate_pr, &attr_alua_support, &attr_pgr_support, NULL, From patchwork Mon Apr 27 15:08:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bodo Stroesser X-Patchwork-Id: 11512429 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD69A92A for ; Mon, 27 Apr 2020 15:08:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4E13206B9 for ; Mon, 27 Apr 2020 15:08:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ts.fujitsu.com header.i=@ts.fujitsu.com header.b="RICz3GlQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728151AbgD0PIk (ORCPT ); Mon, 27 Apr 2020 11:08:40 -0400 Received: from mail1.bemta26.messagelabs.com ([85.158.142.112]:45014 "EHLO mail1.bemta26.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727010AbgD0PIj (ORCPT ); Mon, 27 Apr 2020 11:08:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ts.fujitsu.com; s=200619tsfj; t=1588000116; i=@ts.fujitsu.com; bh=hhdndVHek54RMTdFxOSkrFch+MGToNeHqu/zEHcd718=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=RICz3GlQBKo+7Vdw1+8OBF0vp9Y4jauNnyuHkxyesoozcqeRuxdS7DU1jLwK8/zWm e8RnRVPBAflS7EvfHSdEgt/hsT9kgljvcmZF+2hSDnxLa4ohVG1AgFeaTEVeG3qR3U 72rfiASEM0qVbKvm3joeSPlhHkrrT4tTTj9WQi6g+6roLX7M3v4aLaMErElQf9KXUc 1rwmbMs4q/U35O+UuvyByPYrVb7pllhAwZy14c+IUVbK3GiqIIq8Ve/+7CbvWSpfii iAMkoDjoGX23QHMOjVGqjQGFdRg6fYvrmTS3lV4ZjmZkh/fYU2uxb0hb8HZYq/MG2H z7mm3agBiWwDA== Received: from [100.113.6.103] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-1.bemta.az-b.eu-central-1.aws.symcld.net id FD/77-39489-475F6AE5; Mon, 27 Apr 2020 15:08:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsViZ8MRqlv8dVm cwZJFqhZf/09nsVi5+iiTRff1HWwWy4//Y7JYf2QDo0Xr0rdMDmweu282sHl8fHqLxeP9vqts HptPV3t83iQXwBrFmpmXlF+RwJqx8fdD1oKjkhUH/jexNDAuFOti5OIQEpjMKDHx10pWCGc6o 8SCZ6eYuxg5OdgEDCRWTLrPAmKLCNhI9B1eygRSxCzQxChx69V6NpCEsECIRN/q42BFLAKqEv Me/QWzeQXsJA4eu8IOYksIyEt0HJgMFucUsJc4c/E6UC8H0DY7iY8P9CYwci9gZFjFaJFUlJm eUZKbmJmja2hgoGtoaKxromtkpJdYpZukl1qqm5yaV1KUCJTUSywv1iuuzE3OSdHLSy3ZxAgM q5RCFrEdjLPWvtc7xCjJwaQkynty9bI4Ib6k/JTKjMTijPii0pzU4kOMMhwcShK8Uz8D5QSLU tNTK9Iyc4AhDpOW4OBREuFN+AKU5i0uSMwtzkyHSJ1iVJQS57UDSQiAJDJK8+DaYHF1iVFWSp iXkYGBQYinILUoN7MEVf4VozgHo5Iw7yyQ7TyZeSVw018BLWYCWlwlvxhkcUkiQkqqgUn11Tu 35q5zNrUOtZJzrz6cO0sm3O8Q8xTNp8F3+dKeLJi5Vnn1vH93T21vv3Zn4rMzEnHPzi8WWvq9 x+LXN9u8PyJnuXYdON5+VOB53NSfspfSgmYzC4WdaGn5Wf8reW3wQbVPm7xm77wYlFnDv+LAV +WNHxPz3rw169JaKPz4mg/Hrqkbm3dpmlgu/3qN6eOOxg9/ZCLi921Jip3Tnbf48//vlxbzKJ slmKan73fznb4v68zLEqcXQa9fVmn9eGB8uHS2wdy2a1yOXmulXvHtkuTQTS/6H6lYaqSuUr3 toWjgC7Ha1pTdu/lqOj3CDqlGn29cqpQw/zt7mLlh6BxJx+2hyT5/uBYotS8JSLNVYinOSDTU Yi4qTgQArlRA2iYDAAA= X-Env-Sender: bstroesser@ts.fujitsu.com X-Msg-Ref: server-23.tower-245.messagelabs.com!1588000115!1029317!1 X-Originating-IP: [62.60.8.85] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.50.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9044 invoked from network); 27 Apr 2020 15:08:35 -0000 Received: from unknown (HELO mailhost4.uk.fujitsu.com) (62.60.8.85) by server-23.tower-245.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Apr 2020 15:08:35 -0000 Received: from x-serv01 ([172.17.38.52]) by mailhost4.uk.fujitsu.com (8.14.5/8.14.5) with SMTP id 03RF8XOS025009; Mon, 27 Apr 2020 16:08:33 +0100 Received: from VTC.emeia.fujitsu.local (unknown [172.17.38.7]) by x-serv01 (Postfix) with ESMTP id 01D7420722; Mon, 27 Apr 2020 17:08:26 +0200 (CEST) From: Bodo Stroesser To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: mchristi@redhat.com, ddiss@suse.de, hch@lst.de, martin.petersen@oracle.com, Bodo Stroesser Subject: [PATCH 2/4] target: tcmu: add attrbutes enforce_pr_isids and force_pr_aptpl Date: Mon, 27 Apr 2020 17:08:21 +0200 Message-Id: <20200427150823.15350-3-bstroesser@ts.fujitsu.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20200427150823.15350-1-bstroesser@ts.fujitsu.com> References: <20200427150823.15350-1-bstroesser@ts.fujitsu.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org tcmu has not set TRANSPORT_FLAG_PASSTHROUGH_PGR. Therefore the in core pr emulation is active by default, but there are some attributes for configuration missing. So we add them now. Signed-off-by: Bodo Stroesser --- drivers/target/target_core_configfs.c | 11 +++++++++++ drivers/target/target_core_user.c | 19 +++++++++---------- include/target/target_core_backend.h | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index d8589bb39c53..efa92d836946 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1210,6 +1210,17 @@ struct configfs_attribute *passthrough_attrib_attrs[] = { }; EXPORT_SYMBOL(passthrough_attrib_attrs); +/* + * pr related dev_attrib attributes for devices passing through CDBs, + * but allowing in core pr emulation. + */ +struct configfs_attribute *passthrough_pr_attrib_attrs[] = { + &attr_enforce_pr_isids, + &attr_force_pr_aptpl, + NULL, +}; +EXPORT_SYMBOL(passthrough_pr_attrib_attrs); + TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL); TB_CIT_SETUP_DRV(dev_action, NULL, NULL); diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index f769bb1e3735..8adde343182f 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -2753,12 +2753,12 @@ static int __init tcmu_module_init(void) goto out_unreg_device; } - for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) { + for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) len += sizeof(struct configfs_attribute *); - } - for (i = 0; tcmu_attrib_attrs[i] != NULL; i++) { + for (i = 0; passthrough_pr_attrib_attrs[i] != NULL; i++) + len += sizeof(struct configfs_attribute *); + for (i = 0; tcmu_attrib_attrs[i] != NULL; i++) len += sizeof(struct configfs_attribute *); - } len += sizeof(struct configfs_attribute *); tcmu_attrs = kzalloc(len, GFP_KERNEL); @@ -2767,13 +2767,12 @@ static int __init tcmu_module_init(void) goto out_unreg_genl; } - for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) { + for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) tcmu_attrs[i] = passthrough_attrib_attrs[i]; - } - for (k = 0; tcmu_attrib_attrs[k] != NULL; k++) { - tcmu_attrs[i] = tcmu_attrib_attrs[k]; - i++; - } + for (k = 0; passthrough_pr_attrib_attrs[k] != NULL; k++) + tcmu_attrs[i++] = passthrough_pr_attrib_attrs[k]; + for (k = 0; tcmu_attrib_attrs[k] != NULL; k++) + tcmu_attrs[i++] = tcmu_attrib_attrs[k]; tcmu_ops.tb_dev_attrib_attrs = tcmu_attrs; ret = transport_backend_register(&tcmu_ops); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 1b752d8ea529..8177667eba6d 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -94,6 +94,7 @@ int transport_set_vpd_ident(struct t10_vpd *, unsigned char *); extern struct configfs_attribute *sbc_attrib_attrs[]; extern struct configfs_attribute *passthrough_attrib_attrs[]; +extern struct configfs_attribute *passthrough_pr_attrib_attrs[]; /* core helpers also used by command snooping in pscsi */ void *transport_kmap_data_sg(struct se_cmd *); From patchwork Mon Apr 27 15:08:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bodo Stroesser X-Patchwork-Id: 11512417 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6922E92A for ; Mon, 27 Apr 2020 15:08:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D96F206B9 for ; Mon, 27 Apr 2020 15:08:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ts.fujitsu.com header.i=@ts.fujitsu.com header.b="Yj4D+tAF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbgD0PIf (ORCPT ); Mon, 27 Apr 2020 11:08:35 -0400 Received: from mail1.bemta26.messagelabs.com ([85.158.142.114]:44634 "EHLO mail1.bemta26.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727010AbgD0PIf (ORCPT ); Mon, 27 Apr 2020 11:08:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ts.fujitsu.com; s=200619tsfj; t=1588000110; i=@ts.fujitsu.com; bh=yDZiskhu2q8Mcsmv/6wKv8QYYiltiqb5ejmNnsFrsD4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Yj4D+tAFgibJAMpBv4A/CgvE16wS9tfZ8OIrBQU8viEmiR4G9K6OJI3rR6rVf//lV NKNna+5PiaigUoaVlxjbXZSiBGgIKbA2CSiPvrMXAi7VFF9eIbSbceQ24n6ZZjufgp umV/TyTDFNyJxbrEjGV7eLYHsn7/ECXA+gTWBahTS5RhaAjwfuIvmW6FEKEFISr7xW EAcr8eB5QMJ+Tum7ahwhIzOhtny9hwYjcW2GsRtyG9qtQXxHStxsclKw4by6Vag1P1 acFb8JY/oU6kDouTvt1yags2ROHUvGpluwae8KHrZbUScz+SPcBf9neFadkGAFMMgl BeA4UqlqJY/DQ== Received: from [100.113.6.103] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-3.bemta.az-b.eu-central-1.aws.symcld.net id 11/00-40390-E65F6AE5; Mon, 27 Apr 2020 15:08:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsViZ8MxVTfv67I 4g993WC2+/p/OYrFy9VEmi+7rO9gslh//x2Sx/sgGRovWpW+ZHNg8dt9sYPP4+PQWi8f7fVfZ PDafrvb4vEkugDWKNTMvKb8igTVj+vHLrAXXIivurnnF1sA426+LkZNDSGAyo8TlnxxdjFxA9 nRGifs397ODJNgEDCRWTLrPAmKLCNhI9B1eygRSxCzQxChx69V6NpCEMFDixL0msCIWAVWJtQ t/MoHYvAJ2El3v+sFsCQF5iY4Dk8FqOAXsJc5cvA7UywG0zU7i4wO9CYzcCxgZVjFaJhVlpme U5CZm5ugaGhjoGhoa65rpGpoa6CVW6SbppZbqJqfmlRQlAmX1EsuL9Yorc5NzUvTyUks2MQLD KqWQbdoOxitr3+sdYpTkYFIS5T25elmcEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneqZ+BcoJFq empFWmZOcAQh0lLcPAoifAmfAFK8xYXJOYWZ6ZDpE4xKkqJ89qBJARAEhmleXBtsLi6xCgrJc zLyMDAIMRTkFqUm1mCKv+KUZyDUUmYdxbIdp7MvBK46a+AFjMBLa6SXwyyuCQRISXVwLRxo96 ylu+7GFM82HKjUyqVRI2n8Omy1m+YfcM8Qk6oabdOScYx3kmHGybHzc+xdFiTa5QzQXfSYR6J XRUHZ1//wbDv2ff+KqGpH+4kr9XZzfxs9urfoiscGN/oCivHl8RuT0k8uGft35VdmepHZlc+C Fo8ae8kRe/4A+ky3t07Jfg3+rVdvHrK+jhbsZVWquu/ysXB2zae/Ri6N3v1uUdLfqeb993h9n /8zs1iT4aIZ+2dJzvLzuz//btW5bTOpOM+8380apu8aendYPrA+QX3naBbxx7HZikK5/uli+g EMFoaXVM5xy4o1dRsNCFa8um+zVtiI6cy35vBO9c0cxuf8nKH87PEtgbckmv4uUGJpTgj0VCL uag4EQA9WvfUJgMAAA== X-Env-Sender: bstroesser@ts.fujitsu.com X-Msg-Ref: server-22.tower-245.messagelabs.com!1588000109!1031667!1 X-Originating-IP: [62.60.8.149] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.50.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5055 invoked from network); 27 Apr 2020 15:08:30 -0000 Received: from unknown (HELO mailhost2.uk.fujitsu.com) (62.60.8.149) by server-22.tower-245.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Apr 2020 15:08:30 -0000 Received: from x-serv01 ([172.17.38.52]) by mailhost2.uk.fujitsu.com (8.14.5/8.14.5) with SMTP id 03RF8Qfu013124; Mon, 27 Apr 2020 16:08:26 +0100 Received: from VTC.emeia.fujitsu.local (unknown [172.17.38.7]) by x-serv01 (Postfix) with ESMTP id 0E795207E1; Mon, 27 Apr 2020 17:08:26 +0200 (CEST) From: Bodo Stroesser To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: mchristi@redhat.com, ddiss@suse.de, hch@lst.de, martin.petersen@oracle.com, Bodo Stroesser Subject: [PATCH 3/4] target: make transport_flags per device Date: Mon, 27 Apr 2020 17:08:22 +0200 Message-Id: <20200427150823.15350-4-bstroesser@ts.fujitsu.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20200427150823.15350-1-bstroesser@ts.fujitsu.com> References: <20200427150823.15350-1-bstroesser@ts.fujitsu.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org pgr_support and alua_support device attributes show the inverted value of the transport_flags * TRANSPORT_FLAG_PASSTHROUGH_PGR * TRANSPORT_FLAG_PASSTHROUGH_ALUA These attributes are per device, while the flags are per backend. So we rename the transport_flags in backend/transport to transport_flags_default and use its value to initialize the new transport_flags field in the se_device structure. Now data and attribute both are per se_device. Signed-off-by: Bodo Stroesser --- drivers/target/target_core_alua.c | 10 +++++----- drivers/target/target_core_configfs.c | 14 +++++++------- drivers/target/target_core_device.c | 3 ++- drivers/target/target_core_pr.c | 2 +- drivers/target/target_core_pscsi.c | 6 +++--- drivers/target/target_core_tpg.c | 3 +-- drivers/target/target_core_transport.c | 6 +++--- drivers/target/target_core_user.c | 2 +- include/target/target_core_backend.h | 2 +- include/target/target_core_base.h | 1 + 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 385e4cf9cfa6..6b72afee2f8b 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -677,7 +677,7 @@ target_alua_state_check(struct se_cmd *cmd) if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) return 0; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) return 0; /* @@ -1090,7 +1090,7 @@ int core_alua_do_port_transition( struct t10_alua_tg_pt_gp *tg_pt_gp; int primary, valid_states, rc = 0; - if (l_dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) + if (l_dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) return -ENODEV; valid_states = l_tg_pt_gp->tg_pt_gp_alua_supported_states; @@ -1920,7 +1920,7 @@ ssize_t core_alua_store_tg_pt_gp_info( unsigned char buf[TG_PT_GROUP_NAME_BUF]; int move = 0; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA || + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA || (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) return -ENODEV; @@ -2177,7 +2177,7 @@ ssize_t core_alua_store_offline_bit( unsigned long tmp; int ret; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA || + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA || (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) return -ENODEV; @@ -2263,7 +2263,7 @@ ssize_t core_alua_store_secondary_write_metadata( int core_setup_alua(struct se_device *dev) { - if (!(dev->transport->transport_flags & + if (!(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) && !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) { struct t10_alua_lu_gp_member *lu_gp_mem; diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index efa92d836946..279989e32e64 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1099,7 +1099,7 @@ static ssize_t block_size_store(struct config_item *item, static ssize_t alua_support_show(struct config_item *item, char *page) { struct se_dev_attrib *da = to_attrib(item); - u8 flags = da->da_dev->transport->transport_flags; + u8 flags = da->da_dev->transport_flags; return snprintf(page, PAGE_SIZE, "%d\n", flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ? 0 : 1); @@ -1108,7 +1108,7 @@ static ssize_t alua_support_show(struct config_item *item, char *page) static ssize_t pgr_support_show(struct config_item *item, char *page) { struct se_dev_attrib *da = to_attrib(item); - u8 flags = da->da_dev->transport->transport_flags; + u8 flags = da->da_dev->transport_flags; return snprintf(page, PAGE_SIZE, "%d\n", flags & TRANSPORT_FLAG_PASSTHROUGH_PGR ? 0 : 1); @@ -1654,7 +1654,7 @@ static ssize_t target_pr_res_holder_show(struct config_item *item, char *page) if (!dev->dev_attrib.emulate_pr) return sprintf(page, "SPC_RESERVATIONS_DISABLED\n"); - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) return sprintf(page, "Passthrough\n"); spin_lock(&dev->dev_reservation_lock); @@ -1796,7 +1796,7 @@ static ssize_t target_pr_res_type_show(struct config_item *item, char *page) if (!dev->dev_attrib.emulate_pr) return sprintf(page, "SPC_RESERVATIONS_DISABLED\n"); - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) return sprintf(page, "SPC_PASSTHROUGH\n"); if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) return sprintf(page, "SPC2_RESERVATIONS\n"); @@ -1810,7 +1810,7 @@ static ssize_t target_pr_res_aptpl_active_show(struct config_item *item, struct se_device *dev = pr_to_dev(item); if (!dev->dev_attrib.emulate_pr || - (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) + (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) return 0; return sprintf(page, "APTPL Bit Status: %s\n", @@ -1823,7 +1823,7 @@ static ssize_t target_pr_res_aptpl_metadata_show(struct config_item *item, struct se_device *dev = pr_to_dev(item); if (!dev->dev_attrib.emulate_pr || - (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) + (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) return 0; return sprintf(page, "Ready to process PR APTPL metadata..\n"); @@ -1870,7 +1870,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item, u8 type = 0; if (!dev->dev_attrib.emulate_pr || - (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) + (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) return count; if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) return count; diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 4cee1138284b..d5800cf22df7 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -732,6 +732,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) dev->se_hba = hba; dev->transport = hba->backend->ops; + dev->transport_flags = dev->transport->transport_flags_default; dev->prot_length = sizeof(struct t10_pi_tuple); dev->hba_index = hba->hba_index; @@ -1100,7 +1101,7 @@ passthrough_parse_cdb(struct se_cmd *cmd, * emulate the response, since tcmu does not have the information * required to process these commands. */ - if (!(dev->transport->transport_flags & + if (!(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) { if (cdb[0] == PERSISTENT_RESERVE_IN) { cmd->execute_cmd = target_scsi3_emulate_pr_in; diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 5e931690e697..91e41cc55704 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -4086,7 +4086,7 @@ target_check_reservation(struct se_cmd *cmd) return 0; if (!dev->dev_attrib.emulate_pr) return 0; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) return 0; spin_lock(&dev->dev_reservation_lock); diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index c9d92b3e777d..4e37fa9b409d 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -1070,9 +1070,9 @@ static void pscsi_req_done(struct request *req, blk_status_t status) static const struct target_backend_ops pscsi_ops = { .name = "pscsi", .owner = THIS_MODULE, - .transport_flags = TRANSPORT_FLAG_PASSTHROUGH | - TRANSPORT_FLAG_PASSTHROUGH_ALUA | - TRANSPORT_FLAG_PASSTHROUGH_PGR, + .transport_flags_default = TRANSPORT_FLAG_PASSTHROUGH | + TRANSPORT_FLAG_PASSTHROUGH_ALUA | + TRANSPORT_FLAG_PASSTHROUGH_PGR, .attach_hba = pscsi_attach_hba, .detach_hba = pscsi_detach_hba, .pmode_enable_hba = pscsi_pmode_enable_hba, diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index d24e0a3ba3ff..62aa5fa63ac0 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -582,8 +582,7 @@ int core_tpg_add_lun( if (ret) goto out_kill_ref; - if (!(dev->transport->transport_flags & - TRANSPORT_FLAG_PASSTHROUGH_ALUA) && + if (!(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA) && !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) target_attach_tg_pt_gp(lun, dev->t10_alua.default_tg_pt_gp); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 594b724bbf79..e6b448f43071 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1397,7 +1397,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd) * Check if SAM Task Attribute emulation is enabled for this * struct se_device storage object */ - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) return 0; if (cmd->sam_task_attr == TCM_ACA_TAG) { @@ -2012,7 +2012,7 @@ static bool target_handle_task_attr(struct se_cmd *cmd) { struct se_device *dev = cmd->se_dev; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) return false; cmd->se_cmd_flags |= SCF_TASK_ATTR_SET; @@ -2126,7 +2126,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd) { struct se_device *dev = cmd->se_dev; - if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) return; if (!(cmd->se_cmd_flags & SCF_TASK_ATTR_SET)) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 8adde343182f..264f19ba8453 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -2617,7 +2617,7 @@ static struct configfs_attribute *tcmu_action_attrs[] = { static struct target_backend_ops tcmu_ops = { .name = "user", .owner = THIS_MODULE, - .transport_flags = TRANSPORT_FLAG_PASSTHROUGH, + .transport_flags_default = TRANSPORT_FLAG_PASSTHROUGH, .attach_hba = tcmu_attach_hba, .detach_hba = tcmu_detach_hba, .alloc_device = tcmu_alloc_device, diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 8177667eba6d..959163504f82 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -23,7 +23,7 @@ struct target_backend_ops { char inquiry_rev[4]; struct module *owner; - u8 transport_flags; + u8 transport_flags_default; int (*attach_hba)(struct se_hba *, u32); void (*detach_hba)(struct se_hba *); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 6d4a694f6ea7..18c3f277b770 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -772,6 +772,7 @@ struct se_device { #define DF_USING_UDEV_PATH 0x00000008 #define DF_USING_ALIAS 0x00000010 #define DF_READ_ONLY 0x00000020 + u8 transport_flags; /* Physical device queue depth */ u32 queue_depth; /* Used for SPC-2 reservations enforce of ISIDs */ From patchwork Mon Apr 27 15:08:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bodo Stroesser X-Patchwork-Id: 11512423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D8A092A for ; Mon, 27 Apr 2020 15:08:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0D8B206B9 for ; Mon, 27 Apr 2020 15:08:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ts.fujitsu.com header.i=@ts.fujitsu.com header.b="l516sYEG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728155AbgD0PIh (ORCPT ); Mon, 27 Apr 2020 11:08:37 -0400 Received: from mail1.bemta26.messagelabs.com ([85.158.142.114]:44634 "EHLO mail1.bemta26.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgD0PIh (ORCPT ); Mon, 27 Apr 2020 11:08:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ts.fujitsu.com; s=200619tsfj; t=1588000110; i=@ts.fujitsu.com; bh=Rq9kKJvJ+KUnaBACdIqakOgXHaMKu+Gez2U2aQLL1ME=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=l516sYEGIkEbfuxnNt/fu0YTQwI2dG5RbsTKZ+WomcygrsR0l+xX+DQi78PPiXdJ2 U3OIo+pJgALlpP11O2jphM1Xen8gbyhGxrNtzQBFeKpivcvoUUfiXG3XXKwqXsLOMK ATbz9KQVRmbDgFD3cvs0dbh3BzHRZCpoHCHj7aCGRjCkCjQVdWKlvwkVVjMu0i5oTj u7rZemaVQX3+lvvhYFxpANmQra2dmbXABBghOr8QpNnzgJgnAEc2eLI2egXUB8hspd 1/AQyqqoYRdF5J1tPt7vLF/ThXdG+a6sxSFqUiVs/cuXDlY3b/Ml3VRHnp5+ySaDYW RjvZerwriW1Aw== Received: from [100.113.6.103] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-3.bemta.az-b.eu-central-1.aws.symcld.net id 45/00-40390-E65F6AE5; Mon, 27 Apr 2020 15:08:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsViZ8MxVTfv67I 4g31veSy+/p/OYrFy9VEmi+7rO9gslh//x2Sx/sgGRovWpW+ZHNg8dt9sYPP4+PQWi8f7fVfZ PDafrvb4vEkugDWKNTMvKb8igTVj+adzbAVH1CoePLzB3MDYr9jFyMUhJDCZUaKhfQIThDOdU eLvv4XMXYycHGwCBhIrJt1nAbFFBGwk+g4vBStiFmhilLj1aj0bSEJYIELi2KN3QAkODhYBVY nN3+tBwrwCdhKzN35nBbElBOQlOg5MBpvDKWAvcebidTaQciGgmo8P9CYwci9gZFjFaJFUlJm eUZKbmJmja2hgoGtoaKxromtkpJdYpZukl1qqm5yaV1KUCJTUSywv1iuuzE3OSdHLSy3ZxAgM qpRCFrEdjLPWvtc7xCjJwaQkynty9bI4Ib6k/JTKjMTijPii0pzU4kOMMhwcShK8Uz8D5QSLU tNTK9Iyc4ABDpOW4OBREuFN+AKU5i0uSMwtzkyHSJ1iVJQS57UDSQiAJDJK8+DaYFF1iVFWSp iXkYGBQYinILUoN7MEVf4VozgHo5Iw7yyQ7TyZeSVw018BLWYCWlwlvxhkcUkiQkqqgcn977l WhphdJQq5X2Sn39Pe94Nhx+l3H41kF9obVGpL177eIyj65cdrK4PUfb80GDwimayKV2s/fX32 M7NDQ8XkH/enrDwm8PHb3zDmGSK/TeOf3fzspNeRdK9o97TjWSGcWcmXloosbVyXV2z0bIfUD ebkmH0Ru8+27etTTOb4d9Pp+Nf1551WnfmTpdH140v3pPSoOZFB8572dYhFqVutPpeS9uZl6m Tj38cNNDvc7UJrjl09cOZy/AerIzf3pZ/5IcyU633rjU5huftfpWduRduU3ByK54tr8mdzO/f Ea2cfc9l9tvfAFa8D7jqTMzP47h/Nk7p3JGXqhVdiL/8Ufr/67Hb2i+Kv7aXH18QqsRRnJBpq MRcVJwIADf/LmCUDAAA= X-Env-Sender: bstroesser@ts.fujitsu.com X-Msg-Ref: server-18.tower-238.messagelabs.com!1588000109!62717!1 X-Originating-IP: [62.60.8.149] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.50.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20793 invoked from network); 27 Apr 2020 15:08:30 -0000 Received: from unknown (HELO mailhost2.uk.fujitsu.com) (62.60.8.149) by server-18.tower-238.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Apr 2020 15:08:30 -0000 Received: from x-serv01 ([172.17.38.52]) by mailhost2.uk.fujitsu.com (8.14.5/8.14.5) with SMTP id 03RF8Qji013128; Mon, 27 Apr 2020 16:08:26 +0100 Received: from VTC.emeia.fujitsu.local (unknown [172.17.38.7]) by x-serv01 (Postfix) with ESMTP id 124A7208E4; Mon, 27 Apr 2020 17:08:26 +0200 (CEST) From: Bodo Stroesser To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: mchristi@redhat.com, ddiss@suse.de, hch@lst.de, martin.petersen@oracle.com, Bodo Stroesser Subject: [PATCH 4/4] target: tcmu: make pgr_support and alua_support attributes writable Date: Mon, 27 Apr 2020 17:08:23 +0200 Message-Id: <20200427150823.15350-5-bstroesser@ts.fujitsu.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20200427150823.15350-1-bstroesser@ts.fujitsu.com> References: <20200427150823.15350-1-bstroesser@ts.fujitsu.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Currently in tcmu reservation commands are handled by core's pr implementation (default) or completely rejected (emulate_pr set to 0). We additionally want to be able to do full reservation handling in userspace. Therefore we need a way to set the TRANSPORT_FLAG_PASSTHROUGH_PGR. The inverted flag is displayed by attribute pgr_support. Since we moved the flag from transport/backend to se_device in the previous patch, we now can make it changeable per device by allowing to write the attribute. The new field transport_flags_changeable in transport/backend is used to reject writing if not allowed for a backend. Regarding ALUA we also want to be able to passthrough commands to userspace in tcmu. Therefore we need TRANSPORT_FLAG_PASSTHROUGH_ALUA to be changeable, because by setting it we can switch off all ALUA checks in core. So we also set TRANSPORT_FLAG_PASSTHROUGH_ALUA in tcmu's transport_flags_changeable. Of course, ALUA and reservation handling in userspace will work only, if session/nexus information is sent to userspace along with every command. This will be object of a patch series announced by Mike Christie. Signed-off-by: Bodo Stroesser --- drivers/target/target_core_configfs.c | 56 +++++++++++++++++++++++++++++++++-- drivers/target/target_core_user.c | 2 ++ include/target/target_core_backend.h | 1 + 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 279989e32e64..f04352285155 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1105,6 +1105,32 @@ static ssize_t alua_support_show(struct config_item *item, char *page) flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ? 0 : 1); } +static ssize_t alua_support_store(struct config_item *item, + const char *page, size_t count) +{ + struct se_dev_attrib *da = to_attrib(item); + struct se_device *dev = da->da_dev; + bool flag; + int ret; + + if (!(dev->transport->transport_flags_changeable & + TRANSPORT_FLAG_PASSTHROUGH_ALUA)) { + pr_err("dev[%p]: Unable to change SE Device alua_support:" + " alua_support has fixed value\n", dev); + return -EINVAL; + } + + ret = strtobool(page, &flag); + if (ret < 0) + return ret; + + if (flag) + dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_ALUA; + else + dev->transport_flags |= TRANSPORT_FLAG_PASSTHROUGH_ALUA; + return count; +} + static ssize_t pgr_support_show(struct config_item *item, char *page) { struct se_dev_attrib *da = to_attrib(item); @@ -1114,6 +1140,32 @@ static ssize_t pgr_support_show(struct config_item *item, char *page) flags & TRANSPORT_FLAG_PASSTHROUGH_PGR ? 0 : 1); } +static ssize_t pgr_support_store(struct config_item *item, + const char *page, size_t count) +{ + struct se_dev_attrib *da = to_attrib(item); + struct se_device *dev = da->da_dev; + bool flag; + int ret; + + if (!(dev->transport->transport_flags_changeable & + TRANSPORT_FLAG_PASSTHROUGH_PGR)) { + pr_err("dev[%p]: Unable to change SE Device pgr_support:" + " pgr_support has fixed value\n", dev); + return -EINVAL; + } + + ret = strtobool(page, &flag); + if (ret < 0) + return ret; + + if (flag) + dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_PGR; + else + dev->transport_flags |= TRANSPORT_FLAG_PASSTHROUGH_PGR; + return count; +} + CONFIGFS_ATTR(, emulate_model_alias); CONFIGFS_ATTR(, emulate_dpo); CONFIGFS_ATTR(, emulate_fua_write); @@ -1146,8 +1198,8 @@ CONFIGFS_ATTR(, unmap_granularity); CONFIGFS_ATTR(, unmap_granularity_alignment); CONFIGFS_ATTR(, unmap_zeroes_data); CONFIGFS_ATTR(, max_write_same_len); -CONFIGFS_ATTR_RO(, alua_support); -CONFIGFS_ATTR_RO(, pgr_support); +CONFIGFS_ATTR(, alua_support); +CONFIGFS_ATTR(, pgr_support); /* * dev_attrib attributes for devices using the target core SBC/SPC diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 264f19ba8453..b02760b2e9c0 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -2618,6 +2618,8 @@ static struct target_backend_ops tcmu_ops = { .name = "user", .owner = THIS_MODULE, .transport_flags_default = TRANSPORT_FLAG_PASSTHROUGH, + .transport_flags_changeable = TRANSPORT_FLAG_PASSTHROUGH_PGR | + TRANSPORT_FLAG_PASSTHROUGH_ALUA, .attach_hba = tcmu_attach_hba, .detach_hba = tcmu_detach_hba, .alloc_device = tcmu_alloc_device, diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 959163504f82..f51452e3b984 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -24,6 +24,7 @@ struct target_backend_ops { struct module *owner; u8 transport_flags_default; + u8 transport_flags_changeable; int (*attach_hba)(struct se_hba *, u32); void (*detach_hba)(struct se_hba *);