From patchwork Wed Apr 13 00:45:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Durgin X-Patchwork-Id: 702491 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 p3D0lH1d002190 for ; Wed, 13 Apr 2011 00:47:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932579Ab1DMArL (ORCPT ); Tue, 12 Apr 2011 20:47:11 -0400 Received: from mail.hq.newdream.net ([66.33.206.127]:49715 "EHLO mail.hq.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932693Ab1DMArF (ORCPT ); Tue, 12 Apr 2011 20:47:05 -0400 Received: from mail.hq.newdream.net (localhost [127.0.0.1]) by mail.hq.newdream.net (Postfix) with ESMTP id 2BEB1C069; Tue, 12 Apr 2011 17:47:05 -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=Yqoyrt8pCIBgsFBhAzjUv8rip 5NvYOgWm4QVoKqcu7bI5JC4N/Bmz55Gh2mKJY3FlLDFbvj/FCfU026X0ej325hRn /WGDOSTvvbrByY9j5eUYcqkDkjx4P3/NX+ScfPr5OEdESJ7244nLALhH+u2O+oHJ Ec/mEefpNjTnOYjiaI= 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=7y4lY6zq2qmjVyXNjgnzlyZxzUg=; b= lLkCaV6eY9gzl+zrKqXgcn3ZLKR7saBgY84lwraSlAyVmhJ16Xr/UtvYbhS3imMV mt3NXPDS7A7wXCwJ6wxFI2E9c4P7eemJUk/U2KSUkEFKdQH4ek1xMKYmEygDkL2R ZIS/ndPEaBNOtI8G++RUneiTQ+tWZnPhgJMxofEMAFg= 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 27AE5C062; Tue, 12 Apr 2011 17:47:05 -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 4/4] rbd: Add bdrv_truncate implementation Date: Tue, 12 Apr 2011 17:45:26 -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:18 +0000 (UTC) Signed-off-by: Josh Durgin --- block/rbd.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index ac20282..4514dbd 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -686,6 +686,20 @@ static int64_t qemu_rbd_getlength(BlockDriverState *bs) return info.size; } +static int qemu_rbd_truncate(BlockDriverState *bs, int64_t offset) +{ + BDRVRBDState *s = bs->opaque; + int r; + + r = rbd_resize(s->image, offset); + if (r < 0) { + error_report("failed to resize rbd image"); + return -EIO; + } + + return 0; +} + static int qemu_rbd_snap_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { @@ -784,6 +798,7 @@ static BlockDriver bdrv_rbd = { .bdrv_get_info = qemu_rbd_getinfo, .create_options = qemu_rbd_create_options, .bdrv_getlength = qemu_rbd_getlength, + .bdrv_truncate = qemu_rbd_truncate, .protocol_name = "rbd", .bdrv_aio_readv = qemu_rbd_aio_readv,