From patchwork Tue May 24 18:51:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Durgin X-Patchwork-Id: 813322 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 p4OItXvj002473 for ; Tue, 24 May 2011 18:55:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932830Ab1EXSzZ (ORCPT ); Tue, 24 May 2011 14:55:25 -0400 Received: from mail.hq.newdream.net ([66.33.206.127]:46157 "EHLO mail.hq.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756918Ab1EXSzX (ORCPT ); Tue, 24 May 2011 14:55:23 -0400 Received: from mail.hq.newdream.net (localhost [127.0.0.1]) by mail.hq.newdream.net (Postfix) with ESMTP id 1F96DC483; Tue, 24 May 2011 11:55:23 -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=bmUBhETYpgcUPoA5z4CO5iVJltZgKn3RJ45rTRrmpbFrpRj 91gs99asDHeSxbZrHE6aJdAJo4uirw91aX54FV4CB8vpL7l8kCpR7wqXtl37z+8S w8o/CGNTBNYNh9T2rp/m9nPUt/ogamXziQ6Wms0VpvoTyC+HuGdm9lWfXcA0= 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=orwgieigk8H/UPjl1JpwDCE4VqQ=; b=HZ19JFpMpX69AR NvbsYuYa1SuSc6E8F2U7PtRMud8BxatRYjuS7g8rLVHWAVxLQiNH0kBzmOxIFv2B UFnI5Hio31dzD82QaAlmiJ/6WAoQHv68ascpELo3iuQpcDKUtmi0xU6OenitUbsC IDgqOhNxQdnSU+9RQXlkjHhUDd/Qs= 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 1B918C128; Tue, 24 May 2011 11:55:23 -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 4/4] rbd: Add bdrv_truncate implementation Date: Tue, 24 May 2011 11:51:18 -0700 Message-Id: <1306263078-18089-5-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: 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.6 (demeter1.kernel.org [140.211.167.41]); Tue, 24 May 2011 18:55:34 +0000 (UTC) Signed-off-by: Josh Durgin Reviewed-by: Christian Brunner --- block/rbd.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index c9f32e4..015ae8e 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -687,6 +687,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) { @@ -785,6 +799,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,