From patchwork Tue Jun 22 20:27:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brunner X-Patchwork-Id: 107505 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5MKRBof008377 for ; Tue, 22 Jun 2010 20:27:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754793Ab0FVU1L (ORCPT ); Tue, 22 Jun 2010 16:27:11 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:40486 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753698Ab0FVU1K (ORCPT ); Tue, 22 Jun 2010 16:27:10 -0400 Received: by bwz9 with SMTP id 9so198577bwz.19 for ; Tue, 22 Jun 2010 13:27:08 -0700 (PDT) Received: by 10.204.81.196 with SMTP id y4mr4725579bkk.75.1277238428612; Tue, 22 Jun 2010 13:27:08 -0700 (PDT) Received: from chb-desktop (e181012148.adsl.alicedsl.de [85.181.12.148]) by mx.google.com with ESMTPS id jq1sm10858660bkb.47.2010.06.22.13.27.07 (version=SSLv3 cipher=RC4-MD5); Tue, 22 Jun 2010 13:27:08 -0700 (PDT) Date: Tue, 22 Jun 2010 22:27:05 +0200 From: Christian Brunner To: ceph-devel@vger.kernel.org Subject: Re: [PATCH] rbd: add queuing delay Message-ID: <20100622202705.GA17975@chb-desktop> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@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]); Tue, 22 Jun 2010 20:27:11 +0000 (UTC) diff --git a/block/rbd.c b/block/rbd.c index 10daf20..f87e84c 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -50,6 +50,7 @@ int eventfd(unsigned int initval, int flags); */ #define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER) +#define MAX_QUEUE_SIZE 33554432 // 32MB typedef struct RBDAIOCB { BlockDriverAIOCB common; @@ -79,6 +80,7 @@ typedef struct BDRVRBDState { uint64_t size; uint64_t objsize; int qemu_aio_count; + uint64_t queuesize; } BDRVRBDState; typedef struct rbd_obj_header_ondisk RbdHeader1; @@ -334,6 +336,7 @@ static int rbd_open(BlockDriverState *bs, const char *filename, int flags) le64_to_cpus((uint64_t *) & header->image_size); s->size = header->image_size; s->objsize = 1 << header->options.order; + s->queuesize = 0; s->efd = eventfd(0, 0); if (s->efd < 0) { @@ -443,6 +446,7 @@ static void rbd_finish_aiocb(rados_completion_t c, RADOSCB *rcb) int i; acb->aiocnt--; + acb->s->queuesize -= rcb->segsize; r = rados_aio_get_return_value(c); rados_aio_release(c); if (acb->write) { @@ -560,6 +564,12 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs, rcb->segsize = segsize; rcb->buf = buf; + while (s->queuesize > MAX_QUEUE_SIZE) { + usleep(100); + } + + s->queuesize += segsize; + if (write) { rados_aio_create_completion(rcb, NULL, (rados_callback_t) rbd_finish_aiocb,