Patchwork [06/12] iscsi: add .bdrv_get_info

login
register
mail settings
Submitter Peter Lieven
Date Sept. 13, 2013, 10:25 a.m.
Message ID <1379067909-22984-7-git-send-email-pl@kamp.de>
Download mbox | patch
Permalink /patch/274716/
State New
Headers show

Comments

Peter Lieven - Sept. 13, 2013, 10:25 a.m.
Signed-off-by: Peter Lieven <pl@kamp.de>
---
 block/iscsi.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
Eric Blake - Sept. 13, 2013, 6:19 p.m.
On 09/13/2013 04:25 AM, Peter Lieven wrote:
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  block/iscsi.c |   24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 

> +
> +    bdi->discard_zeroes =  iscsilun->lbprz;
> +    bdi->discard_write_zeroes =  (bs->open_flags & BDRV_O_UNMAP) &&

Why two spaces after = (two instances)?

But that's cosmetic, so you can fix before adding:

Reviewed-by: Eric Blake <eblake@redhat.com>

Patch

diff --git a/block/iscsi.c b/block/iscsi.c
index 3d7961d..438d45e 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1577,6 +1577,29 @@  out:
     return ret;
 }
 
+static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    int max_discard = iscsilun->bl.max_unmap;
+    int max_write_zeroes = iscsilun->bl.max_ws_len;
+
+    if (max_discard == 0xffffffff) {
+        max_discard = ISCSI_MAX_UNMAP;
+    }
+    bdi->max_discard = sector_lun2qemu(max_discard, iscsilun);
+
+    if (max_write_zeroes == 0xffffffff) {
+        max_write_zeroes = ISCSI_MAX_WRITESAME;
+    }
+    bdi->max_write_zeroes = sector_lun2qemu(max_write_zeroes, iscsilun);
+
+    bdi->discard_zeroes =  iscsilun->lbprz;
+    bdi->discard_write_zeroes =  (bs->open_flags & BDRV_O_UNMAP) &&
+                                 iscsilun->lbprz && iscsilun->lbp.lbpws;
+
+    return 0;
+}
+
 static QEMUOptionParameter iscsi_create_options[] = {
     {
         .name = BLOCK_OPT_SIZE,
@@ -1597,6 +1620,7 @@  static BlockDriver bdrv_iscsi = {
     .create_options  = iscsi_create_options,
 
     .bdrv_getlength  = iscsi_getlength,
+    .bdrv_get_info   = iscsi_get_info,
     .bdrv_truncate   = iscsi_truncate,
 
     .bdrv_co_get_block_status = iscsi_co_get_block_status,