diff mbox

block: Don't emulate natively supported pwritev flags

Message ID 1465307797-28378-1-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf June 7, 2016, 1:56 p.m. UTC
Drivers that implement .bdrv_co_pwritev() get the flags passed as an
argument to said function, but we also unconditionally emulate the flags
anyway. We shouldn't do that.

Fix this by clearing all flags that the driver supports natively after
it returns from .bdrv_co_pwritev().

Fixes: 4df863f3 ('block: Make supported_write_flags a per-bds property')
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Eric Blake June 7, 2016, 2:32 p.m. UTC | #1
On 06/07/2016 07:56 AM, Kevin Wolf wrote:
> Drivers that implement .bdrv_co_pwritev() get the flags passed as an
> argument to said function, but we also unconditionally emulate the flags
> anyway. We shouldn't do that.
> 
> Fix this by clearing all flags that the driver supports natively after
> it returns from .bdrv_co_pwritev().
> 
> Fixes: 4df863f3 ('block: Make supported_write_flags a per-bds property')
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/io.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>

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

> diff --git a/block/io.c b/block/io.c
> index 2b10870..dec30e3 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -816,7 +816,9 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
>      int ret;
>  
>      if (drv->bdrv_co_pwritev) {
> -        ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov, flags);
> +        ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov,
> +                                   flags & bs->supported_write_flags);
> +        flags &= ~bs->supported_write_flags;
>          goto emulate_flags;
>      }
>  
>
Stefan Hajnoczi June 8, 2016, 2:11 p.m. UTC | #2
On Tue, Jun 07, 2016 at 03:56:37PM +0200, Kevin Wolf wrote:
> Drivers that implement .bdrv_co_pwritev() get the flags passed as an
> argument to said function, but we also unconditionally emulate the flags
> anyway. We shouldn't do that.
> 
> Fix this by clearing all flags that the driver supports natively after
> it returns from .bdrv_co_pwritev().
> 
> Fixes: 4df863f3 ('block: Make supported_write_flags a per-bds property')
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/io.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Stefan Hajnoczi June 8, 2016, 2:12 p.m. UTC | #3
On Tue, Jun 07, 2016 at 03:56:37PM +0200, Kevin Wolf wrote:
> Drivers that implement .bdrv_co_pwritev() get the flags passed as an
> argument to said function, but we also unconditionally emulate the flags
> anyway. We shouldn't do that.
> 
> Fix this by clearing all flags that the driver supports natively after
> it returns from .bdrv_co_pwritev().
> 
> Fixes: 4df863f3 ('block: Make supported_write_flags a per-bds property')
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/io.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
diff mbox

Patch

diff --git a/block/io.c b/block/io.c
index 2b10870..dec30e3 100644
--- a/block/io.c
+++ b/block/io.c
@@ -816,7 +816,9 @@  static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
     int ret;
 
     if (drv->bdrv_co_pwritev) {
-        ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov, flags);
+        ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov,
+                                   flags & bs->supported_write_flags);
+        flags &= ~bs->supported_write_flags;
         goto emulate_flags;
     }