From patchwork Fri Feb 6 05:06:34 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: 5788611 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8C4059F30C for ; Fri, 6 Feb 2015 05:40:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0C3F2015E for ; Fri, 6 Feb 2015 05:40:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA2CB20155 for ; Fri, 6 Feb 2015 05:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751498AbbBFFju (ORCPT ); Fri, 6 Feb 2015 00:39:50 -0500 Received: from mail-ob0-f174.google.com ([209.85.214.174]:33041 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752AbbBFFjr (ORCPT ); Fri, 6 Feb 2015 00:39:47 -0500 Received: by mail-ob0-f174.google.com with SMTP id wo20so11240828obc.5 for ; Thu, 05 Feb 2015 21:39:46 -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=BIbbXnm2rlItgHqcrzpgQQ6varvTADQW2+D8OM84mS4=; b=PFW9xf4FeSQoJF0BSGKhauuHEGqC0dC1QsocEuMO0Qak6rx6zM8swWblmcPs38xHI2 TliHlET1Yi6sfwpN9rry+rq5CvOsSYjL9h64p+kFbxV15GqoTZ+0wYia+RnUQMxPjIjO kYVmXNiyrYCwkLv515eLFkzbDJ1h0g8LdUhWrwc/dY83gGOff98rweRfn+0WgRIBagyK BfloXr6Eh37+2uAx421732tcCTfE/ZxRk8CiUCiWqBPbSHl1xJfWz2hHei5g1l51/r27 lRhNCwKO1X2wZNNtuA3FPsoQmBNJpLD6HNKz+y1A/MhS64obTzeNKWCwi1dMcaQxIw2w dBmw== X-Gm-Message-State: ALoCoQmtUOdPN5xN06nqgnnCi+w+KneKOLA+nzh1YFvC7JDo9q8wT50KZPZcnu1RXtQ++5stA2kv X-Received: by 10.202.172.197 with SMTP id v188mr1237575oie.48.1423201186434; Thu, 05 Feb 2015 21:39:46 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by mx.google.com with ESMTPSA id x8sm800393obg.18.2015.02.05.21.39.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Feb 2015 21:39:46 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , kvm-devel , Paolo Bonzini , "Michael S. Tsirkin" , Al Viro , Christoph Hellwig , Nicholas Bellinger , Al Viro Subject: [PATCH-v4 1/8] vhost/scsi: Convert completion path to use copy_to_iter Date: Fri, 6 Feb 2015 05:06:34 +0000 Message-Id: <1423199201-14659-2-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1423199201-14659-1-git-send-email-nab@daterainc.com> References: <1423199201-14659-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=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 Required for ANY_LAYOUT support when the incoming virtio-scsi response header + fixed size sense buffer payload may span more than a single iovec entry. This changes existing code to save cmd->tvc_resp_iov instead of the first single iovec base pointer from &vq->iov[out]. Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Al Viro Signed-off-by: Nicholas Bellinger --- drivers/vhost/scsi.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 01c01cb..29dfdf6 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -72,6 +72,8 @@ struct tcm_vhost_cmd { int tvc_vq_desc; /* virtio-scsi initiator task attribute */ int tvc_task_attr; + /* virtio-scsi response incoming iovecs */ + int tvc_in_iovs; /* virtio-scsi initiator data direction */ enum dma_data_direction tvc_data_direction; /* Expected data transfer length from virtio-scsi header */ @@ -87,8 +89,8 @@ struct tcm_vhost_cmd { struct scatterlist *tvc_sgl; struct scatterlist *tvc_prot_sgl; struct page **tvc_upages; - /* Pointer to response */ - struct virtio_scsi_cmd_resp __user *tvc_resp; + /* Pointer to response header iovec */ + struct iovec *tvc_resp_iov; /* Pointer to vhost_scsi for our device */ struct vhost_scsi *tvc_vhost; /* Pointer to vhost_virtqueue for the cmd */ @@ -682,6 +684,7 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work) struct tcm_vhost_cmd *cmd; struct llist_node *llnode; struct se_cmd *se_cmd; + struct iov_iter iov_iter; int ret, vq; bitmap_zero(signal, VHOST_SCSI_MAX_VQ); @@ -703,8 +706,11 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work) se_cmd->scsi_sense_length); memcpy(v_rsp.sense, cmd->tvc_sense_buf, se_cmd->scsi_sense_length); - ret = copy_to_user(cmd->tvc_resp, &v_rsp, sizeof(v_rsp)); - if (likely(ret == 0)) { + + iov_iter_init(&iov_iter, READ, cmd->tvc_resp_iov, + cmd->tvc_in_iovs, sizeof(v_rsp)); + ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter); + if (likely(ret == sizeof(v_rsp))) { struct vhost_scsi_virtqueue *q; vhost_add_used(cmd->tvc_vq, cmd->tvc_vq_desc, 0); q = container_of(cmd->tvc_vq, struct vhost_scsi_virtqueue, vq); @@ -1159,7 +1165,8 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) cmd->tvc_vhost = vs; cmd->tvc_vq = vq; - cmd->tvc_resp = vq->iov[out].iov_base; + cmd->tvc_resp_iov = &vq->iov[out]; + cmd->tvc_in_iovs = in; pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n", cmd->tvc_cdb[0], cmd->tvc_lun);