Skip to content

Commit

Permalink
block: handle ENOTSUP from discard in generic code
Browse files Browse the repository at this point in the history
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: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
bonzini authored and stefanhaRH committed Dec 3, 2013
1 parent d5ef94d commit 7ce2101
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion block.c
Expand Up @@ -4376,7 +4376,7 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
ret = co.ret;
}
}
if (ret) {
if (ret && ret != -ENOTSUP) {
return ret;
}

Expand Down
12 changes: 6 additions & 6 deletions block/raw-posix.c
Expand Up @@ -323,10 +323,10 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
}
#endif

s->has_discard = 1;
s->has_discard = true;
#ifdef CONFIG_XFS
if (platform_test_xfs_fd(s->fd)) {
s->is_xfs = 1;
s->is_xfs = true;
}
#endif

Expand Down Expand Up @@ -698,8 +698,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb)
int ret = -EOPNOTSUPP;
BDRVRawState *s = aiocb->bs->opaque;

if (s->has_discard == 0) {
return 0;
if (!s->has_discard) {
return -ENOTSUP;
}

if (aiocb->aio_type & QEMU_AIO_BLKDEV) {
Expand Down Expand Up @@ -734,8 +734,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb)

if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP ||
ret == -ENOTTY) {
s->has_discard = 0;
ret = 0;
s->has_discard = false;
ret = -ENOTSUP;
}
return ret;
}
Expand Down

0 comments on commit 7ce2101

Please sign in to comment.