From patchwork Wed May 25 20:34:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Durgin X-Patchwork-Id: 817552 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 p4PKdNm3004802 for ; Wed, 25 May 2011 20:39:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755964Ab1EYUjW (ORCPT ); Wed, 25 May 2011 16:39:22 -0400 Received: from mail.hq.newdream.net ([66.33.206.127]:48240 "EHLO mail.hq.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755550Ab1EYUjT (ORCPT ); Wed, 25 May 2011 16:39:19 -0400 Received: from mail.hq.newdream.net (localhost [127.0.0.1]) by mail.hq.newdream.net (Postfix) with ESMTP id E4B67C64F; Wed, 25 May 2011 13:39:18 -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=e7SfrpylNjBLl3j99x9UFfhy71s1uEyOVR/E1Im2cU3hwJY TEjXckyFMkXH1NHO22kB94hIuPRUJv+c2elAcIv4fPajYZ6WdVhMX9mwNTontYf2 ykwUSq3iqnrpw4wwH8AGaIuhMKG8r6spnZ+Od4TgC8K7+btgJmPacLyJlEzA= 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=kYsZyCJVSAmOUB2PQqTf1B3919g=; b=A5SN8QNQDzcRAZ xvjHtifv7izHvOW9zD5nbxE1BmEnpI+i2alKt3NebXKIFEzE8s9JkknG1xPvS5tW ib01305u5epx8U/+0nUiuzLxLmUDCUiEyhY24Ntmw/QT/MUxi0WZWjJCLs6t5bgq N6uRHsumTH8r+OwyUkpdhgLpgeV0k= 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 CF05BC12E; Wed, 25 May 2011 13:39:18 -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 v5 4/4] rbd: Add bdrv_truncate implementation Date: Wed, 25 May 2011 13:34:47 -0700 Message-Id: <1306355687-4647-5-git-send-email-josh.durgin@dreamhost.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1306355687-4647-1-git-send-email-josh.durgin@dreamhost.com> References: <1306355687-4647-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 (demeter1.kernel.org [140.211.167.41]); Wed, 25 May 2011 20:39:24 +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 a44d160..b95b1eb 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -688,6 +688,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,