From patchwork Mon Feb 24 05:32:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 3706391 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 592A89F35F for ; Mon, 24 Feb 2014 05:56:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 87FD520160 for ; Mon, 24 Feb 2014 05:56:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9710B2015A for ; Mon, 24 Feb 2014 05:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752114AbaBXFyc (ORCPT ); Mon, 24 Feb 2014 00:54:32 -0500 Received: from mail-oa0-f54.google.com ([209.85.219.54]:36618 "EHLO mail-oa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbaBXFyY (ORCPT ); Mon, 24 Feb 2014 00:54:24 -0500 Received: by mail-oa0-f54.google.com with SMTP id m1so792645oag.27 for ; Sun, 23 Feb 2014 21:54:24 -0800 (PST) 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=AjZD/2+6balOeMYKXxsSpycwLMl5gBrZL1XT55y2upE=; b=bQO/EYE8CIeadLkzvcPXHnLPOp5S62b4YLJ5uBn2kk4+pk6YN3rXWuKuPFay976dp1 coqLrP1Q2+ELfxSSJ+bITri0g9jpxfX8jrICD1619ypO/RIhZ37wlD+JQiyFkZ7Xj52o 7VziQc5z4jql29+9RNpeqXVSRW/9M8uyBSMJuhM0iLxOAJdBAVFOJrAH7IpVJMWnOJnv cScmVx9RaaiUMePbMe6lPh7FljUBP+gAiE89UCKVAhrh13+FwsEEShcSuIST+Ll2pAkn V/4jECzV1mWusmOd0pJefy6ZtSNhTyQW3apZQ//9nHF6x0Z+zcHQIovQreRWQD2Z88WM T4hw== X-Gm-Message-State: ALoCoQmtCFIureNeLb8L4MCj3LvbR1hm6P1HzsSa7ilyCgQMhrsE1Tk9L+izJ5ZPd/fcZHeeTZft X-Received: by 10.60.60.33 with SMTP id e1mr19925053oer.36.1393221263975; Sun, 23 Feb 2014 21:54:23 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by mx.google.com with ESMTPSA id tr10sm31941566obb.6.2014.02.23.21.54.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 23 Feb 2014 21:54:23 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , linux-kernel , kvm-devel , "Michael S. Tsirkin" , Paolo Bonzini , "Martin K. Petersen" , Christoph Hellwig , Hannes Reinecke , Sagi Grimberg , Nicholas Bellinger , Sagi Grimberg Subject: [RFC 3/6] vhost/scsi: Add T10 PI IOV -> SGL memory mapping logic Date: Mon, 24 Feb 2014 05:32:27 +0000 Message-Id: <1393219950-18613-4-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1393219950-18613-1-git-send-email-nab@daterainc.com> References: <1393219950-18613-1-git-send-email-nab@daterainc.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 adds vhost_scsi_map_iov_to_prot() to perform the mapping of T10 data integrity memory between virtio iov + struct scatterlist using get_user_pages_fast() following existing code. As with vhost_scsi_map_iov_to_sgl(), this does sanity checks against the total prot_sgl_count vs. pre-allocated SGLs, and loops across protection iovs using vhost_scsi_map_to_sgl() to perform the actual memory mapping. Also update tcm_vhost_release_cmd() to release associated tvc_prot_sgl[] struct page. Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Sagi Grimberg Signed-off-by: Nicholas Bellinger --- drivers/vhost/scsi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 314cbd4..0cf5948 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -80,6 +80,7 @@ struct tcm_vhost_cmd { u64 tvc_tag; /* The number of scatterlists associated with this cmd */ u32 tvc_sgl_count; + u32 tvc_prot_sgl_count; /* Saved unpacked SCSI LUN for tcm_vhost_submission_work() */ u32 tvc_lun; /* Pointer to the SGL formatted memory from virtio-scsi */ @@ -458,12 +459,16 @@ static void tcm_vhost_release_cmd(struct se_cmd *se_cmd) struct tcm_vhost_cmd *tv_cmd = container_of(se_cmd, struct tcm_vhost_cmd, tvc_se_cmd); struct se_session *se_sess = se_cmd->se_sess; + int i; if (tv_cmd->tvc_sgl_count) { - u32 i; for (i = 0; i < tv_cmd->tvc_sgl_count; i++) put_page(sg_page(&tv_cmd->tvc_sgl[i])); } + if (tv_cmd->tvc_prot_sgl_count) { + for (i = 0; i < tv_cmd->tvc_prot_sgl_count; i++) + put_page(sg_page(&tv_cmd->tvc_prot_sgl[i])); + } tcm_vhost_put_inflight(tv_cmd->inflight); percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);