Commit 42ec24e2 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Stefan Hajnoczi
Browse files

gluster: Add image resize support



Implement .bdrv_truncate in GlusterFS block driver so that GlusterFS backend
can support image resizing.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarBharata B Rao <bharata@linux.vnet.ibm.com>
Tested-by: default avatarBharata B Rao <bharata@linux.vnet.ibm.com>
Acked-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent e3409362
...@@ -493,6 +493,19 @@ out: ...@@ -493,6 +493,19 @@ out:
return NULL; 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, static BlockDriverAIOCB *qemu_gluster_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque) BlockDriverCompletionFunc *cb, void *opaque)
...@@ -631,6 +644,7 @@ static BlockDriver bdrv_gluster = { ...@@ -631,6 +644,7 @@ static BlockDriver bdrv_gluster = {
.bdrv_create = qemu_gluster_create, .bdrv_create = qemu_gluster_create,
.bdrv_getlength = qemu_gluster_getlength, .bdrv_getlength = qemu_gluster_getlength,
.bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size,
.bdrv_truncate = qemu_gluster_truncate,
.bdrv_aio_readv = qemu_gluster_aio_readv, .bdrv_aio_readv = qemu_gluster_aio_readv,
.bdrv_aio_writev = qemu_gluster_aio_writev, .bdrv_aio_writev = qemu_gluster_aio_writev,
.bdrv_aio_flush = qemu_gluster_aio_flush, .bdrv_aio_flush = qemu_gluster_aio_flush,
...@@ -650,6 +664,7 @@ static BlockDriver bdrv_gluster_tcp = { ...@@ -650,6 +664,7 @@ static BlockDriver bdrv_gluster_tcp = {
.bdrv_create = qemu_gluster_create, .bdrv_create = qemu_gluster_create,
.bdrv_getlength = qemu_gluster_getlength, .bdrv_getlength = qemu_gluster_getlength,
.bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size,
.bdrv_truncate = qemu_gluster_truncate,
.bdrv_aio_readv = qemu_gluster_aio_readv, .bdrv_aio_readv = qemu_gluster_aio_readv,
.bdrv_aio_writev = qemu_gluster_aio_writev, .bdrv_aio_writev = qemu_gluster_aio_writev,
.bdrv_aio_flush = qemu_gluster_aio_flush, .bdrv_aio_flush = qemu_gluster_aio_flush,
...@@ -669,6 +684,7 @@ static BlockDriver bdrv_gluster_unix = { ...@@ -669,6 +684,7 @@ static BlockDriver bdrv_gluster_unix = {
.bdrv_create = qemu_gluster_create, .bdrv_create = qemu_gluster_create,
.bdrv_getlength = qemu_gluster_getlength, .bdrv_getlength = qemu_gluster_getlength,
.bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size,
.bdrv_truncate = qemu_gluster_truncate,
.bdrv_aio_readv = qemu_gluster_aio_readv, .bdrv_aio_readv = qemu_gluster_aio_readv,
.bdrv_aio_writev = qemu_gluster_aio_writev, .bdrv_aio_writev = qemu_gluster_aio_writev,
.bdrv_aio_flush = qemu_gluster_aio_flush, .bdrv_aio_flush = qemu_gluster_aio_flush,
...@@ -688,6 +704,7 @@ static BlockDriver bdrv_gluster_rdma = { ...@@ -688,6 +704,7 @@ static BlockDriver bdrv_gluster_rdma = {
.bdrv_create = qemu_gluster_create, .bdrv_create = qemu_gluster_create,
.bdrv_getlength = qemu_gluster_getlength, .bdrv_getlength = qemu_gluster_getlength,
.bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size,
.bdrv_truncate = qemu_gluster_truncate,
.bdrv_aio_readv = qemu_gluster_aio_readv, .bdrv_aio_readv = qemu_gluster_aio_readv,
.bdrv_aio_writev = qemu_gluster_aio_writev, .bdrv_aio_writev = qemu_gluster_aio_writev,
.bdrv_aio_flush = qemu_gluster_aio_flush, .bdrv_aio_flush = qemu_gluster_aio_flush,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment