From patchwork Tue Jun 14 04:35:46 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: 9174967 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 9CE5B6048C for ; Tue, 14 Jun 2016 04:37:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 926E9281DB for ; Tue, 14 Jun 2016 04:37:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 874CE2821F; Tue, 14 Jun 2016 04:37:11 +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 26F2C281DB for ; Tue, 14 Jun 2016 04:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423155AbcFNEhG (ORCPT ); Tue, 14 Jun 2016 00:37:06 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:38564 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933464AbcFNEhC (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 2AF0322D9DD; Tue, 14 Jun 2016 04:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=linux-iscsi.org; s=default.private; t=1465878965; bh=Qvv2WJ/fFe8dleFgI00R3CUk9UCQ2X0 l0wgtBok0Dw4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References; b=MtxEjwveO8pSjBkw0WXwk1jWMhNopClf3gPZIYYFbh2I51S9PGfY LZvetg7dPGT0eYAWZxE4RkneBATf0N3y4RtsnL9hkAe9ZmtY7lbY5wjXr3oKoiia2Kd 2eZI6sTBiZa/1pz7UBGLMLpfvv/qYL+OQ7zcTe5GGSpwupwT8khI= 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 11/11] nvmet/loop: Add support for bio integrity handling Date: Tue, 14 Jun 2016 04:35:46 +0000 Message-Id: <1465878946-26556-12-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 adds support for nvme/loop block integrity, based upon the reported ID_NS.ms + ID_NS.dps feature bits in nvmet_execute_identify_ns(). 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/loop.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index e9f31d4..480a7ef 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -42,6 +42,7 @@ struct nvme_loop_iod { struct nvme_loop_queue *queue; struct work_struct work; struct sg_table sg_table; + struct scatterlist meta_sg; struct scatterlist first_sgl[]; }; @@ -201,6 +202,23 @@ static int nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx, BUG_ON(iod->req.sg_cnt > req->nr_phys_segments); } + if (blk_integrity_rq(req)) { + int count; + + if (blk_rq_count_integrity_sg(hctx->queue, req->bio) != 1) + BUG_ON(1); + + sg_init_table(&iod->meta_sg, 1); + count = blk_rq_map_integrity_sg(hctx->queue, req->bio, + &iod->meta_sg); + + iod->req.prot_sg = &iod->meta_sg; + iod->req.prot_sg_cnt = 1; + + pr_debug("nvme/loop: Set prot_sg %p and prot_sg_cnt: %d\n", + iod->req.prot_sg, iod->req.prot_sg_cnt); + } + iod->cmd.common.command_id = req->tag; blk_mq_start_request(req);