|
|
9ae3a8 |
From bb95ce076f174cba655e098fb7924364fd29aa8b Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
Message-Id: <bb95ce076f174cba655e098fb7924364fd29aa8b.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
In-Reply-To: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
References: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 9 Dec 2013 14:09:15 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 27/50] block: handle ENOTSUP from discard in generic code
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1386598178-11845-30-git-send-email-pbonzini@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56066
|
|
|
9ae3a8 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH 29/52] block: handle ENOTSUP from discard in generic code
|
|
|
9ae3a8 |
Bugzilla: 1007815
|
|
|
9ae3a8 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Similar to write_zeroes, let the generic code receive a ENOTSUP for
|
|
|
9ae3a8 |
discard operations. Since bdrv_discard has advisory semantics,
|
|
|
9ae3a8 |
we can just swallow the error.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Peter Lieven <pl@kamp.de>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 7ce21016b69b512bf4777965a4292318f2bc7544)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 2 +-
|
|
|
9ae3a8 |
block/raw-posix.c | 12 ++++++------
|
|
|
9ae3a8 |
2 files changed, 7 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 2 +-
|
|
|
9ae3a8 |
block/raw-posix.c | 12 ++++++------
|
|
|
9ae3a8 |
2 files changed, 7 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block.c b/block.c
|
|
|
9ae3a8 |
index fc15370..c9e65b4 100644
|
|
|
9ae3a8 |
--- a/block.c
|
|
|
9ae3a8 |
+++ b/block.c
|
|
|
9ae3a8 |
@@ -4545,7 +4545,7 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
|
|
|
9ae3a8 |
ret = co.ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- if (ret) {
|
|
|
9ae3a8 |
+ if (ret && ret != -ENOTSUP) {
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/raw-posix.c b/block/raw-posix.c
|
|
|
9ae3a8 |
index c2b3dfd..7a140b0 100644
|
|
|
9ae3a8 |
--- a/block/raw-posix.c
|
|
|
9ae3a8 |
+++ b/block/raw-posix.c
|
|
|
9ae3a8 |
@@ -324,10 +324,10 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- s->has_discard = 1;
|
|
|
9ae3a8 |
+ s->has_discard = true;
|
|
|
9ae3a8 |
#ifdef CONFIG_XFS
|
|
|
9ae3a8 |
if (platform_test_xfs_fd(s->fd)) {
|
|
|
9ae3a8 |
- s->is_xfs = 1;
|
|
|
9ae3a8 |
+ s->is_xfs = true;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -699,8 +699,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb)
|
|
|
9ae3a8 |
int ret = -EOPNOTSUPP;
|
|
|
9ae3a8 |
BDRVRawState *s = aiocb->bs->opaque;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (s->has_discard == 0) {
|
|
|
9ae3a8 |
- return 0;
|
|
|
9ae3a8 |
+ if (!s->has_discard) {
|
|
|
9ae3a8 |
+ return -ENOTSUP;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (aiocb->aio_type & QEMU_AIO_BLKDEV) {
|
|
|
9ae3a8 |
@@ -735,8 +735,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP ||
|
|
|
9ae3a8 |
ret == -ENOTTY) {
|
|
|
9ae3a8 |
- s->has_discard = 0;
|
|
|
9ae3a8 |
- ret = 0;
|
|
|
9ae3a8 |
+ s->has_discard = false;
|
|
|
9ae3a8 |
+ ret = -ENOTSUP;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.11.7
|
|
|
9ae3a8 |
|