qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/4] iscsi: add .bdrv_get_info


From: Peter Lieven
Subject: [Qemu-devel] [PATCH 2/4] iscsi: add .bdrv_get_info
Date: Mon, 15 Jul 2013 12:49:33 +0200

this is used to reveal max_unmap and discard_zeroes capabilities.

Signed-off-by: Peter Lieven <address@hidden>
---
 block/iscsi.c |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 2b8fab9..74a35b9 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -927,6 +927,11 @@ retry:
     return 0;
 }
 
+static bool iscsi_discard_zeroes(IscsiLun *iscsilun)
+{
+    return iscsilun->lbprz && iscsilun->lbpu;
+}
+
 static int
 coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num,
                                    int nb_sectors)
@@ -937,8 +942,7 @@ coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, 
int64_t sector_num,
         return -EINVAL;
     }
 
-    if (!iscsilun->lbprz || !iscsilun->lbpu ||
-        !(bs->open_flags & BDRV_O_UNMAP)) {
+    if (!iscsi_discard_zeroes(iscsilun) || !(bs->open_flags & BDRV_O_UNMAP)) {
         /* fall back to writev */
         return -ENOTSUP;
     }
@@ -1468,6 +1472,16 @@ out:
     return ret;
 }
 
+static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+{
+    IscsiLun *iscsilun = bs->opaque;
+
+    bdi->max_unmap = sector_lun2qemu(iscsilun->max_unmap, iscsilun);
+    bdi->discard_zeroes =  iscsi_discard_zeroes(iscsilun);
+
+    return 0;
+}
+
 static QEMUOptionParameter iscsi_create_options[] = {
     {
         .name = BLOCK_OPT_SIZE,
@@ -1488,6 +1502,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_is_allocated = iscsi_co_is_allocated,
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]