diff mbox

block/iscsi: allow fall back to WRITE SAME without UNMAP

Message ID 1398684205-16812-1-git-send-email-pl@kamp.de
State New
Headers show

Commit Message

Peter Lieven April 28, 2014, 11:23 a.m. UTC
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 <pl@kamp.de>
---
 block/iscsi.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Paolo Bonzini April 28, 2014, 1:10 p.m. UTC | #1
Il 28/04/2014 13:23, Peter Lieven ha scritto:
> 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 <pl@kamp.de>
> ---
>  block/iscsi.c |   11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 0819945..5fbee82 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;
>      }
>
>

Applied to scsi-next, thanks.

Paolo
diff mbox

Patch

diff --git a/block/iscsi.c b/block/iscsi.c
index 0819945..5fbee82 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;
     }