From patchwork Fri Jun 11 19:51:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simone Gotti X-Patchwork-Id: 105637 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5BJpUpD023219 for ; Fri, 11 Jun 2010 19:51:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760530Ab0FKTv0 (ORCPT ); Fri, 11 Jun 2010 15:51:26 -0400 Received: from ey-out-2122.google.com ([74.125.78.26]:42806 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753324Ab0FKTvY (ORCPT ); Fri, 11 Jun 2010 15:51:24 -0400 Received: by ey-out-2122.google.com with SMTP id 25so299606eya.19 for ; Fri, 11 Jun 2010 12:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=UlEEuQUYG+jUhG6DOOQ7vbfGBUWNkul8UJOJNEOEq1E=; b=Vg1QDp9Ar/RmbOwe9rmWwtlx5NPKLYFoeot4gZgDNDqTxrUb1DmR61lwICmunw0WPv ELTT2nLVzkmxMqF4qq5IOgrhuoHQqDK3ooYNUoPpunyd0ntEdXxlKaRQmFv/94BxZ+8Z 4gXZ6asBs07f82wSW9Zk215NhUmdGAn7pdaig= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=TGgBHs+AVoVg5F+K/8w94VL2Wj9UeVP8Hc48GLxfJ7KfP4lDn3ccBgHv1KJaGrSOeY ZMpee9RIc+i0m5w/9fvXIW4SnwnvPJ9JwBEBsiCri/6Le684K+aQbVe4/pz8gDuifNfT PtUCr7ghpo3hSuiYq3LQ4Y614/34uUPdZ0m7Y= Received: by 10.213.51.84 with SMTP id c20mr890148ebg.6.1276285881920; Fri, 11 Jun 2010 12:51:21 -0700 (PDT) Received: from [192.168.2.2] (host3-63-dynamic.47-79-r.retail.telecomitalia.it [79.47.63.3]) by mx.google.com with ESMTPS id 23sm3061160eya.44.2010.06.11.12.51.19 (version=SSLv3 cipher=RC4-MD5); Fri, 11 Jun 2010 12:51:21 -0700 (PDT) Message-ID: <4C1293B7.1060307@gmail.com> Date: Fri, 11 Jun 2010 21:51:19 +0200 From: Simone Gotti User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-3.fc13 Lightning/1.0b2pre Thunderbird/3.0.4 MIME-Version: 1.0 To: Christian Brunner CC: Kevin Wolf , kvm@vger.kernel.org, qemu-devel@nongnu.org, ceph-devel@vger.kernel.org Subject: Re: [PATCH] ceph/rbd block driver for qemu-kvm (v3) References: <20100531193140.GA13993@chb-desktop> In-Reply-To: <20100531193140.GA13993@chb-desktop> 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.3 (demeter.kernel.org [140.211.167.41]); Fri, 11 Jun 2010 19:51:30 +0000 (UTC) diff --git a/block/rbd.c b/block/rbd.c index 4d22069..83b7898 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -25,6 +25,8 @@ #include +#include + /* * When specifying the image filename use: * @@ -47,6 +49,15 @@ #define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER) +typedef struct BDRVRBDState { + int efd; + rados_pool_t pool; + char name[RBD_MAX_OBJ_NAME_SIZE]; + uint64_t size; + uint64_t objsize; + int qemu_aio_count; +} BDRVRBDState; + typedef struct RBDAIOCB { BlockDriverAIOCB common; QEMUBH *bh; @@ -57,6 +68,7 @@ typedef struct RBDAIOCB { int64_t sector_num; int aiocnt; int error; + BDRVRBDState *s; } RBDAIOCB; typedef struct RADOSCB { @@ -67,12 +79,6 @@ typedef struct RADOSCB { char *buf; } RADOSCB; -typedef struct BDRVRBDState { - rados_pool_t pool; - char name[RBD_MAX_OBJ_NAME_SIZE]; - uint64_t size; - uint64_t objsize; -} BDRVRBDState; typedef struct rbd_obj_header_ondisk RbdHeader1; @@ -255,6 +261,31 @@ done: return ret; } +static void rbd_aio_completion_cb(void *opaque) +{ + BDRVRBDState *s = opaque; + + uint64_t val; + ssize_t ret; + + do { + if ((ret = read(s->efd, &val, sizeof(val))) > 0) { + s->qemu_aio_count -= val; + } + } while (ret == -1 && errno == EINTR); + + return; +} + +static int rbd_aio_flush_cb(void *opaque) +{ + BDRVRBDState *s = opaque; + + return (s->qemu_aio_count > 0) ? 1 : 0; +} + + + static int rbd_open(BlockDriverState *bs, const char *filename, int flags) { BDRVRBDState *s = bs->opaque; @@ -303,6 +334,15 @@ static int rbd_open(BlockDriverState *bs, const char *filename, int flags) s->size = header->image_size; s->objsize = 1 << header->options.order; + s->efd = eventfd(0, 0); + if (s->efd == -1) { + error_report("error opening eventfd"); + goto failed; + } + fcntl(s->efd, F_SETFL, O_NONBLOCK); + qemu_aio_set_fd_handler(s->efd, rbd_aio_completion_cb, NULL, + rbd_aio_flush_cb, NULL, s); + return 0;