mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
block: Add bdrv_supports_compressed_writes()
Filters cannot compress data themselves but they have to implement .bdrv_co_pwritev_compressed() still (or they cannot forward compressed writes). Therefore, checking whether bs->drv->bdrv_co_pwritev_compressed is non-NULL is not sufficient to know whether the node can actually handle compressed writes. This function looks down the filter chain to see whether there is a non-filter that can actually convert the compressed writes into compressed data (and thus normal writes). Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
8b8277cdb0
commit
ae23f78646
23
block.c
23
block.c
@ -5065,6 +5065,29 @@ bool bdrv_is_sg(BlockDriverState *bs)
|
||||
return bs->sg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given node supports compressed writes.
|
||||
*/
|
||||
bool bdrv_supports_compressed_writes(BlockDriverState *bs)
|
||||
{
|
||||
BlockDriverState *filtered;
|
||||
|
||||
if (!bs->drv || !block_driver_can_compress(bs->drv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filtered = bdrv_filter_bs(bs);
|
||||
if (filtered) {
|
||||
/*
|
||||
* Filters can only forward compressed writes, so we have to
|
||||
* check the child.
|
||||
*/
|
||||
return bdrv_supports_compressed_writes(filtered);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *bdrv_get_format_name(BlockDriverState *bs)
|
||||
{
|
||||
return bs->drv ? bs->drv->format_name : NULL;
|
||||
|
@ -532,6 +532,7 @@ BlockDriverState *bdrv_next(BdrvNextIterator *it);
|
||||
void bdrv_next_cleanup(BdrvNextIterator *it);
|
||||
|
||||
BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs);
|
||||
bool bdrv_supports_compressed_writes(BlockDriverState *bs);
|
||||
void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
|
||||
void *opaque, bool read_only);
|
||||
const char *bdrv_get_node_name(const BlockDriverState *bs);
|
||||
|
Loading…
Reference in New Issue
Block a user