Patchwork [PULL,16/31] block: Fix open_flags in bdrv_reopen()

login
register
mail settings
Submitter Kevin Wolf
Date April 30, 2014, 6:23 p.m.
Message ID <1398882243-14783-17-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/344265/
State New
Headers show

Comments

Kevin Wolf - April 30, 2014, 6:23 p.m.
Use the same function as bdrv_open() for determining what the right
flags for bs->file are. Without doing this, a reopen means that
bs->file loses BDRV_O_CACHE_WB or BDRV_O_UNMAP if bs doesn't have it as
well.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Jan Kiszka - May 4, 2014, 10:13 a.m.
On 2014-04-30 20:23, Kevin Wolf wrote:
> Use the same function as bdrv_open() for determining what the right
> flags for bs->file are. Without doing this, a reopen means that
> bs->file loses BDRV_O_CACHE_WB or BDRV_O_UNMAP if bs doesn't have it as
> well.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> ---
>  block.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index 9f6f07e..b749d31 100644
> --- a/block.c
> +++ b/block.c
> @@ -1525,8 +1525,11 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
>          QSIMPLEQ_INIT(bs_queue);
>      }
>  
> +    /* bdrv_open() masks this flag out */
> +    flags &= ~BDRV_O_PROTOCOL;
> +
>      if (bs->file) {
> -        bdrv_reopen_queue(bs_queue, bs->file, flags);
> +        bdrv_reopen_queue(bs_queue, bs->file, bdrv_inherited_flags(flags));
>      }
>  
>      bs_entry = g_new0(BlockReopenQueueEntry, 1);
> 

This breaks the "commit" monitor command for disks in snapshot mode.
Returned error is "no permission" (I assume -EPERM).

Jan

Patch

diff --git a/block.c b/block.c
index 9f6f07e..b749d31 100644
--- a/block.c
+++ b/block.c
@@ -1525,8 +1525,11 @@  BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
         QSIMPLEQ_INIT(bs_queue);
     }
 
+    /* bdrv_open() masks this flag out */
+    flags &= ~BDRV_O_PROTOCOL;
+
     if (bs->file) {
-        bdrv_reopen_queue(bs_queue, bs->file, flags);
+        bdrv_reopen_queue(bs_queue, bs->file, bdrv_inherited_flags(flags));
     }
 
     bs_entry = g_new0(BlockReopenQueueEntry, 1);