diff mbox

[RFC,13/17] block: fallback from discard to writes

Message ID 1331226917-6658-14-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini March 8, 2012, 5:15 p.m. UTC
Allow discard to fail, and fall back to the write operation.  This
is needed because there's no simple way to probe for availability
of FALLOC_FL_PUNCH_HOLE.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Comments

Christoph Hellwig March 24, 2012, 3:35 p.m. UTC | #1
On Thu, Mar 08, 2012 at 06:15:13PM +0100, Paolo Bonzini wrote:
> Allow discard to fail, and fall back to the write operation.  This
> is needed because there's no simple way to probe for availability
> of FALLOC_FL_PUNCH_HOLE.

So you switch on advertising TRIM support in the patch before, and then
fall back to a very suboptimal implementation here?

This will make Windows 7 users very unhappy.
diff mbox

Patch

diff --git a/block.c b/block.c
index af73497..7397df6 100644
--- a/block.c
+++ b/block.c
@@ -1798,7 +1798,10 @@  static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
         bdi.discard_granularity &&
         (sector_num & (bdi.discard_granularity - 1)) == 0 &&
         (nb_sectors & (bdi.discard_granularity - 1)) == 0) {
-        return bdrv_co_do_discard(bs, sector_num, nb_sectors);
+        ret = bdrv_co_do_discard(bs, sector_num, nb_sectors);
+        if (ret != -ENOTSUP) {
+            return ret;
+        }
     }
 
     if (qiov) {