From patchwork Mon Mar 17 05:32:57 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: 3841461 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 EA9F09F44E for ; Mon, 17 Mar 2014 05:57:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BA7B201C0 for ; Mon, 17 Mar 2014 05:57:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20493201B4 for ; Mon, 17 Mar 2014 05:57:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753429AbaCQFzj (ORCPT ); Mon, 17 Mar 2014 01:55:39 -0400 Received: from mail-oa0-f42.google.com ([209.85.219.42]:33736 "EHLO mail-oa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753379AbaCQFzh (ORCPT ); Mon, 17 Mar 2014 01:55:37 -0400 Received: by mail-oa0-f42.google.com with SMTP id i4so5185424oah.1 for ; Sun, 16 Mar 2014 22:55:36 -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=FSW/kG4J0jTfjZW6EgC/pn7mZ2cNrsRFLJ09Ads/Bp8=; b=j58LMmgKmodxiDOncJ1dFnre8r13XPs62DzEOXIZl/1Ill+ihcNWeyWFACuVbFKVuR GD93/xFbS1XjdOyrSpIN6dvbctS7IbL34PhO9gQFdMbe9GJsvfVr48uS2fokK98+l3MP DVUXfXI753a7+SM1nr/SHlbBomVaKUGnsbUq8RImyPW2Z5t/qdo0GQVbcC+nEuaeSF7I 8tAgonOtOCp+KJsOZshLyzkouzcJCb6AA+2ZPh1syYV6n4bmfLRFf8ntxZO6aWPla+fj rnuUBFIM5xRxPzy5CLbuuoKNVS9GQ+r2YHcQqr8CdJqXuXNnVnBkNYHwBpjRxpPLFJeQ 2aiQ== X-Gm-Message-State: ALoCoQnJhlPaoOkvxp79WfBecfxeoVuwBOCA3ZdKh43dYckZf9J7Dwnei9PDg8zj1kOzYO89CfXn X-Received: by 10.182.153.226 with SMTP id vj2mr19298848obb.26.1395035736554; Sun, 16 Mar 2014 22:55:36 -0700 (PDT) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by mx.google.com with ESMTPSA id f9sm4915749obm.2.2014.03.16.22.55.35 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 16 Mar 2014 22:55:35 -0700 (PDT) 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 , "H. Peter Anvin" , Nicholas Bellinger Subject: [RFCv2 3/7] vhost/scsi: Add preallocation of protection SGLs Date: Mon, 17 Mar 2014 05:32:57 +0000 Message-Id: <1395034381-656-4-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1395034381-656-1-git-send-email-nab@daterainc.com> References: <1395034381-656-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 updates tcm_vhost_make_nexus() to pre-allocate per descriptor tcm_vhost_cmd->tvc_prot_sgl[] used to expose protection SGLs from within virtio-scsi guest memory to vhost-scsi. Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Nicholas Bellinger --- drivers/vhost/scsi.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 8c88ce9..a2cb289 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -58,6 +58,7 @@ #define TCM_VHOST_DEFAULT_TAGS 256 #define TCM_VHOST_PREALLOC_SGLS 2048 #define TCM_VHOST_PREALLOC_UPAGES 2048 +#define TCM_VHOST_PREALLOC_PROT_SGLS 512 struct vhost_scsi_inflight { /* Wait for the flush operation to finish */ @@ -83,6 +84,7 @@ struct tcm_vhost_cmd { u32 tvc_lun; /* Pointer to the SGL formatted memory from virtio-scsi */ struct scatterlist *tvc_sgl; + struct scatterlist *tvc_prot_sgl; struct page **tvc_upages; /* Pointer to response */ struct virtio_scsi_cmd_resp __user *tvc_resp; @@ -717,7 +719,7 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, struct tcm_vhost_cmd *cmd; struct tcm_vhost_nexus *tv_nexus; struct se_session *se_sess; - struct scatterlist *sg; + struct scatterlist *sg, *prot_sg; struct page **pages; int tag; @@ -736,10 +738,12 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[tag]; sg = cmd->tvc_sgl; + prot_sg = cmd->tvc_prot_sgl; pages = cmd->tvc_upages; memset(cmd, 0, sizeof(struct tcm_vhost_cmd)); cmd->tvc_sgl = sg; + cmd->tvc_prot_sgl = prot_sg; cmd->tvc_upages = pages; cmd->tvc_se_cmd.map_tag = tag; cmd->tvc_tag = v_req->tag; @@ -1692,6 +1696,7 @@ static void tcm_vhost_free_cmd_map_res(struct tcm_vhost_nexus *nexus, tv_cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[i]; kfree(tv_cmd->tvc_sgl); + kfree(tv_cmd->tvc_prot_sgl); kfree(tv_cmd->tvc_upages); } } @@ -1750,6 +1755,14 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tpg, pr_err("Unable to allocate tv_cmd->tvc_upages\n"); goto out; } + + tv_cmd->tvc_prot_sgl = kzalloc(sizeof(struct scatterlist) * + TCM_VHOST_PREALLOC_PROT_SGLS, GFP_KERNEL); + if (!tv_cmd->tvc_prot_sgl) { + mutex_unlock(&tpg->tv_tpg_mutex); + pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n"); + goto out; + } } /* * Since we are running in 'demo mode' this call with generate a