[Top][All Lists]

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

[Qemu-devel] [PATCH v3 38/44] block: Add blk_get_opt_transfer_length()

From: Eric Blake
Subject: [Qemu-devel] [PATCH v3 38/44] block: Add blk_get_opt_transfer_length()
Date: Fri, 22 Apr 2016 17:40:46 -0600

The NBD protocol would like to advertise the optimal I/O
size to the client; but it would be a layering violation to
peek into blk_bs(blk)->bl, when we only have a BB.

I just copied the existing blk_get_max_transfer_length() in
reading a value from the top BDS; I have no idea if
bdrv_refresh_limits() properly picks a size valid over the
entire BDS chain as part of its recursion, but if not, it
would be audit of existing code in addition to the new
accessor function added here.

Signed-off-by: Eric Blake <address@hidden>
 include/sysemu/block-backend.h |  1 +
 block/block-backend.c          | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index bf04086..76b3647 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -145,6 +145,7 @@ void blk_lock_medium(BlockBackend *blk, bool locked);
 void blk_eject(BlockBackend *blk, bool eject_flag);
 int blk_get_flags(BlockBackend *blk);
 int blk_get_max_transfer_length(BlockBackend *blk);
+int blk_get_opt_transfer_length(BlockBackend *blk);
 int blk_get_max_iov(BlockBackend *blk);
 void blk_set_guest_block_size(BlockBackend *blk, int align);
 void *blk_try_blockalign(BlockBackend *blk, size_t size);
diff --git a/block/block-backend.c b/block/block-backend.c
index 1c3b495..e76e61d 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1272,6 +1272,17 @@ int blk_get_max_transfer_length(BlockBackend *blk)

+int blk_get_opt_transfer_length(BlockBackend *blk)
+    BlockDriverState *bs = blk_bs(blk);
+    if (bs) {
+        return bs->bl.opt_transfer_length;
+    } else {
+        return 0;
+    }
 int blk_get_max_iov(BlockBackend *blk)
     return blk->root->bs->bl.max_iov;

reply via email to

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