From patchwork Mon Mar 30 03:28:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 6118341 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E316D9F1BE for ; Mon, 30 Mar 2015 03:29:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CEA652037C for ; Mon, 30 Mar 2015 03:29:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7511720357 for ; Mon, 30 Mar 2015 03:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752865AbbC3D3l (ORCPT ); Sun, 29 Mar 2015 23:29:41 -0400 Received: from mail-oi0-f54.google.com ([209.85.218.54]:36829 "EHLO mail-oi0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752860AbbC3D3j (ORCPT ); Sun, 29 Mar 2015 23:29:39 -0400 Received: by oicf142 with SMTP id f142so107798049oic.3 for ; Sun, 29 Mar 2015 20:29:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OOWp0wRDTU1AyLYn32I0CuAdCVIMqeCz2+QlFH0mPu8=; b=jUq1iQJC02Io9vHu8tsQMoTX1eGH6dvr/+A9uFvS+gnxTqIVdO5nEazFzW8cCFuykU Ui2Mggilk9NVUoeIgZkHonLJ5cM76WrIAj9Pw3dCTZoTxPfhObXpQiFH5r2CZkqW96db 2rQLF2dZZI/AQZ8zDoiBnKCKj46BMxYSoLMFqz0qDZ0M7LJ+TgkIyL0ije3L3JMKRH0r iCDqA87Mi2nOjmH4uesm3aCUYl55zOdz/7uS74+KCE6bo3ei5izig/SEMmfC2HeXeg2S jfFWWoBTFBQl5txpYM78MokNyuyyyLwJzon9md9OMOAVug3Z091Wdupe2Y32GzPSHsqZ VLUQ== X-Gm-Message-State: ALoCoQkuNtvnCUBm8SVKvBe7CY6AK+DDzxAd3AO7bocXTID89gaV7kqBTZvko8hf47MYqwqlbU2z X-Received: by 10.202.82.76 with SMTP id g73mr3403444oib.118.1427686178630; Sun, 29 Mar 2015 20:29:38 -0700 (PDT) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by mx.google.com with ESMTPSA id wc6sm5439898obc.8.2015.03.29.20.29.37 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 29 Mar 2015 20:29:38 -0700 (PDT) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , "Martin K. Petersen" , Sagi Grimberg , Quinn Tran , Nicholas Bellinger , "Michael S. Tsirkin" Subject: [PATCH-v2 12/15] vhost/scsi: Add fabric_prot_type attribute support Date: Mon, 30 Mar 2015 03:28:21 +0000 Message-Id: <1427686104-14231-13-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1427686104-14231-1-git-send-email-nab@daterainc.com> References: <1427686104-14231-1-git-send-email-nab@daterainc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger This patch updates vhost-scsi to add a new fabric_prot_type TPG attribute, used for controlling LLD level protection into LIO when the backend device does not support T10-PI. This is required for vhost-scsi to enable WRITE_STRIP + READ_INSERT operations using software emulation + crct10dif instruction offload. It's disabled by default and controls which se_sesion->sess_prot_type are set at vhost_scsi_make_nexus() session registration time. Cc: Michael S. Tsirkin Cc: Martin Petersen Cc: Sagi Grimberg Signed-off-by: Nicholas Bellinger --- drivers/vhost/scsi.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 8d4f3f1..27ed964 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -131,6 +131,8 @@ struct vhost_scsi_tpg { int tv_tpg_port_count; /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */ int tv_tpg_vhost_count; + /* Used for enabling T10-PI with legacy devices */ + int tv_fabric_prot_type; /* list for vhost_scsi_list */ struct list_head tv_tpg_list; /* Used to protect access for tpg_nexus */ @@ -431,6 +433,14 @@ vhost_scsi_parse_pr_out_transport_id(struct se_portal_group *se_tpg, port_nexus_ptr); } +static int vhost_scsi_check_prot_fabric_only(struct se_portal_group *se_tpg) +{ + struct vhost_scsi_tpg *tpg = container_of(se_tpg, + struct vhost_scsi_tpg, se_tpg); + + return tpg->tv_fabric_prot_type; +} + static struct se_node_acl * vhost_scsi_alloc_fabric_acl(struct se_portal_group *se_tpg) { @@ -1878,6 +1888,45 @@ static void vhost_scsi_free_cmd_map_res(struct vhost_scsi_nexus *nexus, } } +static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type( + struct se_portal_group *se_tpg, + const char *page, + size_t count) +{ + struct vhost_scsi_tpg *tpg = container_of(se_tpg, + struct vhost_scsi_tpg, se_tpg); + unsigned long val; + int ret = kstrtoul(page, 0, &val); + + if (ret) { + pr_err("kstrtoul() returned %d for fabric_prot_type\n", ret); + return ret; + } + if (val != 0 && val != 1 && val != 3) { + pr_err("Invalid vhost_scsi fabric_prot_type: %lu\n", val); + return -EINVAL; + } + tpg->tv_fabric_prot_type = val; + + return count; +} + +static ssize_t vhost_scsi_tpg_attrib_show_fabric_prot_type( + struct se_portal_group *se_tpg, + char *page) +{ + struct vhost_scsi_tpg *tpg = container_of(se_tpg, + struct vhost_scsi_tpg, se_tpg); + + return sprintf(page, "%d\n", tpg->tv_fabric_prot_type); +} +TF_TPG_ATTRIB_ATTR(vhost_scsi, fabric_prot_type, S_IRUGO | S_IWUSR); + +static struct configfs_attribute *vhost_scsi_tpg_attrib_attrs[] = { + &vhost_scsi_tpg_attrib_fabric_prot_type.attr, + NULL, +}; + static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg, const char *name) { @@ -2290,6 +2339,7 @@ static struct target_core_fabric_ops vhost_scsi_ops = { .tpg_check_demo_mode_cache = vhost_scsi_check_true, .tpg_check_demo_mode_write_protect = vhost_scsi_check_false, .tpg_check_prod_mode_write_protect = vhost_scsi_check_false, + .tpg_check_prot_fabric_only = vhost_scsi_check_prot_fabric_only, .tpg_alloc_fabric_acl = vhost_scsi_alloc_fabric_acl, .tpg_release_fabric_acl = vhost_scsi_release_fabric_acl, .tpg_get_inst_index = vhost_scsi_tpg_get_inst_index, @@ -2348,7 +2398,7 @@ static int vhost_scsi_register_configfs(void) */ fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = vhost_scsi_wwn_attrs; fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = vhost_scsi_tpg_attrs; - fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = vhost_scsi_tpg_attrib_attrs; fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;