From nobody Sat May 18 13:36:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1554980537; cv=none; d=zoho.com; s=zohoarc; b=ZCXbDlk8UL16lpGGUsr7QvbTg+RjxKeLM0RjjIHCLdCCmfJvGobqF3tVgnkZ3iVZmcqpStOiKySh5c3hYE5N9QZ7IIFLOUVaPfkBIQ7d75GAh08g3wsKJTSJz2t5413quOk18mEWVzCNmoi9OhLatGbK9Vmj6EZKcF8Ag/sD/kE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1554980537; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jbygTqk0I9MLOFQU+0InhKQfFzItOuf6nrYE08Xe1ZI=; b=fgTFW/bpHJF1QUbsGbT1STLRJOpILvYKz3UWhdluC6QgwopHABy2AAW1f0SLFnWdAqCtizlpwlJxKs+F4SbCjmyE/COKqEpD4KRFKYzLUk9k5uIW5aswXtW7SqjXykqKRtxmc/2qLOKhco1KCfl1SCO8q3iW8YXnIu7qztjSBhA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15549805378181007.9712024466833; Thu, 11 Apr 2019 04:02:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:46401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEXSw-0002c6-P2 for importer@patchew.org; Thu, 11 Apr 2019 07:01:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEXHv-0001ma-2Y for qemu-devel@nongnu.org; Thu, 11 Apr 2019 06:50:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEXHt-0006fX-W5 for qemu-devel@nongnu.org; Thu, 11 Apr 2019 06:50:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43696) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hEXHr-0006dB-Bo; Thu, 11 Apr 2019 06:50:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A2FCD88AC8; Thu, 11 Apr 2019 10:50:30 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-116-245.ams2.redhat.com [10.36.116.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EF461001E67; Thu, 11 Apr 2019 10:50:28 +0000 (UTC) From: Stefano Garzarella To: qemu-devel@nongnu.org Date: Thu, 11 Apr 2019 12:50:25 +0200 Message-Id: <20190411105025.97397-2-sgarzare@redhat.com> In-Reply-To: <20190411105025.97397-1-sgarzare@redhat.com> References: <20190411105025.97397-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 11 Apr 2019 10:50:30 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Josh Durgin , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" RBD APIs don't allow us to write more than the size set with rbd_create() or rbd_resize(). In order to support growing images (eg. qcow2), we resize the image before RW operations that exceed the current size. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1171007 Signed-off-by: Stefano Garzarella --- block/rbd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/block/rbd.c b/block/rbd.c index 0c549c9935..228658e20a 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -102,6 +102,7 @@ typedef struct BDRVRBDState { rbd_image_t image; char *image_name; char *snap; + uint64_t image_size; } BDRVRBDState; =20 static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx, @@ -777,6 +778,14 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *= options, int flags, goto failed_open; } =20 + r =3D rbd_get_size(s->image, &s->image_size); + if (r < 0) { + error_setg_errno(errp, -r, "error reading image size from %s", + s->image_name); + rbd_close(s->image); + goto failed_open; + } + /* If we are using an rbd snapshot, we must be r/o, otherwise * leave as-is */ if (s->snap !=3D NULL) { @@ -921,6 +930,20 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs, rcb->buf =3D acb->bounce; } =20 + /* + * RBD APIs don't allow us to write more than actual size, so in order + * to support growing images, we resize the image before RW operations + * that exceed the current size. + */ + if (s->image_size < off + size) { + r =3D rbd_resize(s->image, off + size); + if (r < 0) { + goto failed; + } + + s->image_size =3D off + size; + } + acb->ret =3D 0; acb->error =3D 0; acb->s =3D s; @@ -1066,6 +1089,8 @@ static int coroutine_fn qemu_rbd_co_truncate(BlockDri= verState *bs, return r; } =20 + s->image_size =3D offset; + return 0; } =20 --=20 2.20.1