[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v4 3/8] block: Add blk_get_opt_transfer()
From: |
Eric Blake |
Subject: |
[Qemu-block] [PATCH v4 3/8] block: Add blk_get_opt_transfer() |
Date: |
Mon, 20 Feb 2017 20:42:43 -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.
This copies the existing blk_get_max_transfer() in reading
a value from the top BDS; where that value was picked via
bdrv_refresh_limits() to reflect the overall constraints of
the entire BDS chain.
Signed-off-by: Eric Blake <address@hidden>
---
v4: retitle, as part of rebasing to byte limits
v3: new patch
---
include/sysemu/block-backend.h | 1 +
block/block-backend.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 6444e41..882480a 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -174,6 +174,7 @@ void blk_lock_medium(BlockBackend *blk, bool locked);
void blk_eject(BlockBackend *blk, bool eject_flag);
int blk_get_flags(BlockBackend *blk);
uint32_t blk_get_max_transfer(BlockBackend *blk);
+uint32_t blk_get_opt_transfer(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 efbf398..4d91ff8 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1426,6 +1426,18 @@ uint32_t blk_get_max_transfer(BlockBackend *blk)
return MIN_NON_ZERO(max, INT_MAX);
}
+/* Returns the optimum transfer length, in bytes; may be 0 if no optimum */
+uint32_t blk_get_opt_transfer(BlockBackend *blk)
+{
+ BlockDriverState *bs = blk_bs(blk);
+
+ if (bs) {
+ return bs->bl.opt_transfer;
+ } else {
+ return 0;
+ }
+}
+
int blk_get_max_iov(BlockBackend *blk)
{
return blk->root->bs->bl.max_iov;
--
2.9.3
- [Qemu-block] [PATCH v4 0/8] Implement NBD_OPT_GO, block size advertisement, Eric Blake, 2017/02/20
- [Qemu-block] [PATCH v4 1/8] nbd/client: fix drop_sync [CVE-2017-2630], Eric Blake, 2017/02/20
- [Qemu-block] [PATCH v4 3/8] block: Add blk_get_opt_transfer(),
Eric Blake <=
- [Qemu-block] [PATCH v4 2/8] nbd: Create struct for tracking export info, Eric Blake, 2017/02/20
- [Qemu-block] [PATCH v4 7/8] nbd: Implement NBD_INFO_BLOCK_SIZE on server, Eric Blake, 2017/02/20
- Re: [Qemu-block] [PATCH v4 7/8] nbd: Implement NBD_INFO_BLOCK_SIZE on server, Paolo Bonzini, 2017/02/22
- Re: [Qemu-block] [PATCH v4 7/8] nbd: Implement NBD_INFO_BLOCK_SIZE on server, Eric Blake, 2017/02/22
- Re: [Qemu-block] [PATCH v4 7/8] nbd: Implement NBD_INFO_BLOCK_SIZE on server, Paolo Bonzini, 2017/02/22
- Re: [Qemu-block] [PATCH v4 7/8] nbd: Implement NBD_INFO_BLOCK_SIZE on server, Eric Blake, 2017/02/22
- Re: [Qemu-block] [PATCH v4 7/8] nbd: Implement NBD_INFO_BLOCK_SIZE on server, Paolo Bonzini, 2017/02/23
- Re: [Qemu-block] [PATCH v4 7/8] nbd: Implement NBD_INFO_BLOCK_SIZE on server, Eric Blake, 2017/02/23