From patchwork Thu May 26 23:07:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Durgin X-Patchwork-Id: 822292 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4QNC2i9032658 for ; Thu, 26 May 2011 23:12:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932893Ab1EZXL6 (ORCPT ); Thu, 26 May 2011 19:11:58 -0400 Received: from mail.hq.newdream.net ([66.33.206.127]:49532 "EHLO mail.hq.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758578Ab1EZXLy (ORCPT ); Thu, 26 May 2011 19:11:54 -0400 Received: from mail.hq.newdream.net (localhost [127.0.0.1]) by mail.hq.newdream.net (Postfix) with ESMTP id 11A95C3B1; Thu, 26 May 2011 16:11:54 -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=hqbFg+dctjtXa16Whcd93ha6B8QX+7Sxc2fPBlNy+tVOcRB cMD97AJ5ah9S9IzcTTk9mMeFfnPpGob/xpHQzklVkT2GPUqO1Jyh9BrZSEP9Ormy EifsMLmJ2ESmDorF3kdSItoIebC1xr0ixgz68rFJQ8riIRnN9M8c6ZhMG88E= 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=cFF/SMbzqM7373otpX0xB9v4YBM=; b=DoIzZAHrealnvn ZO1+sDNlHnlJIE690iS1rn6P7vLLciqqIqDWTBLBwczM3ihm6C5LnQ7HX9YUHyr0 rs8R9muV0SSg4Iof3kf43dHDGwW5owar22gc5nsP4vHdIxvnEDXzqI9+RI8g54ha vPxnoBXZZB7YKr+IZjc5CPLZkRh+Y= 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 0D13BC248; Thu, 26 May 2011 16:11:54 -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 v6 4/4] rbd: Add bdrv_truncate implementation Date: Thu, 26 May 2011 16:07:34 -0700 Message-Id: <1306451254-25864-5-git-send-email-josh.durgin@dreamhost.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1306451254-25864-1-git-send-email-josh.durgin@dreamhost.com> References: <1306451254-25864-1-git-send-email-josh.durgin@dreamhost.com> To: kvm@vger.kernel.org, qemu-devel@nongnu.org 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 (demeter2.kernel.org [140.211.167.43]); Thu, 26 May 2011 23:12:03 +0000 (UTC) Reviewed-by: Christian Brunner Signed-off-by: Josh Durgin --- block/rbd.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index f4da6ab..bdc448a 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -688,6 +688,19 @@ 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) { + return r; + } + + return 0; +} + static int qemu_rbd_snap_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { @@ -784,6 +797,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,