Skip to contentSkip to conversation

block-backend: simplify blk_get_aio_context

PATCH Applied Daniel Henrique Barboza 3 participants 4 messages Mar 27, 2018 – Apr 9, 2018 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block-backend: simplify blk_get_aio_context

blk_get_aio_context verifies if BlockDriverState bs is not NULL, return bdrv_get_aio_context(bs) if true or qemu_get_aio_context() otherwise. However, bdrv_get_aio_context from block.c already does this verification itself, also returning qemu_get_aio_context() if bs is NULL:

AioContext *bdrv_get_aio_context(BlockDriverState *bs)

{
    return bs ? bs->aio_context : qemu_get_aio_context();
}

This patch simplifies blk_get_aio_context to simply call bdrv_get_aio_context instead of replicating the same logic.

---
 block/block-backend.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
block/block-backend.c +1 -7
index 681b240b12..89f47b00ea 100644
@@ -1865,13 +1865,7 @@ void blk_op_unblock_all(BlockBackend *blk, Error *reason)
 
 AioContext *blk_get_aio_context(BlockBackend *blk)
 {
-    BlockDriverState *bs = blk_bs(blk);
-
-    if (bs) {
-        return bdrv_get_aio_context(bs);
-    } else {
-        return qemu_get_aio_context();
-    }
+    return bdrv_get_aio_context(blk_bs(blk));
 }
 
 static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Daniel Henrique Barboza

blk_get_aio_context verifies if BlockDriverState bs is not NULL, return bdrv_get_aio_context(bs) if true or qemu_get_aio_context() otherwise. However, bdrv_get_aio_context from block.c already does this verification itself, also returning qemu_get_aio_context() if bs is NULL:

AioContext *bdrv_get_aio_context(BlockDriverState *bs)

Quoted 8 lines
{
   return bs ? bs->aio_context : qemu_get_aio_context();
}

This patch simplifies blk_get_aio_context to simply call bdrv_get_aio_context instead of replicating the same logic.

Seems to make sense.

Quoted 27 lines

---
block/block-backend.c | 8 +-------

1 file changed, 1 insertion(+), 7 deletions(-)
block/block-backend.c +1 -7
index 681b240b12..89f47b00ea 100644
@@ -1865,13 +1865,7 @@ void blk_op_unblock_all(BlockBackend *blk, Error *reason)
 
 AioContext *blk_get_aio_context(BlockBackend *blk)
 {
-    BlockDriverState *bs = blk_bs(blk);
-
-    if (bs) {
-        return bdrv_get_aio_context(bs);
-    } else {
-        return qemu_get_aio_context();
-    }
+    return bdrv_get_aio_context(blk_bs(blk));
 }
 
 static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)
Signature · 1 line
2.14.3
#2 lore raw
In reply to Daniel Henrique Barboza

Ping

Quoted 38 lines · Daniel Henrique Barboza

blk_get_aio_context verifies if BlockDriverState bs is not NULL, return bdrv_get_aio_context(bs) if true or qemu_get_aio_context() otherwise. However, bdrv_get_aio_context from block.c already does this verification itself, also returning qemu_get_aio_context() if bs is NULL:

AioContext *bdrv_get_aio_context(BlockDriverState *bs)

{
     return bs ? bs->aio_context : qemu_get_aio_context();
}

This patch simplifies blk_get_aio_context to simply call bdrv_get_aio_context instead of replicating the same logic.

---
  block/block-backend.c | 8 +-------
  1 file changed, 1 insertion(+), 7 deletions(-)
block/block-backend.c +1 -7
index 681b240b12..89f47b00ea 100644
@@ -1865,13 +1865,7 @@ void blk_op_unblock_all(BlockBackend *blk, Error *reason)
 
  AioContext *blk_get_aio_context(BlockBackend *blk)
  {
-    BlockDriverState *bs = blk_bs(blk);
-
-    if (bs) {
-        return bdrv_get_aio_context(bs);
-    } else {
-        return qemu_get_aio_context();
-    }
+    return bdrv_get_aio_context(blk_bs(blk));
  }
 
  static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)
Applied
#3 lore raw
In reply to Daniel Henrique Barboza

Am 27.03.2018 um 15:08 hat Daniel Henrique Barboza geschrieben:

Quoted 7 lines

blk_get_aio_context verifies if BlockDriverState bs is not NULL, return bdrv_get_aio_context(bs) if true or qemu_get_aio_context() otherwise. However, bdrv_get_aio_context from block.c already does this verification itself, also returning qemu_get_aio_context() if bs is NULL:

AioContext *bdrv_get_aio_context(BlockDriverState *bs)

Quoted 8 lines
{
    return bs ? bs->aio_context : qemu_get_aio_context();
}

This patch simplifies blk_get_aio_context to simply call bdrv_get_aio_context instead of replicating the same logic.

Thanks, applied to the block-next branch.

Kevin