Diff for /qemu/block.c between versions 1.1.1.9 and 1.1.1.10

version 1.1.1.9, 2018/04/24 17:01:52 version 1.1.1.10, 2018/04/24 17:06:50
Line 41 Line 41
 #define SECTOR_BITS 9  #define SECTOR_BITS 9
 #define SECTOR_SIZE (1 << SECTOR_BITS)  #define SECTOR_SIZE (1 << SECTOR_BITS)
   
   static AIOPool vectored_aio_pool;
   
 typedef struct BlockDriverAIOCBSync {  typedef struct BlockDriverAIOCBSync {
     BlockDriverAIOCB common;      BlockDriverAIOCB common;
     QEMUBH *bh;      QEMUBH *bh;
Line 141  static void bdrv_register(BlockDriver *b Line 143  static void bdrv_register(BlockDriver *b
         bdrv->bdrv_read = bdrv_read_em;          bdrv->bdrv_read = bdrv_read_em;
         bdrv->bdrv_write = bdrv_write_em;          bdrv->bdrv_write = bdrv_write_em;
     }      }
       aio_pool_init(&bdrv->aio_pool, bdrv->aiocb_size, bdrv->bdrv_aio_cancel);
     bdrv->next = first_drv;      bdrv->next = first_drv;
     first_drv = bdrv;      first_drv = bdrv;
 }  }
Line 1332  typedef struct VectorTranslationState { Line 1335  typedef struct VectorTranslationState {
     BlockDriverAIOCB *this_aiocb;      BlockDriverAIOCB *this_aiocb;
 } VectorTranslationState;  } VectorTranslationState;
   
   static void bdrv_aio_cancel_vector(BlockDriverAIOCB *acb)
   {
       VectorTranslationState *s = acb->opaque;
   
       bdrv_aio_cancel(s->aiocb);
   }
   
 static void bdrv_aio_rw_vector_cb(void *opaque, int ret)  static void bdrv_aio_rw_vector_cb(void *opaque, int ret)
 {  {
     VectorTranslationState *s = opaque;      VectorTranslationState *s = opaque;
Line 1354  static BlockDriverAIOCB *bdrv_aio_rw_vec Line 1364  static BlockDriverAIOCB *bdrv_aio_rw_vec
   
 {  {
     VectorTranslationState *s = qemu_mallocz(sizeof(*s));      VectorTranslationState *s = qemu_mallocz(sizeof(*s));
     BlockDriverAIOCB *aiocb = qemu_aio_get(bs, cb, opaque);      BlockDriverAIOCB *aiocb = qemu_aio_get_pool(&vectored_aio_pool, bs,
                                                   cb, opaque);
   
     s->this_aiocb = aiocb;      s->this_aiocb = aiocb;
     s->iov = iov;      s->iov = iov;
Line 1443  BlockDriverAIOCB *bdrv_aio_write(BlockDr Line 1454  BlockDriverAIOCB *bdrv_aio_write(BlockDr
   
 void bdrv_aio_cancel(BlockDriverAIOCB *acb)  void bdrv_aio_cancel(BlockDriverAIOCB *acb)
 {  {
     BlockDriver *drv = acb->bs->drv;      acb->pool->cancel(acb);
   
     if (acb->cb == bdrv_aio_rw_vector_cb) {  
         VectorTranslationState *s = acb->opaque;  
         acb = s->aiocb;  
     }  
   
     drv->bdrv_aio_cancel(acb);  
 }  }
   
   
Line 1551  static int bdrv_write_em(BlockDriverStat Line 1555  static int bdrv_write_em(BlockDriverStat
   
 void bdrv_init(void)  void bdrv_init(void)
 {  {
       aio_pool_init(&vectored_aio_pool, sizeof(BlockDriverAIOCB),
                     bdrv_aio_cancel_vector);
   
     bdrv_register(&bdrv_raw);      bdrv_register(&bdrv_raw);
     bdrv_register(&bdrv_host_device);      bdrv_register(&bdrv_host_device);
 #ifndef _WIN32  #ifndef _WIN32
Line 1568  void bdrv_init(void) Line 1575  void bdrv_init(void)
     bdrv_register(&bdrv_nbd);      bdrv_register(&bdrv_nbd);
 }  }
   
 void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,  void aio_pool_init(AIOPool *pool, int aiocb_size,
                    void *opaque)                     void (*cancel)(BlockDriverAIOCB *acb))
   {
       pool->aiocb_size = aiocb_size;
       pool->cancel = cancel;
       pool->free_aiocb = NULL;
   }
   
   void *qemu_aio_get_pool(AIOPool *pool, BlockDriverState *bs,
                           BlockDriverCompletionFunc *cb, void *opaque)
 {  {
     BlockDriver *drv;  
     BlockDriverAIOCB *acb;      BlockDriverAIOCB *acb;
   
     drv = bs->drv;      if (pool->free_aiocb) {
     if (drv->free_aiocb) {          acb = pool->free_aiocb;
         acb = drv->free_aiocb;          pool->free_aiocb = acb->next;
         drv->free_aiocb = acb->next;  
     } else {      } else {
         acb = qemu_mallocz(drv->aiocb_size);          acb = qemu_mallocz(pool->aiocb_size);
           acb->pool = pool;
     }      }
     acb->bs = bs;      acb->bs = bs;
     acb->cb = cb;      acb->cb = cb;
Line 1587  void *qemu_aio_get(BlockDriverState *bs, Line 1601  void *qemu_aio_get(BlockDriverState *bs,
     return acb;      return acb;
 }  }
   
   void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
                      void *opaque)
   {
       return qemu_aio_get_pool(&bs->drv->aio_pool, bs, cb, opaque);
   }
   
 void qemu_aio_release(void *p)  void qemu_aio_release(void *p)
 {  {
     BlockDriverAIOCB *acb = p;      BlockDriverAIOCB *acb = (BlockDriverAIOCB *)p;
     BlockDriver *drv = acb->bs->drv;      AIOPool *pool = acb->pool;
     acb->next = drv->free_aiocb;      acb->next = pool->free_aiocb;
     drv->free_aiocb = acb;      pool->free_aiocb = acb;
 }  }
   
 /**************************************************************/  /**************************************************************/

Removed from v.1.1.1.9  
changed lines
  Added in v.1.1.1.10


unix.superglobalmegacorp.com