From patchwork Wed Apr 13 00:45:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Durgin X-Patchwork-Id: 702451 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3D0l9Bg002090 for ; Wed, 13 Apr 2011 00:47:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932732Ab1DMArG (ORCPT ); Tue, 12 Apr 2011 20:47:06 -0400 Received: from mail.hq.newdream.net ([66.33.206.127]:49710 "EHLO mail.hq.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932579Ab1DMArE (ORCPT ); Tue, 12 Apr 2011 20:47:04 -0400 Received: from mail.hq.newdream.net (localhost [127.0.0.1]) by mail.hq.newdream.net (Postfix) with ESMTP id BB557C068; Tue, 12 Apr 2011 17:47:03 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=dreamhost.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:in-reply-to :references; q=dns; s=dreamhost.com; b=ItLiX+1fF6QJF3TpK/EQfumZ6 bssVJRlRtkm0xfyZIdzHQI20/eOyWSKfd4+/g9NPvTAzPyc66Uyw34sXp5FCYBQT J8FFqXJVRCK4d0nLnROrQk7r1yV+Rj7CneC7oNUXKsyOK8m/TYgg8LhNJ+EFz17o M9yQhFXX0x2ehj+cEo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=dreamhost.com; h=from:to :cc:subject:date:message-id:in-reply-to:references:in-reply-to :references; s=dreamhost.com; bh=mcQnZNDJZECULBL/rNGj9maloV0=; b= KIEO1NLeO/gDPb/hmTGz9I8q6e376oZibzv6LZf7BlcRHEuntn7igvSNyS++a0i1 +oPdwpS03X5RoCDtBidoZT1a4q7lwpGOVZdEhHouSjtYrGLirRTvqjnRqummTPBr WxfqVQoZ3nbTibMkJrOpzEXmye6efOE89UIqIH6AVR4= Received: from pudgy.ops.newdream.net (ip-66-33-206-8.dreamhost.com [66.33.206.8]) by mail.hq.newdream.net (Postfix) with ESMTP id B640EC062; Tue, 12 Apr 2011 17:47:03 -0700 (PDT) From: Josh Durgin To: kvm@vger.kernel.org, qemu-devel@nongnu.org Cc: ceph-devel@vger.kernel.org, Kevin Wolf Subject: [PATCH v3 3/4] rbd: check return values when scheduling aio Date: Tue, 12 Apr 2011 17:45:25 -0700 Message-Id: X-Mailer: git-send-email 1.7.2.3 In-Reply-To: References: In-Reply-To: References: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 13 Apr 2011 00:47:10 +0000 (UTC) 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. Reported-by: Stefan Hajnoczi Signed-off-by: Josh Durgin --- block/rbd.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 19014fb..ac20282 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -579,10 +579,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); @@ -609,16 +613,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,