Received: from eggs.gnu.org ([208.118.235.92]:40888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5gwd-00058q-Ik for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:16:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S5gwX-0004rx-Ca for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:16:03 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:47906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5gwX-0004n5-4d for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:15:57 -0500 Received: by mail-iy0-f173.google.com with SMTP id j26so1015616iaf.4 for ; Thu, 08 Mar 2012 09:15:56 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 8 Mar 2012 18:15:13 +0100 Message-Id: <1331226917-6658-14-git-send-email-pbonzini@redhat.com> In-Reply-To: <1331226917-6658-1-git-send-email-pbonzini@redhat.com> References: <1331226917-6658-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [RFC PATCH 13/17] block: fallback from discard to writes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- block.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) 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) { -- 1.7.7.6