block/iscsi: set bdi->cluster_size
RFC PATCH 1/1 block/iscsi: set bdi->cluster_size
this patch aims to set bdi->cluster_size to the internal page size of the iscsi target so that enabled callers can align requests properly.
--- block/iscsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
block/iscsi.c +6 -0
@@ -1569,6 +1569,12 @@ static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)IscsiLun *iscsilun = bs->opaque; bdi->unallocated_blocks_are_zero = !!iscsilun->lbprz; bdi->can_write_zeroes_with_unmap = iscsilun->lbprz && iscsilun->lbp.lbpws; + bdi->cluster_size = iscsilun->bl.opt_xfer_len * iscsilun->block_size; +/* if opt_xfer_len is not specified guess the internal page size of the +* iscsi target by the means of opt_unmap_gran */ +if (bdi->cluster_size ==0 ) { + bdi->cluster_size = iscsilun->bl.opt_unmap_gran * iscsilun->block_size; + }return 0 ; }
Signature · 1 line
1.7.9.5
Il 25/11/2013 09:29, Peter Lieven ha scritto:
Quoted 17 lines
this patch aims to set
bdi->cluster_sizeto the internal page size of the iscsi target so that enabled callers can align requests properly.Signed-off-by Peter Lieven <[email protected]>--- block/iscsi.c | 6 ++++++ 1 file changed, 6 insertions(+)block/iscsi.c +0
-0@@ -1569,6 +1569,12 @@ static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)IscsiLun *iscsilun = bs->opaque; bdi->unallocated_blocks_are_zero = !!iscsilun->lbprz;
block/iscsi.c static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) · line 1580
Quoted 10 lines
block/iscsi.c +6
-0bdi->can_write_zeroes_with_unmap = iscsilun->lbprz && iscsilun->lbp.lbpws; + bdi->cluster_size = iscsilun->bl.opt_xfer_len * iscsilun->block_size; +/* if opt_xfer_len is not specified guess the internal page size of the +* iscsi target by the means of opt_unmap_gran */ +if (bdi->cluster_size ==0 ) { + bdi->cluster_size = iscsilun->bl.opt_unmap_gran * iscsilun->block_size; + }return 0 ; }
This is not what cluster_size does; cluster_size is the granularity of allocations, and hence COW requests. In that sense, opt_unmap_gran is probably a better choice than opt_xfer_len, especially if you want to set the default cluster size of a new image (e.g. qcow2) so that the format itself will not try to discard partial clusters.
However, I'm not sure overloading cluster_size is a good thing; you can already use discard_alignment. Also, I think you need some clamping (e.g. if <4KB or >1MB).
Paolo
Quoted 34 lines · Paolo Bonzini
Il 25/11/2013 09:29, Peter Lieven ha scritto:
Quoted 17 lines
this patch aims to set
bdi->cluster_sizeto the internal page size of the iscsi target so that enabled callers can align requests properly.Signed-off-by Peter Lieven <[email protected]>--- block/iscsi.c | 6 ++++++ 1 file changed, 6 insertions(+)block/iscsi.c +0
-0@@ -1569,6 +1569,12 @@ static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)IscsiLun *iscsilun = bs->opaque; bdi->unallocated_blocks_are_zero = !!iscsilun->lbprz;block/iscsi.c static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) · line 1580
Quoted 10 lines
block/iscsi.c +6
-0bdi->can_write_zeroes_with_unmap = iscsilun->lbprz && iscsilun->lbp.lbpws; + bdi->cluster_size = iscsilun->bl.opt_xfer_len * iscsilun->block_size; +/* if opt_xfer_len is not specified guess the internal page size of the +* iscsi target by the means of opt_unmap_gran */ +if (bdi->cluster_size ==0 ) { + bdi->cluster_size = iscsilun->bl.opt_unmap_gran * iscsilun->block_size; + }return 0 ; }This is not what
cluster_sizedoes;cluster_sizeis the granularity of allocations, and hence COW requests. In that sense,opt_unmap_granis probably a better choice thanopt_xfer_len, especially if you want to set the default cluster size of a new image (e.g. qcow2) so that the format itself will not try to discard partial clusters.
Quoted 3 lines
However, I'm not sure overloading
cluster_sizeis a good thing; you can already usediscard_alignment. Also, I think you need some clamping (e.g. if <4KB or >1MB).
Maybe I should explain the background of this patch. I currently work on some patches optimizing qemu-img convert. And I found out that there is significant speed up if the writes to the output image are aligned to the underlying page boundaries of the iscsi_target. So I wanted to use bdi->cluster_size for aligning the requests if its available. The same that already happens for compressed images.
Maybe I should put together the whole series maybe this gives a better picture.
Peter