diff mbox

[1/2] block/iscsi: dont leave allocmap in an invalid state on UNMAP failure

Message ID 1512733868-9009-2-git-send-email-pl@kamp.de (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Lieven Dec. 8, 2017, 11:51 a.m. UTC
we forgot to set the allocmap to invalid if an UNMAP call fails.

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
---
 block/iscsi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Eric Blake Dec. 8, 2017, 3:07 p.m. UTC | #1
On 12/08/2017 05:51 AM, Peter Lieven wrote:
> we forgot to set the allocmap to invalid if an UNMAP call fails.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  block/iscsi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 

> @@ -1128,6 +1128,9 @@ retry:
>          goto retry;
>      }
>  
> +    iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,
> +                               bytes >> BDRV_SECTOR_BITS);
> +

Semantic conflict with my pending patches to convert the allocmap to
byte-based:

https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg01253.html

Reviewed-by: Eric Blake <eblake@redhat.com>
Paolo Bonzini Dec. 13, 2017, 9:35 p.m. UTC | #2
On 08/12/2017 12:51, Peter Lieven wrote:
> we forgot to set the allocmap to invalid if an UNMAP call fails.

This is only needed for "a power loss, a medium error, or hardware
error" according to the spec, but I guess this is the safe thing to do.

Paolo

> Cc: qemu-stable@nongnu.org
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  block/iscsi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 4683f3b..c532ec7 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -2,7 +2,7 @@
>   * QEMU Block driver for iSCSI images
>   *
>   * Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com>
> - * Copyright (c) 2012-2016 Peter Lieven <pl@kamp.de>
> + * Copyright (c) 2012-2017 Peter Lieven <pl@kamp.de>
>   *
>   * Permission is hereby granted, free of charge, to any person obtaining a copy
>   * of this software and associated documentation files (the "Software"), to deal
> @@ -1128,6 +1128,9 @@ retry:
>          goto retry;
>      }
>  
> +    iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,
> +                               bytes >> BDRV_SECTOR_BITS);
> +
>      if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
>          /* the target might fail with a check condition if it
>             is not happy with the alignment of the UNMAP request
> @@ -1140,9 +1143,6 @@ retry:
>          goto out_unlock;
>      }
>  
> -    iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,
> -                               bytes >> BDRV_SECTOR_BITS);
> -
>  out_unlock:
>      qemu_mutex_unlock(&iscsilun->mutex);
>      return r;
>
diff mbox

Patch

diff --git a/block/iscsi.c b/block/iscsi.c
index 4683f3b..c532ec7 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -2,7 +2,7 @@ 
  * QEMU Block driver for iSCSI images
  *
  * Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com>
- * Copyright (c) 2012-2016 Peter Lieven <pl@kamp.de>
+ * Copyright (c) 2012-2017 Peter Lieven <pl@kamp.de>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -1128,6 +1128,9 @@  retry:
         goto retry;
     }
 
+    iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,
+                               bytes >> BDRV_SECTOR_BITS);
+
     if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
         /* the target might fail with a check condition if it
            is not happy with the alignment of the UNMAP request
@@ -1140,9 +1143,6 @@  retry:
         goto out_unlock;
     }
 
-    iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,
-                               bytes >> BDRV_SECTOR_BITS);
-
 out_unlock:
     qemu_mutex_unlock(&iscsilun->mutex);
     return r;