From 2505dd4bc489fd1fc411421451f866535eee6d6c Mon Sep 17 00:00:00 2001 Message-Id: <2505dd4bc489fd1fc411421451f866535eee6d6c.1346668737.git.minovotn@redhat.com> In-Reply-To: References: From: Paolo Bonzini Date: Mon, 27 Aug 2012 13:42:10 +0200 Subject: [PATCH 07/10] scsi-disk: more assertions and resets for aiocb RH-Author: Paolo Bonzini Message-id: <1346074931-12083-7-git-send-email-pbonzini@redhat.com> Patchwork-id: 41332 O-Subject: [RHEL 6.4 qemu-kvm PATCH 6/7] scsi-disk: more assertions and resets for aiocb Bugzilla: 808664 RH-Acked-by: Gerd Hoffmann RH-Acked-by: Markus Armbruster RH-Acked-by: Orit Wasserman Bugzilla: 808664, 805501 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 (cherry picked from commit 46e3f30e3c81e23c07f16b2193dfb6928646c205) --- hw/scsi-disk.c | 16 ++++++++-------- 1 file modificato, 8 inserzioni(+), 8 rimozioni(-) Signed-off-by: Michal Novotny --- hw/scsi-disk.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 876449d..f0c13b8 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -155,6 +155,8 @@ static void scsi_flush_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) { @@ -218,10 +220,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)) { @@ -250,10 +251,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.4