On Wed, May 09, 2018 at 10:58:07PM +0800, Fam Zheng wrote: Please include a commit description: Introduce the bdrv_co_copy_range() API for copy offloading. Block drivers implementing this API support efficient copy operations that avoid reading each block from the source device and writing it to the destination devices. Examples of copy offload primitives are SCSI EXTENDED COPY and Linux copy_file_range(2). This explains the purpose of the new API. > +/* Copy range from @bs to @dst. */ There is no @bs argument, I guess it should be @src. What about the return value? What about the flags? You don't need to duplicate this information, just reference BlockDriver.bdrv_co_copy_range_from() if you want. > +int bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offset, > + BdrvChild *dst, uint64_t dst_offset, > + uint64_t bytes, BdrvRequestFlags flags) > +{ > + return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset, > + bytes, flags, true); > +} > + > +/* Copy range from @src to @bs. Should only be called by block drivers when @bs > + * is the leaf. */ Same here. > diff --git a/include/block/block.h b/include/block/block.h > index cdec3639a3..72ac011b2b 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -604,4 +604,8 @@ bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, > */ > void bdrv_register_buf(BlockDriverState *bs, void *host, size_t size); > void bdrv_unregister_buf(BlockDriverState *bs, void *host); > + > +int bdrv_co_copy_range(BdrvChild *bs, uint64_t offset, > + BdrvChild *src, uint64_t src_offset, > + uint64_t bytes, BdrvRequestFlags flags); This is the public API. It's missing a doc comment.