diff mbox

block: acquire in bdrv_query_image_info

Message ID 1450867706-19860-1-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Dec. 23, 2015, 10:48 a.m. UTC
NFS calls aio_poll inside bdrv_get_allocated_size.  This requires
acquiring the AioContext.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/qapi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Fam Zheng Dec. 25, 2015, 1:51 a.m. UTC | #1
On Wed, 12/23 11:48, Paolo Bonzini wrote:
> NFS calls aio_poll inside bdrv_get_allocated_size.  This requires
> acquiring the AioContext.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block/qapi.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/block/qapi.c b/block/qapi.c
> index fecac25..ea400e0 100644
> --- a/block/qapi.c
> +++ b/block/qapi.c
> @@ -210,11 +210,13 @@ void bdrv_query_image_info(BlockDriverState *bs,
>      Error *err = NULL;
>      ImageInfo *info;
>  
> +    aio_context_acquire(bdrv_get_aio_context(bs));
> +
>      size = bdrv_getlength(bs);
>      if (size < 0) {
>          error_setg_errno(errp, -size, "Can't get size of device '%s'",
>                           bdrv_get_device_name(bs));
> -        return;
> +        goto out;
>      }
>  
>      info = g_new0(ImageInfo, 1);
> @@ -281,10 +283,13 @@ void bdrv_query_image_info(BlockDriverState *bs,
>      default:
>          error_propagate(errp, err);
>          qapi_free_ImageInfo(info);
> -        return;
> +        goto out;
>      }
>  
>      *p_info = info;
> +
> +out:
> +    aio_context_release(bdrv_get_aio_context(bs));
>  }
>  
>  /* @p_info will be set only on success. */
> -- 
> 2.5.0
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>
Paolo Bonzini Jan. 11, 2016, 8:32 a.m. UTC | #2
On 25/12/2015 02:51, Fam Zheng wrote:
> On Wed, 12/23 11:48, Paolo Bonzini wrote:
>> NFS calls aio_poll inside bdrv_get_allocated_size.  This requires
>> acquiring the AioContext.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  block/qapi.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/qapi.c b/block/qapi.c
>> index fecac25..ea400e0 100644
>> --- a/block/qapi.c
>> +++ b/block/qapi.c
>> @@ -210,11 +210,13 @@ void bdrv_query_image_info(BlockDriverState *bs,
>>      Error *err = NULL;
>>      ImageInfo *info;
>>  
>> +    aio_context_acquire(bdrv_get_aio_context(bs));
>> +
>>      size = bdrv_getlength(bs);
>>      if (size < 0) {
>>          error_setg_errno(errp, -size, "Can't get size of device '%s'",
>>                           bdrv_get_device_name(bs));
>> -        return;
>> +        goto out;
>>      }
>>  
>>      info = g_new0(ImageInfo, 1);
>> @@ -281,10 +283,13 @@ void bdrv_query_image_info(BlockDriverState *bs,
>>      default:
>>          error_propagate(errp, err);
>>          qapi_free_ImageInfo(info);
>> -        return;
>> +        goto out;
>>      }
>>  
>>      *p_info = info;
>> +
>> +out:
>> +    aio_context_release(bdrv_get_aio_context(bs));
>>  }
>>  
>>  /* @p_info will be set only on success. */
>> -- 
>> 2.5.0
>>
>>
> 
> Reviewed-by: Fam Zheng <famz@redhat.com>
> 
> 

Ping?

Paolo
Max Reitz Jan. 14, 2016, 3:25 p.m. UTC | #3
On 23.12.2015 11:48, Paolo Bonzini wrote:
> NFS calls aio_poll inside bdrv_get_allocated_size.  This requires
> acquiring the AioContext.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block/qapi.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Thanks, applied to my block tree:

https://github.com/XanClic/qemu/commits/block

Max
diff mbox

Patch

diff --git a/block/qapi.c b/block/qapi.c
index fecac25..ea400e0 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -210,11 +210,13 @@  void bdrv_query_image_info(BlockDriverState *bs,
     Error *err = NULL;
     ImageInfo *info;
 
+    aio_context_acquire(bdrv_get_aio_context(bs));
+
     size = bdrv_getlength(bs);
     if (size < 0) {
         error_setg_errno(errp, -size, "Can't get size of device '%s'",
                          bdrv_get_device_name(bs));
-        return;
+        goto out;
     }
 
     info = g_new0(ImageInfo, 1);
@@ -281,10 +283,13 @@  void bdrv_query_image_info(BlockDriverState *bs,
     default:
         error_propagate(errp, err);
         qapi_free_ImageInfo(info);
-        return;
+        goto out;
     }
 
     *p_info = info;
+
+out:
+    aio_context_release(bdrv_get_aio_context(bs));
 }
 
 /* @p_info will be set only on success. */