From patchwork Thu Aug 9 13:38:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 176132 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4EBBB2C00A3 for ; Fri, 10 Aug 2012 00:37:58 +1000 (EST) Received: from localhost ([::1]:34213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSy9-0003Ry-VJ for incoming@patchwork.ozlabs.org; Thu, 09 Aug 2012 09:40:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxe-0002eh-GS for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzSxX-0003sl-T2 for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:38 -0400 Received: from mail-gg0-f173.google.com ([209.85.161.173]:56441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxX-0003sh-Om for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:31 -0400 Received: by ggna5 with SMTP id a5so412233ggn.4 for ; Thu, 09 Aug 2012 06:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=AXMhIc+wLM2hDhxRaQTRf0WvzZ9kiEZacnCsZCBJB/o=; b=rHCnf755INx3blZQRsrRtl0Y7CyUQzijH4Qfex5QV0nn+hQFhQX+hsWtLPsYftL/Q3 zAXXKPWRku2kMSkFj2YygQTLZG0pJRo0INwPOo19B0zLCzbe/vg/QIPkG0B+4gepWwZz 8McebvD7aeg+85RUmG4flhqXsrPpdOod30AiK62LwcrAnJF3xu8M2IbJH9P3jhXroiwc W39P4qKmLSFb8OlLkYtmzbYQ0dMWOYZnjwEG2w8xfl88LP47LlA8BfbXKc81YwWHikB3 32MGWxEpcQ3EPCqx2Cw/ZCAAkQ7JKIi0HfZHOcoFYpTOov9ifIdfaNKywxANyHf8JFOf ChQg== Received: by 10.66.72.130 with SMTP id d2mr7835772pav.59.1344519570942; Thu, 09 Aug 2012 06:39:30 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id qa2sm788320pbb.21.2012.08.09.06.39.28 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Aug 2012 06:39:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2012 15:38:29 +0200 Message-Id: <1344519511-18147-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> References: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.161.173 Subject: [Qemu-devel] [PATCH 5/7] scsi-disk: more assertions and resets for aiocb X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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)) {