From patchwork Tue May 24 18:51:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Durgin X-Patchwork-Id: 813342 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 p4OItXvl002473 for ; Tue, 24 May 2011 18:55:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932879Ab1EXSzb (ORCPT ); Tue, 24 May 2011 14:55:31 -0400 Received: from mail.hq.newdream.net ([66.33.206.127]:46151 "EHLO mail.hq.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755355Ab1EXSzW (ORCPT ); Tue, 24 May 2011 14:55:22 -0400 Received: from mail.hq.newdream.net (localhost [127.0.0.1]) by mail.hq.newdream.net (Postfix) with ESMTP id E4D23C482; Tue, 24 May 2011 11:55:21 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=dreamhost.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:to; q=dns; s= dreamhost.com; b=GAEoI8gJBtPZFmFK4cP9sz+ItcFTMjBKZFD8jjrTnNYzIrE 9g18tLETNp77abtM9k+VInT10BWSgktsJliy6Xfc3klnGSTRZDxvLisWFUpVps5W btH793np+DVApRassjMD/j0XzqnNePF7guAYi75Fzvz27++F2+3L3Amcxb+U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=dreamhost.com; h=from:to :cc:subject:date:message-id:in-reply-to:references:to; s= dreamhost.com; bh=ndrSVqLskv+hrCbAc4MJ5+hN52w=; b=oRHYIyZJ5Wrkcr hl5dsrIN9SCpjMiR6zCqeRm78cbYtpPkPr1ac/PQ71gxuMFCLCBr+7Z3yAlbsLhz crATvsyPXYwocQ0ZMaFd+/9bbu/LpVAZxQcS642Hc5KldT6KULzF8knM2vznPrKy fDS6aB2RRGP0pADdkMqTZqbcWah1k= 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 E0CD3C128; Tue, 24 May 2011 11:55:21 -0700 (PDT) From: Josh Durgin To: kvm@vger.kernel.org, qemu-devel@nongnu.org Cc: ceph-devel@vger.kernel.org, Kevin Wolf , Christian Brunner Subject: [PATCH v4 3/4] rbd: check return values when scheduling aio Date: Tue, 24 May 2011 11:51:17 -0700 Message-Id: <1306263078-18089-4-git-send-email-josh.durgin@dreamhost.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1306263078-18089-1-git-send-email-josh.durgin@dreamhost.com> References: <1306263078-18089-1-git-send-email-josh.durgin@dreamhost.com> To: kvm@vger.kernel.org, qemu-devel@nongnu.org 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]); Tue, 24 May 2011 18:55:34 +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 Reviewed-by: Christian Brunner --- block/rbd.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index ff74e8b..c9f32e4 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -580,10 +580,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); @@ -610,16 +614,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,