[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 15/55] sheepdog: Allow fully preallocated truncation
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 15/55] sheepdog: Allow fully preallocated truncation |
Date: |
Tue, 13 Feb 2018 18:04:49 +0100 |
From: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/sheepdog.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index d300fb69c0..ac02b10fe0 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2180,15 +2180,16 @@ static int sd_truncate(BlockDriverState *bs, int64_t
offset,
int ret, fd;
unsigned int datalen;
uint64_t max_vdi_size;
+ int64_t old_size = s->inode.vdi_size;
- if (prealloc != PREALLOC_MODE_OFF) {
+ if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_FULL) {
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_str(prealloc));
return -ENOTSUP;
}
max_vdi_size = (UINT64_C(1) << s->inode.block_size_shift) * MAX_DATA_OBJS;
- if (offset < s->inode.vdi_size) {
+ if (offset < old_size) {
error_setg(errp, "shrinking is not supported");
return -EINVAL;
} else if (offset > max_vdi_size) {
@@ -2211,9 +2212,17 @@ static int sd_truncate(BlockDriverState *bs, int64_t
offset,
if (ret < 0) {
error_setg_errno(errp, -ret, "failed to update an inode");
+ return ret;
}
- return ret;
+ if (prealloc == PREALLOC_MODE_FULL) {
+ ret = sd_prealloc(bs, old_size, offset, errp);
+ if (ret < 0) {
+ return ret;
+ }
+ }
+
+ return 0;
}
/*
--
2.13.6
- [Qemu-block] [PULL 03/55] qemu-img: Document --force-share / -U, (continued)
- [Qemu-block] [PULL 03/55] qemu-img: Document --force-share / -U, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 02/55] qemu-img.texi: Clean up parameter list, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 09/55] gluster: Move glfs_close() to create's clean-up, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 11/55] gluster: Query current size in do_truncate(), Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 04/55] docs: Document share-rw property more thoroughly, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 10/55] gluster: Pull truncation from qemu_gluster_create, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 06/55] block: early check for blockers on drive-mirror, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 05/55] qcow2: Use g_try_realloc() in qcow2_expand_zero_clusters(), Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 08/55] qemu-io: fix EOF Ctrl-D handling in qemu-io readline code, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 07/55] iotests: Use virtio-blk in 155, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 15/55] sheepdog: Allow fully preallocated truncation,
Kevin Wolf <=
- [Qemu-block] [PULL 13/55] sheepdog: Make sd_prealloc() take a BDS, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 17/55] qcow2: Fix documentation of get_cluster_table(), Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 14/55] sheepdog: Pass old and new size to sd_prealloc(), Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 12/55] gluster: Add preallocated truncation, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 18/55] qcow2: Add table size field to Qcow2Cache, Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 19/55] qcow2: Remove BDS parameter from qcow2_cache_get_table_addr(), Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 20/55] qcow2: Remove BDS parameter from qcow2_cache_get_table_idx(), Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 21/55] qcow2: Remove BDS parameter from qcow2_cache_table_release(), Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 26/55] qcow2: Remove BDS parameter from qcow2_cache_discard(), Kevin Wolf, 2018/02/13
- [Qemu-block] [PULL 16/55] block: maintain persistent disabled bitmaps, Kevin Wolf, 2018/02/13