All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
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 <jgross@suse.com>
Subject: [PATCH] xen/scsifront: don't advance ring request pointer in case of error
Date: Tue, 29 Nov 2016 11:50:13 +0100	[thread overview]
Message-ID: <20161129105013.7419-1-jgross@suse.com> (raw)
In-Reply-To: <20161125202650.GK6266@mwanda>

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 <jgross@suse.com>
---
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;
-- 
2.10.2


  reply	other threads:[~2016-11-29 10:50 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-19 18:22 [PATCH] xen-scsifront: Add a missing call to kfree Quentin Lambert
2016-11-19 18:22 ` Quentin Lambert
2016-11-21  6:01 ` Juergen Gross
2016-11-21  6:01   ` Juergen Gross
2016-11-22  3:40   ` Martin K. Petersen
2016-11-22  3:40     ` Martin K. Petersen
2016-11-22  5:19     ` Juergen Gross
2016-11-22  5:19       ` Juergen Gross
2016-11-25 21:28   ` Dan Carpenter
2016-11-25 21:28     ` Dan Carpenter
2016-11-29 10:50     ` Juergen Gross [this message]
2016-11-29 11:14       ` [Xen-devel] [PATCH] xen/scsifront: don't advance ring request pointer in case of error Jan Beulich
2016-11-29 11:14         ` Jan Beulich
     [not found]       ` <583D712F0200007800123283@suse.com>
2016-11-29 11:19         ` Juergen Gross
2016-11-29 11:28           ` David Vrabel
2016-11-29 11:28             ` [Xen-devel] " David Vrabel
2016-11-29 11:33             ` Juergen Gross
2016-11-29 11:40           ` Jan Beulich
2016-11-29 11:40             ` Jan Beulich
     [not found]           ` <583D772D02000078001232DD@suse.com>
2016-11-29 12:33             ` Juergen Gross
2016-12-02  6:10     ` [PATCH v2] xen/scsifront: don't request a slot on the ring until request is ready Juergen Gross
2016-12-02  6:13     ` Juergen Gross
2016-12-02  6:15     ` Juergen Gross
2016-12-05 15:32       ` Boris Ostrovsky
2016-12-05 15:32         ` Boris Ostrovsky
2016-12-05 15:35         ` Juergen Gross
2016-12-08 14:56       ` Boris Ostrovsky
2016-12-09 10:13       ` Juergen Gross
2016-12-05 20:53   ` [PATCH] xen-scsifront: Add a missing call to kfree Dan Carpenter
2016-12-05 20:53     ` Dan Carpenter
2016-12-06  5:45     ` Juergen Gross
2016-12-06  5:45       ` Juergen Gross
2016-12-06 10:22       ` Dan Carpenter
2016-12-06 10:22         ` Dan Carpenter
2016-12-06 10:22         ` Dan Carpenter
2016-11-24  8:24 ` Juergen Gross
2016-11-24  8:24   ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161129105013.7419-1-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=lambert.quentin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.