diff mbox

[1.8,4/6] block/iscsi: set bdi->cluster_size

Message ID 1385387840-17307-5-git-send-email-pl@kamp.de
State New
Headers show

Commit Message

Peter Lieven Nov. 25, 2013, 1:57 p.m. UTC
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.

Signed-off-by: Peter Lieven <pl@kamp.de>
---
 block/iscsi.c |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Paolo Bonzini Nov. 25, 2013, 2:51 p.m. UTC | #1
Il 25/11/2013 14:57, Peter Lieven ha scritto:
> +    /* Guess the internal cluster (page) size of the iscsi target by the means
> +     * of opt_unmap_gran. Transfer the unmap granularity only if it has a
> +     * reasonable size for bdi->cluster_size */
> +    if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 64 * 1024 &&
> +        iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {
> +        bdi->cluster_size = iscsilun->bl.opt_unmap_gran * iscsilun->block_size;
> +    }

I think you are mixing many different concepts:

* The optimal unmap granularity is good as a suggestion for the cluster
size of higher-level formats.

* The optimal transfer granularity (block limits page, bytes 6-7,
min_io_size in Linux) could be used to adjust the length of transfers in
"qemu-img convert".  I have not really thought much about *how* to do it.

* The optimal transfer (block limits page, bytes 12-15, opt_io_size in
Linux) should not be used in "qemu-img convert", I think, unless you can
actually report performance improvements.  This is because in "qemu-img
convert" we need to write the data anyway to the target.  We cannot
schedule other commands between two transfers.  So I don't think any
delays incurred by a very large write should matter.

The maximum transfer length (block limits page, bytes 8-11) should be
handled instead in the iSCSI driver, but I do not see the need to do
this unless we have reports of something not working.

Paolo
Paolo Bonzini Nov. 25, 2013, 3:02 p.m. UTC | #2
Il 25/11/2013 14:57, Peter Lieven ha scritto:
> 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.
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  block/iscsi.c |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 93fee6d..75d6b87 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -1580,6 +1580,13 @@ 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;
> +    /* Guess the internal cluster (page) size of the iscsi target by the means
> +     * of opt_unmap_gran. Transfer the unmap granularity only if it has a
> +     * reasonable size for bdi->cluster_size */
> +    if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 64 * 1024 &&
> +        iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {
> +        bdi->cluster_size = iscsilun->bl.opt_unmap_gran * iscsilun->block_size;
> +    }
>      return 0;
>  }
>  
> 

After looking at patch 5, I think this one is correct.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

but I think you should make higher layers (qcow2) use the lower BDS's
granularity, at least as a default.

Paolo
diff mbox

Patch

diff --git a/block/iscsi.c b/block/iscsi.c
index 93fee6d..75d6b87 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1580,6 +1580,13 @@  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;
+    /* Guess the internal cluster (page) size of the iscsi target by the means
+     * of opt_unmap_gran. Transfer the unmap granularity only if it has a
+     * reasonable size for bdi->cluster_size */
+    if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 64 * 1024 &&
+        iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {
+        bdi->cluster_size = iscsilun->bl.opt_unmap_gran * iscsilun->block_size;
+    }
     return 0;
 }