aboutsummaryrefslogtreecommitdiff
path: root/block/io.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2020-04-24 14:54:39 +0200
committerKevin Wolf <kwolf@redhat.com>2020-04-30 17:51:07 +0200
commit92b92799dc8662b6f71809100a4aabc1ae408ebb (patch)
tree3f1ac86ecb305c8ed56ba752fc92832b314b6894 /block/io.c
parent3fb61087074474b088fee23bb81ffd258cb9cb2a (diff)
block: Add flags to BlockDriver.bdrv_co_truncate()
This adds a new BdrvRequestFlags parameter to the .bdrv_co_truncate() driver callbacks, and a supported_truncate_flags field in BlockDriverState that allows drivers to advertise support for request flags in the context of truncate. For now, we always pass 0 and no drivers declare support for any flag. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200424125448.63318-2-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/io.c')
-rw-r--r--block/io.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/block/io.c b/block/io.c
index aba67f66b9..04ac5cf023 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3344,6 +3344,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
BlockDriverState *bs = child->bs;
BlockDriver *drv = bs->drv;
BdrvTrackedRequest req;
+ BdrvRequestFlags flags = 0;
int64_t old_size, new_bytes;
int ret;
@@ -3394,7 +3395,12 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
}
if (drv->bdrv_co_truncate) {
- ret = drv->bdrv_co_truncate(bs, offset, exact, prealloc, errp);
+ if (flags & ~bs->supported_truncate_flags) {
+ error_setg(errp, "Block driver does not support requested flags");
+ ret = -ENOTSUP;
+ goto out;
+ }
+ ret = drv->bdrv_co_truncate(bs, offset, exact, prealloc, flags, errp);
} else if (bs->file && drv->is_filter) {
ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, errp);
} else {