yeahuh / rpms / qemu-kvm

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