[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 7/7] sheepdog: Allow fully preallocated truncation
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 7/7] sheepdog: Allow fully preallocated truncation |
Date: |
Tue, 13 Feb 2018 14:03:56 +0100 |
Signed-off-by: Max Reitz <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.14.3
- [Qemu-devel] [PATCH 0/7] block: Preallocated truncation for gluster and sheepdog, Max Reitz, 2018/02/13
- [Qemu-devel] [PATCH 4/7] gluster: Add preallocated truncation, Max Reitz, 2018/02/13
- [Qemu-devel] [PATCH 1/7] gluster: Move glfs_close() to create's clean-up, Max Reitz, 2018/02/13
- [Qemu-devel] [PATCH 2/7] gluster: Pull truncation from qemu_gluster_create, Max Reitz, 2018/02/13
- [Qemu-devel] [PATCH 7/7] sheepdog: Allow fully preallocated truncation,
Max Reitz <=
- [Qemu-devel] [PATCH 3/7] gluster: Query current size in do_truncate(), Max Reitz, 2018/02/13
- [Qemu-devel] [PATCH 5/7] sheepdog: Make sd_prealloc() take a BDS, Max Reitz, 2018/02/13
- [Qemu-devel] [PATCH 6/7] sheepdog: Pass old and new size to sd_prealloc(), Max Reitz, 2018/02/13
- Re: [Qemu-devel] [PATCH 0/7] block: Preallocated truncation for gluster and sheepdog, Kevin Wolf, 2018/02/13