From patchwork Mon Mar 30 03:28:20 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: 6118361 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AD16FBF4A6 for ; Mon, 30 Mar 2015 03:29:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A708C20357 for ; Mon, 30 Mar 2015 03:29:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 888EB2037D for ; Mon, 30 Mar 2015 03:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752879AbbC3D3q (ORCPT ); Sun, 29 Mar 2015 23:29:46 -0400 Received: from mail-oi0-f48.google.com ([209.85.218.48]:33187 "EHLO mail-oi0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752826AbbC3D3h (ORCPT ); Sun, 29 Mar 2015 23:29:37 -0400 Received: by oifl3 with SMTP id l3so117129287oif.0 for ; Sun, 29 Mar 2015 20:29:37 -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=oQr7zDe4umbQa61bv/eY7cNhKlfv4lp1spW27x4YOGw=; b=LXvRRs6veMc64R3ojArl3dKkCU/mX3razKh0DzwosNBrJiXqmEp97qPhnonkunMT6m 10gtNm4DkPAMsyujolQNYd6V77hEc+FvnQWOjX4k5DxUSa6Z9TJ5WTATnjE3sZh/gx+U Zj9wjg2udJt5FlJMRUzWbX2kKaVvQCIbql8/++joEhxe2yJ99wRulmey87j5YLspNuxq VmpWniMXuiOtKuE3GWRbETjCMoyPegXIofeRcnrDJAEN8R+L3Gh1cBaf3V+kcIAbzFnr nVQNPZGxWKzo2dEKMis99YRlWwNCnSJnFnkquDhHIIvG2dgHgePI/UCvgcUCShiqCzQT KObg== X-Gm-Message-State: ALoCoQl7IWr057NozQHhWZa4vSrGnX3mlJW9tm4mnsPds+3nn4abHtUQ6tdkpBg8IQBLpqq2zcGm X-Received: by 10.60.132.6 with SMTP id oq6mr10377988oeb.31.1427686176983; Sun, 29 Mar 2015 20:29:36 -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.36 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 29 Mar 2015 20:29:36 -0700 (PDT) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , "Martin K. Petersen" , Sagi Grimberg , Quinn Tran , Nicholas Bellinger , Hannes Reinecke Subject: [PATCH-v2 11/15] loopback: Add fabric_prot_type attribute support Date: Mon, 30 Mar 2015 03:28:20 +0000 Message-Id: <1427686104-14231-12-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 loopback 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. Also, go ahead and set DIN_PASS + DOUT_PASS so target-core knows that it will be doing any WRITE_STRIP and READ_INSERT operations. Cc: Martin Petersen Cc: Sagi Grimberg Cc: Hannes Reinecke Signed-off-by: Nicholas Bellinger --- drivers/target/loopback/tcm_loop.c | 54 ++++++++++++++++++++++++++++++++++++-- drivers/target/loopback/tcm_loop.h | 1 + 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index f4618e7..797c731 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -697,6 +697,13 @@ static int tcm_loop_check_prod_mode_write_protect(struct se_portal_group *se_tpg return 0; } +static int tcm_loop_check_prot_fabric_only(struct se_portal_group *se_tpg) +{ + struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, + tl_se_tpg); + return tl_tpg->tl_fabric_prot_type; +} + static struct se_node_acl *tcm_loop_tpg_alloc_fabric_acl( struct se_portal_group *se_tpg) { @@ -912,6 +919,46 @@ static void tcm_loop_port_unlink( /* End items for tcm_loop_port_cit */ +static ssize_t tcm_loop_tpg_attrib_show_fabric_prot_type( + struct se_portal_group *se_tpg, + char *page) +{ + struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, + tl_se_tpg); + + return sprintf(page, "%d\n", tl_tpg->tl_fabric_prot_type); +} + +static ssize_t tcm_loop_tpg_attrib_store_fabric_prot_type( + struct se_portal_group *se_tpg, + const char *page, + size_t count) +{ + struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, + tl_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 qla2xxx fabric_prot_type: %lu\n", val); + return -EINVAL; + } + tl_tpg->tl_fabric_prot_type = val; + + return count; +} + +TF_TPG_ATTRIB_ATTR(tcm_loop, fabric_prot_type, S_IRUGO | S_IWUSR); + +static struct configfs_attribute *tcm_loop_tpg_attrib_attrs[] = { + &tcm_loop_tpg_attrib_fabric_prot_type.attr, + NULL, +}; + /* Start items for tcm_loop_nexus_cit */ static int tcm_loop_make_nexus( @@ -937,7 +984,8 @@ static int tcm_loop_make_nexus( /* * Initialize the struct se_session pointer */ - tl_nexus->se_sess = transport_init_session(TARGET_PROT_ALL); + tl_nexus->se_sess = transport_init_session( + TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS); if (IS_ERR(tl_nexus->se_sess)) { ret = PTR_ERR(tl_nexus->se_sess); goto out; @@ -1377,6 +1425,8 @@ static int tcm_loop_register_configfs(void) &tcm_loop_check_demo_mode_write_protect; fabric->tf_ops.tpg_check_prod_mode_write_protect = &tcm_loop_check_prod_mode_write_protect; + fabric->tf_ops.tpg_check_prot_fabric_only = + &tcm_loop_check_prot_fabric_only; /* * The TCM loopback fabric module runs in demo-mode to a local * virtual SCSI device, so fabric dependent initator ACLs are @@ -1429,7 +1479,7 @@ static int tcm_loop_register_configfs(void) */ fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_loop_wwn_attrs; fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = tcm_loop_tpg_attrs; - fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = tcm_loop_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; /* diff --git a/drivers/target/loopback/tcm_loop.h b/drivers/target/loopback/tcm_loop.h index 6ae49f2..1e72ff7 100644 --- a/drivers/target/loopback/tcm_loop.h +++ b/drivers/target/loopback/tcm_loop.h @@ -43,6 +43,7 @@ struct tcm_loop_nacl { struct tcm_loop_tpg { unsigned short tl_tpgt; unsigned short tl_transport_status; + enum target_prot_type tl_fabric_prot_type; atomic_t tl_tpg_port_count; struct se_portal_group tl_se_tpg; struct tcm_loop_hba *tl_hba;