diff mbox

[v4,4/4] rbd: Add bdrv_truncate implementation

Message ID 1306263078-18089-5-git-send-email-josh.durgin@dreamhost.com (mailing list archive)
State New, archived
Headers show

Commit Message

Josh Durgin May 24, 2011, 6:51 p.m. UTC
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
---
 block/rbd.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

Comments

Christian Brunner May 25, 2011, 7:22 p.m. UTC | #1
Looks good to me:

Reviewed-by: Christian Brunner <chb@muc.de>


2011/5/24 Josh Durgin <josh.durgin@dreamhost.com>:
> Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
> ---
>  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,
> --
> 1.7.2.3
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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,