[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 38/44] block: Add blk_get_opt_transfer_length()
From: |
Eric Blake |
Subject: |
[Qemu-block] [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;
--
2.5.5
- [Qemu-block] [PATCH v3 27/44] nbd: Use BDRV_REQ_FUA for better FUA where supported, (continued)
- [Qemu-block] [PATCH v3 27/44] nbd: Use BDRV_REQ_FUA for better FUA where supported, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 26/44] qemu-io: Add 'write -z -u' to test MAY_UNMAP flag, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 31/44] nbd: Share common reply-sending code in server, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 33/44] nbd: Let client skip portions of server reply, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 35/44] nbd: Support shorter handshake, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 30/44] nbd: Treat flags vs. command type as separate fields, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 29/44] nbd: Avoid magic number for NBD max name size, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 38/44] block: Add blk_get_opt_transfer_length(),
Eric Blake <=
- [Qemu-block] [PATCH v3 41/44] nbd: Implement NBD_CMD_WRITE_ZEROES on server, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 43/44] nbd: Implement NBD_OPT_BLOCK_SIZE on server, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 44/44] nbd: Implement NBD_OPT_BLOCK_SIZE on client, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 34/44] nbd: Less allocation during NBD_OPT_LIST, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 32/44] nbd: Share common option-sending code in client, Eric Blake, 2016/04/22