From patchwork Tue Nov 29 10:50:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 9451461 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 E494960710 for ; Tue, 29 Nov 2016 10:50:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDD4427F10 for ; Tue, 29 Nov 2016 10:50:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1BF92811E; Tue, 29 Nov 2016 10:50:32 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 7338127F10 for ; Tue, 29 Nov 2016 10:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755416AbcK2Kua (ORCPT ); Tue, 29 Nov 2016 05:50:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:57426 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753243AbcK2Ku3 (ORCPT ); Tue, 29 Nov 2016 05:50:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 66A40ABE7; Tue, 29 Nov 2016 10:50:27 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: boris.ostrovsky@oracle.com, lambert.quentin@gmail.com, linux-scsi@vger.kernel.org, dan.carpenter@oracle.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, Juergen Gross Subject: [PATCH] xen/scsifront: don't advance ring request pointer in case of error Date: Tue, 29 Nov 2016 11:50:13 +0100 Message-Id: <20161129105013.7419-1-jgross@suse.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161125202650.GK6266@mwanda> References: <20161125202650.GK6266@mwanda> 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 When allocating a new ring slot for a request don't advance the producer index until the request is really ready to go to the backend. Otherwise only partially filled requests will be visible to the backend in case of errors on the frontend side. In scsifront_action_handler() free the request id in case of an error. Signed-off-by: Juergen Gross --- In case accepted I'll take this patch through the Xen tree as it is based on another patch by lambert.quentin@gmail.com which is going through Xen, too. --- drivers/scsi/xen-scsifront.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index c01316c..33805f6 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -184,8 +184,6 @@ static struct vscsiif_request *scsifront_pre_req(struct vscsifrnt_info *info) ring_req = RING_GET_REQUEST(&(info->ring), ring->req_prod_pvt); - ring->req_prod_pvt++; - ring_req->rqid = (uint16_t)id; return ring_req; @@ -196,6 +194,8 @@ static void scsifront_do_request(struct vscsifrnt_info *info) struct vscsiif_front_ring *ring = &(info->ring); int notify; + ring->req_prod_pvt++; + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(ring, notify); if (notify) notify_remote_via_irq(info->irq); @@ -626,6 +626,7 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) } if (scsifront_enter(info)) { + scsifront_put_rqid(info, shadow->rqid); spin_unlock_irq(host->host_lock); kfree(shadow); return FAILED;