From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlFWl-00040l-EM for qemu-devel@nongnu.org; Fri, 16 May 2014 06:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlFWf-0004h5-Ei for qemu-devel@nongnu.org; Fri, 16 May 2014 06:38:11 -0400 Received: from mail-ee0-x236.google.com ([2a00:1450:4013:c00::236]:40731) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlFWf-0004gj-8q for qemu-devel@nongnu.org; Fri, 16 May 2014 06:38:05 -0400 Received: by mail-ee0-f54.google.com with SMTP id b57so1414282eek.27 for ; Fri, 16 May 2014 03:38:04 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 16 May 2014 12:37:40 +0200 Message-Id: <1400236664-32334-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1400236664-32334-1-git-send-email-pbonzini@redhat.com> References: <1400236664-32334-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 07/11] block/iscsi: allow fall back to WRITE SAME without UNMAP List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Lieven From: Peter Lieven if the iscsi driver receives a write zeroes request with the BDRV_REQ_MAY_UNMAP flag set it fails with -ENOTSUP if the iscsi target does not support WRITE SAME with UNMAP. However, the BDRV_REQ_MAY_UNMAP is only a hint and writing zeroes with WRITE SAME will still be better than falling back to writing zeroes with WRITE16. Signed-off-by: Peter Lieven Signed-off-by: Paolo Bonzini --- block/iscsi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index a636ea4..56f5419 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -809,13 +809,14 @@ coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, return -EINVAL; } - if (!(flags & BDRV_REQ_MAY_UNMAP) && !iscsilun->has_write_same) { - /* WRITE SAME without UNMAP is not supported by the target */ - return -ENOTSUP; + if ((flags & BDRV_REQ_MAY_UNMAP) && !iscsilun->lbp.lbpws) { + /* WRITE SAME with UNMAP is not supported by the target, + * fall back and try WRITE SAME without UNMAP */ + flags &= ~BDRV_REQ_MAY_UNMAP; } - if ((flags & BDRV_REQ_MAY_UNMAP) && !iscsilun->lbp.lbpws) { - /* WRITE SAME with UNMAP is not supported by the target */ + if (!(flags & BDRV_REQ_MAY_UNMAP) && !iscsilun->has_write_same) { + /* WRITE SAME without UNMAP is not supported by the target */ return -ENOTSUP; } -- 1.8.3.1