block: Introduce buf register API
Allow block driver to map and unmap a buffer for later I/O, as a performance hint. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20180116060901.17413-5-famz@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
parent
bdd6a90a9e
commit
23d0ba9319
@ -2096,3 +2096,13 @@ static void blk_root_drained_end(BdrvChild *child)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void blk_register_buf(BlockBackend *blk, void *host, size_t size)
|
||||
{
|
||||
bdrv_register_buf(blk_bs(blk), host, size);
|
||||
}
|
||||
|
||||
void blk_unregister_buf(BlockBackend *blk, void *host)
|
||||
{
|
||||
bdrv_unregister_buf(blk_bs(blk), host);
|
||||
}
|
||||
|
24
block/io.c
24
block/io.c
@ -2825,3 +2825,27 @@ void bdrv_io_unplug(BlockDriverState *bs)
|
||||
bdrv_io_unplug(child->bs);
|
||||
}
|
||||
}
|
||||
|
||||
void bdrv_register_buf(BlockDriverState *bs, void *host, size_t size)
|
||||
{
|
||||
BdrvChild *child;
|
||||
|
||||
if (bs->drv && bs->drv->bdrv_register_buf) {
|
||||
bs->drv->bdrv_register_buf(bs, host, size);
|
||||
}
|
||||
QLIST_FOREACH(child, &bs->children, next) {
|
||||
bdrv_register_buf(child->bs, host, size);
|
||||
}
|
||||
}
|
||||
|
||||
void bdrv_unregister_buf(BlockDriverState *bs, void *host)
|
||||
{
|
||||
BdrvChild *child;
|
||||
|
||||
if (bs->drv && bs->drv->bdrv_unregister_buf) {
|
||||
bs->drv->bdrv_unregister_buf(bs, host);
|
||||
}
|
||||
QLIST_FOREACH(child, &bs->children, next) {
|
||||
bdrv_unregister_buf(child->bs, host);
|
||||
}
|
||||
}
|
||||
|
@ -631,5 +631,14 @@ void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp);
|
||||
|
||||
bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
|
||||
uint32_t granularity, Error **errp);
|
||||
|
||||
/**
|
||||
*
|
||||
* bdrv_register_buf/bdrv_unregister_buf:
|
||||
*
|
||||
* Register/unregister a buffer for I/O. For example, VFIO drivers are
|
||||
* interested to know the memory areas that would later be used for I/O, so
|
||||
* that they can prepare IOMMU mapping etc., to get better performance.
|
||||
*/
|
||||
void bdrv_register_buf(BlockDriverState *bs, void *host, size_t size);
|
||||
void bdrv_unregister_buf(BlockDriverState *bs, void *host);
|
||||
#endif
|
||||
|
@ -446,6 +446,15 @@ struct BlockDriver {
|
||||
const char *name,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* Register/unregister a buffer for I/O. For example, when the driver is
|
||||
* interested to know the memory areas that will later be used in iovs, so
|
||||
* that it can do IOMMU mapping with VFIO etc., in order to get better
|
||||
* performance. In the case of VFIO drivers, this callback is used to do
|
||||
* DMA mapping for hot buffers.
|
||||
*/
|
||||
void (*bdrv_register_buf)(BlockDriverState *bs, void *host, size_t size);
|
||||
void (*bdrv_unregister_buf)(BlockDriverState *bs, void *host);
|
||||
QLIST_ENTRY(BlockDriver) list;
|
||||
};
|
||||
|
||||
|
@ -229,4 +229,7 @@ void blk_io_limits_enable(BlockBackend *blk, const char *group);
|
||||
void blk_io_limits_update_group(BlockBackend *blk, const char *group);
|
||||
void blk_set_force_allow_inactivate(BlockBackend *blk);
|
||||
|
||||
void blk_register_buf(BlockBackend *blk, void *host, size_t size);
|
||||
void blk_unregister_buf(BlockBackend *blk, void *host);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user