From patchwork Wed Jun 8 13:48:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 99432 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 581F0B6FD6 for ; Thu, 9 Jun 2011 00:09:23 +1000 (EST) Received: from localhost ([::1]:42290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUJRf-0002VJ-RM for incoming@patchwork.ozlabs.org; Wed, 08 Jun 2011 10:09:20 -0400 Received: from eggs.gnu.org ([140.186.70.92]:36791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUJ53-0005eS-KZ for qemu-devel@nongnu.org; Wed, 08 Jun 2011 09:45:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QUJ4z-00005s-ET for qemu-devel@nongnu.org; Wed, 08 Jun 2011 09:45:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUJ4y-00005E-LZ for qemu-devel@nongnu.org; Wed, 08 Jun 2011 09:45:52 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p58DjnvV005533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 8 Jun 2011 09:45:49 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p58DjcfJ007654; Wed, 8 Jun 2011 09:45:48 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Wed, 8 Jun 2011 15:48:26 +0200 Message-Id: <1307540910-12398-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1307540910-12398-1-git-send-email-kwolf@redhat.com> References: <1307540910-12398-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 08/12] rbd: check return values when scheduling aio 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 From: Josh Durgin If scheduling fails, the number of outstanding I/Os must be correct, or there will be a hang when waiting for everything to be flushed. Reviewed-by: Christian Brunner Reported-by: Stefan Hajnoczi Signed-off-by: Josh Durgin Signed-off-by: Kevin Wolf --- block/rbd.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index edf1086..f4da6ab 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -581,10 +581,14 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs, rbd_completion_t c; int64_t off, size; char *buf; + int r; BDRVRBDState *s = bs->opaque; acb = qemu_aio_get(&rbd_aio_pool, bs, cb, opaque); + if (!acb) { + return NULL; + } acb->write = write; acb->qiov = qiov; acb->bounce = qemu_blockalign(bs, qiov->size); @@ -611,16 +615,28 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs, rcb->buf = buf; rcb->s = acb->s; rcb->size = size; + r = rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c); + if (r < 0) { + goto failed; + } if (write) { - rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c); - rbd_aio_write(s->image, off, size, buf, c); + r = rbd_aio_write(s->image, off, size, buf, c); } else { - rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c); - rbd_aio_read(s->image, off, size, buf, c); + r = rbd_aio_read(s->image, off, size, buf, c); + } + + if (r < 0) { + goto failed; } return &acb->common; + +failed: + qemu_free(rcb); + s->qemu_aio_count--; + qemu_aio_release(acb); + return NULL; } static BlockDriverAIOCB *qemu_rbd_aio_readv(BlockDriverState *bs,