Blame SOURCES/kvm-block-handle-ENOTSUP-from-discard-in-generic-code.patch.patch.patch

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