13.06.2019 1:09, Max Reitz wrote: > There are BDS children that the general block layer code can access, > namely bs->file and bs->backing. Since the introduction of filters and > external data files, their meaning is not quite clear. bs->backing can > be a COW source, or it can be an R/W-filtered child; bs->file can be an > R/W-filtered child, it can be data and metadata storage, or it can be > just metadata storage. > > This overloading really is not helpful. This patch adds function that > retrieve the correct child for each exact purpose. Later patches in > this series will make use of them. Doing so will allow us to handle > filter nodes and external data files in a meaningful way. > > Signed-off-by: Max Reitz <mre...@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > --- > include/block/block_int.h | 57 ++++++++++++++++++++-- > block.c | 99 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 153 insertions(+), 3 deletions(-) > > diff --git a/include/block/block_int.h b/include/block/block_int.h > index 58fca37ba3..7ce71623f8 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h [..] > > typedef struct BlockLimits { > @@ -1249,4 +1258,46 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, > uint64_t src_offset, > > int refresh_total_sectors(BlockDriverState *bs, int64_t hint); > > +BdrvChild *bdrv_filtered_cow_child(BlockDriverState *bs); > +BdrvChild *bdrv_filtered_rw_child(BlockDriverState *bs); > +BdrvChild *bdrv_filtered_child(BlockDriverState *bs); > +BdrvChild *bdrv_metadata_child(BlockDriverState *bs); > +BdrvChild *bdrv_storage_child(BlockDriverState *bs); > +BdrvChild *bdrv_primary_child(BlockDriverState *bs); > + Wow! Such a big family :) I'd like to put them into a table, just for me to make it easier to keep it all in mind. But if you want, you may include it here as a comment.. But it's difficult to keep it less than 80 columns. I think, I'll modify it after reviewing following patches. +--------------------+----------------------------+-------------------------------+-------------------------------+ | child | description | filter node | format node | +--------------------+----------------------------+-------------------------------+-------------------------------+ | filtered_cow_child | for COW/COR | NULL | bs->backing | +--------------------+----------------------------+-------------------------------+-------------------------------+ | filtered_rw_child | for IO pass-through | bs->backing or bs->file | NULL | | | | (only one may exist) | | +--------------------+----------------------------+-------------------------------+-------------------------------+ | filtered_child | one of the previous | | | | | for extended backing | filtered_rw_child | filtered_cow_child | | | chain | | | +--------------------+----------------------------+-------------------------------+-------------------------------+ | metadata_child | where metadata is stored | NULL | bs->file | +--------------------+----------------------------+-------------------------------+-------------------------------+ | storage_child | where actual guest visible | bs->drv->bdrv_storage_child() | bs->drv->bdrv_storage_child() | | | data is stored | or filtered_rw_child | or bs->file | +--------------------+----------------------------+-------------------------------+-------------------------------+ | primary_child | don't know yet | filtered_rw_child | bs->file | +--------------------+----------------------------+-------------------------------+-------------------------------+ -- Best regards, Vladimir