@@ -607,6 +607,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
} else {
s->discard_zeroes = true;
s->has_fallocate = true;
+ bs->supported_zero_flags = BDRV_REQ_ALLOCATE;
}
} else {
if (!(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
@@ -650,10 +651,11 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
#ifdef CONFIG_XFS
if (platform_test_xfs_fd(s->fd)) {
s->is_xfs = true;
+ bs->supported_zero_flags = BDRV_REQ_ALLOCATE;
}
#endif
- bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
+ bs->supported_zero_flags |= BDRV_REQ_MAY_UNMAP;
ret = 0;
fail:
if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
@@ -1552,6 +1554,10 @@ static int handle_aiocb_write_zeroes(void *opaque)
s->has_fallocate = false;
#endif
+ if (!s->has_fallocate) {
+ aiocb->bs->supported_zero_flags &= ~BDRV_REQ_ALLOCATE;
+ }
+
return -ENOTSUP;
}