[for-4.0] block: Forward 'discard' to temporary overlay
diff mbox series

Message ID 20190404150746.12585-1-kwolf@redhat.com
State New
Headers show
Series
  • [for-4.0] block: Forward 'discard' to temporary overlay
Related show

Commit Message

Kevin Wolf April 4, 2019, 3:07 p.m. UTC
When bdrv_temp_snapshot_options() is called for snapshot=on, the
'discard' option in the options QDict hasn't been parsed and merged into
the flags yet. So copy the dict entry to make sure that the temporary
overlay enables discard when it was requested for the drive.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Eric Blake April 4, 2019, 3:18 p.m. UTC | #1
On 4/4/19 10:07 AM, Kevin Wolf wrote:
> When bdrv_temp_snapshot_options() is called for snapshot=on, the
> 'discard' option in the options QDict hasn't been parsed and merged into
> the flags yet. So copy the dict entry to make sure that the temporary
> overlay enables discard when it was requested for the drive.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block.c b/block.c
> index 3050854528..16615bc876 100644
> --- a/block.c
> +++ b/block.c
> @@ -950,8 +950,9 @@ static void bdrv_temp_snapshot_options(int *child_flags, QDict *child_options,
>      qdict_set_default_str(child_options, BDRV_OPT_CACHE_DIRECT, "off");
>      qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on");
>  
> -    /* Copy the read-only option from the parent */
> +    /* Copy the read-only and discard options from the parent */
>      qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY);
> +    qdict_copy_default(child_options, parent_options, BDRV_OPT_DISCARD);
>  
>      /* aio=native doesn't work for cache.direct=off, so disable it for the
>       * temporary snapshot */
>
Stefano Garzarella April 4, 2019, 3:38 p.m. UTC | #2
On Thu, Apr 04, 2019 at 05:07:46PM +0200, Kevin Wolf wrote:
> When bdrv_temp_snapshot_options() is called for snapshot=on, the
> 'discard' option in the options QDict hasn't been parsed and merged into
> the flags yet. So copy the dict entry to make sure that the temporary
> overlay enables discard when it was requested for the drive.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Alberto Garcia April 5, 2019, 7:36 a.m. UTC | #3
On Thu 04 Apr 2019 05:07:46 PM CEST, Kevin Wolf wrote:
> When bdrv_temp_snapshot_options() is called for snapshot=on, the
> 'discard' option in the options QDict hasn't been parsed and merged into
> the flags yet. So copy the dict entry to make sure that the temporary
> overlay enables discard when it was requested for the drive.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

Patch
diff mbox series

diff --git a/block.c b/block.c
index 3050854528..16615bc876 100644
--- a/block.c
+++ b/block.c
@@ -950,8 +950,9 @@  static void bdrv_temp_snapshot_options(int *child_flags, QDict *child_options,
     qdict_set_default_str(child_options, BDRV_OPT_CACHE_DIRECT, "off");
     qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on");
 
-    /* Copy the read-only option from the parent */
+    /* Copy the read-only and discard options from the parent */
     qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY);
+    qdict_copy_default(child_options, parent_options, BDRV_OPT_DISCARD);
 
     /* aio=native doesn't work for cache.direct=off, so disable it for the
      * temporary snapshot */