From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 5/7] scsi-disk: more assertions and resets for aiocb
Date: Thu, 9 Aug 2012 15:38:29 +0200 [thread overview]
Message-ID: <1344519511-18147-6-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1344519511-18147-1-git-send-email-pbonzini@redhat.com>
Leaving the aiocb to a non-NULL value leads to an assertion failure when
rerror/werror are set to stop or enospc, and the operation is retried.
scsi-disk checks that the aiocb member is NULL before filling it.
This patch correctly resets the aiocb to NULL values everywhere,
and adds the dual assertion that the aiocb was non-NULL before
calling bdrv_acct_done.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi-disk.c | 16 ++++++++--------
1 file modificato, 8 inserzioni(+), 8 rimozioni(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a9c7279..3baa238 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -175,6 +175,8 @@ static void scsi_aio_complete(void *opaque, int ret)
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
+ assert(r->req.aiocb != NULL);
+ r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (ret < 0) {
@@ -238,10 +240,9 @@ static void scsi_dma_complete(void *opaque, int ret)
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
- if (r->req.aiocb != NULL) {
- r->req.aiocb = NULL;
- bdrv_acct_done(s->qdev.conf.bs, &r->acct);
- }
+ assert(r->req.aiocb != NULL);
+ r->req.aiocb = NULL;
+ bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
@@ -270,10 +271,9 @@ static void scsi_read_complete(void * opaque, int ret)
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
int n;
- if (r->req.aiocb != NULL) {
- r->req.aiocb = NULL;
- bdrv_acct_done(s->qdev.conf.bs, &r->acct);
- }
+ assert(r->req.aiocb != NULL);
+ r->req.aiocb = NULL;
+ bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
--
1.7.11.2
next prev parent reply other threads:[~2012-08-09 13:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-09 13:38 [Qemu-devel] [PULL 0/7] last SCSI changes for 1.2 Paolo Bonzini
2012-08-09 13:38 ` [Qemu-devel] [PATCH 1/7] iscsi: do not leak initiator_name Paolo Bonzini
2012-08-09 13:38 ` [Qemu-devel] [PATCH 2/7] iscsi: reorganize code for parse_initiator_name Paolo Bonzini
2012-08-09 13:38 ` [Qemu-devel] [PATCH 3/7] iscsi: Pick default initiator-name based on the name of the VM Paolo Bonzini
2012-08-09 13:38 ` [Qemu-devel] [PATCH 4/7] virtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags Paolo Bonzini
2012-08-09 13:38 ` Paolo Bonzini [this message]
2012-08-09 17:16 ` [Qemu-devel] [PATCH 5/7] scsi-disk: more assertions and resets for aiocb Michael Tokarev
2012-08-09 18:07 ` Paolo Bonzini
2012-08-09 13:38 ` [Qemu-devel] [PATCH 6/7] scsi-disk: improve out-of-range LBA detection for WRITE SAME Paolo Bonzini
2012-08-09 13:38 ` [Qemu-devel] [PATCH 7/7] scsi-disk: add support for the UNMAP command Paolo Bonzini
2012-08-11 22:33 ` [Qemu-devel] [PULL 0/7] last SCSI changes for 1.2 Anthony Liguori
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=1344519511-18147-6-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).