From patchwork Tue Jun 14 04:35:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 9174965 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 4E2486048C for ; Tue, 14 Jun 2016 04:37:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 438E1281DB for ; Tue, 14 Jun 2016 04:37:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 386312821F; Tue, 14 Jun 2016 04:37:10 +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=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, URIBL_BLACK 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 CD197281DB for ; Tue, 14 Jun 2016 04:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423561AbcFNEhH (ORCPT ); Tue, 14 Jun 2016 00:37:07 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:38552 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933196AbcFNEhC (ORCPT ); Tue, 14 Jun 2016 00:37:02 -0400 Received: from linux-iscsi.org (localhost [127.0.0.1]) by linux-iscsi.org (Postfix) with ESMTP id 3719B22D9DC; Tue, 14 Jun 2016 04:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=linux-iscsi.org; s=default.private; t=1465878964; bh=bR8pOZe7k4qazazbQtJKNhUxJ7KEjZT 3r1RPu9/eLCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References; b=JRflaw/i+R5wsaXC8flgrCMBgoQu6qo+uU5VYvsYA3nH5pCRp/8B 4vIM6gpKGyAyyvSRCJrGpxPHnLJFWg0i41n7uioARFaFc9yAnRE9aKbHE7+1yPNTt2u KmaYsUsf7NKK43RS9VopfX8B+79Ig7sQiAKPdhXs0EKH5U3r59CM= From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , linux-nvme , Jens Axboe , Christoph Hellwig , Keith Busch , Jay Freyensee , Martin Petersen , Sagi Grimberg , Hannes Reinecke , Mike Christie , Dave B Minturn , Nicholas Bellinger Subject: [RFC-v2 10/11] nvmet/admin-cmd: Hookup T10-PI to ID_NS.ms + ID_NS.dps feature bits Date: Tue, 14 Jun 2016 04:35:45 +0000 Message-Id: <1465878946-26556-11-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1465878946-26556-1-git-send-email-nab@linux-iscsi.org> References: <1465878946-26556-1-git-send-email-nab@linux-iscsi.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger This patch updates nvmet_execute_identify_ns() to report target-core backend T10-PI related feature bits to the NVMe host controller. Note this assumes support for NVME_NS_DPC_PI_TYPE1 and NVME_NS_DPC_PI_TYPE3 as reported by backend drivers via /sys/kernel/config/target/core/*/*/attrib/pi_prot_type. Cc: Jens Axboe Cc: Christoph Hellwig Cc: Martin Petersen Cc: Sagi Grimberg Cc: Hannes Reinecke Cc: Mike Christie Signed-off-by: Nicholas Bellinger --- drivers/nvme/target/admin-cmd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index 240e323..3a808dc 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -200,6 +200,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) { struct nvmet_ns *ns; struct nvme_id_ns *id; + struct se_device *dev; u16 status = 0; ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid); @@ -228,6 +229,22 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) id->nlbaf = 0; id->flbas = 0; + /* Populate bits for T10-PI from se_device backend */ + rcu_read_lock(); + dev = rcu_dereference(ns->dev); + if (dev && dev->dev_attrib.pi_prot_type) { + int pi_prot_type = dev->dev_attrib.pi_prot_type; + + id->lbaf[0].ms = cpu_to_le16(sizeof(struct t10_pi_tuple)); + printk("nvmet_set_id_ns: ms: %u\n", id->lbaf[0].ms); + + if (pi_prot_type == 1) + id->dps = NVME_NS_DPC_PI_TYPE1; + else if (pi_prot_type == 3) + id->dps = NVME_NS_DPC_PI_TYPE3; + } + rcu_read_unlock(); + /* * Our namespace might always be shared. Not just with other * controllers, but also with any other user of the block device.