From 4f7481a9815ec6b879db9cb20be7dcc419274e11 Mon Sep 17 00:00:00 2001 From: Asias He Date: Thu, 12 Sep 2013 07:39:32 +0200 Subject: [PATCH 12/29] gluster: Add image resize support RH-Author: Asias He Message-id: <1378971575-22416-2-git-send-email-asias@redhat.com> Patchwork-id: 54323 O-Subject: [RHEL7.0 qemu-kvm PATCH 1/4] gluster: Add image resize support Bugzilla: 1007226 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Paolo Bonzini RH-Acked-by: Fam Zheng From: Paolo Bonzini BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1005052 Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=6275752 Implement .bdrv_truncate in GlusterFS block driver so that GlusterFS backend can support image resizing. Signed-off-by: Paolo Bonzini Signed-off-by: Bharata B Rao Tested-by: Bharata B Rao Acked-by: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi (cherry picked from commit 42ec24e2851674e0899f71933e0d7d9125f31d76) --- block/gluster.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) Signed-off-by: Miroslav Rezanina --- block/gluster.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 61424bc..7b10e9c 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -493,6 +493,19 @@ out: return NULL; } +static int qemu_gluster_truncate(BlockDriverState *bs, int64_t offset) +{ + int ret; + BDRVGlusterState *s = bs->opaque; + + ret = glfs_ftruncate(s->fd, offset); + if (ret < 0) { + return -errno; + } + + return 0; +} + static BlockDriverAIOCB *qemu_gluster_aio_readv(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) @@ -598,6 +611,7 @@ static BlockDriver bdrv_gluster = { .bdrv_create = qemu_gluster_create, .bdrv_getlength = qemu_gluster_getlength, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, + .bdrv_truncate = qemu_gluster_truncate, .bdrv_aio_readv = qemu_gluster_aio_readv, .bdrv_aio_writev = qemu_gluster_aio_writev, .bdrv_aio_flush = qemu_gluster_aio_flush, @@ -614,6 +628,7 @@ static BlockDriver bdrv_gluster_tcp = { .bdrv_create = qemu_gluster_create, .bdrv_getlength = qemu_gluster_getlength, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, + .bdrv_truncate = qemu_gluster_truncate, .bdrv_aio_readv = qemu_gluster_aio_readv, .bdrv_aio_writev = qemu_gluster_aio_writev, .bdrv_aio_flush = qemu_gluster_aio_flush, @@ -630,6 +645,7 @@ static BlockDriver bdrv_gluster_unix = { .bdrv_create = qemu_gluster_create, .bdrv_getlength = qemu_gluster_getlength, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, + .bdrv_truncate = qemu_gluster_truncate, .bdrv_aio_readv = qemu_gluster_aio_readv, .bdrv_aio_writev = qemu_gluster_aio_writev, .bdrv_aio_flush = qemu_gluster_aio_flush, @@ -646,6 +662,7 @@ static BlockDriver bdrv_gluster_rdma = { .bdrv_create = qemu_gluster_create, .bdrv_getlength = qemu_gluster_getlength, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, + .bdrv_truncate = qemu_gluster_truncate, .bdrv_aio_readv = qemu_gluster_aio_readv, .bdrv_aio_writev = qemu_gluster_aio_writev, .bdrv_aio_flush = qemu_gluster_aio_flush, -- 1.7.1