提交 7ce21016 编写于 作者: P Paolo Bonzini 提交者: Stefan Hajnoczi

block: handle ENOTSUP from discard in generic code

Similar to write_zeroes, let the generic code receive a ENOTSUP for
discard operations.  Since bdrv_discard has advisory semantics,
we can just swallow the error.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NPeter Lieven <pl@kamp.de>
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 d5ef94d4
...@@ -4376,7 +4376,7 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, ...@@ -4376,7 +4376,7 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
ret = co.ret; ret = co.ret;
} }
} }
if (ret) { if (ret && ret != -ENOTSUP) {
return ret; return ret;
} }
......
...@@ -323,10 +323,10 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, ...@@ -323,10 +323,10 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
} }
#endif #endif
s->has_discard = 1; s->has_discard = true;
#ifdef CONFIG_XFS #ifdef CONFIG_XFS
if (platform_test_xfs_fd(s->fd)) { if (platform_test_xfs_fd(s->fd)) {
s->is_xfs = 1; s->is_xfs = true;
} }
#endif #endif
...@@ -698,8 +698,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb) ...@@ -698,8 +698,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb)
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
BDRVRawState *s = aiocb->bs->opaque; BDRVRawState *s = aiocb->bs->opaque;
if (s->has_discard == 0) { if (!s->has_discard) {
return 0; return -ENOTSUP;
} }
if (aiocb->aio_type & QEMU_AIO_BLKDEV) { if (aiocb->aio_type & QEMU_AIO_BLKDEV) {
...@@ -734,8 +734,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb) ...@@ -734,8 +734,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb)
if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP || if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP ||
ret == -ENOTTY) { ret == -ENOTTY) {
s->has_discard = 0; s->has_discard = false;
ret = 0; ret = -ENOTSUP;
} }
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册