From 4841211e0d1628cd386b35835676d7f6f9a4fa9d Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 28 Mar 2019 23:27:49 -0500 Subject: block: Add bdrv_get_request_alignment() The next patch needs access to a device's minimum permitted alignment, since NBD wants to advertise this to clients. Add an accessor function, borrowing from blk_get_max_transfer() for accessing a backend's block limits. Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20190329042750.14704-6-eblake@redhat.com> --- block/block-backend.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'block') diff --git a/block/block-backend.c b/block/block-backend.c index edad02a0f2..f78e82a707 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1764,6 +1764,13 @@ int blk_get_flags(BlockBackend *blk) } } +/* Returns the minimum request alignment, in bytes; guaranteed nonzero */ +uint32_t blk_get_request_alignment(BlockBackend *blk) +{ + BlockDriverState *bs = blk_bs(blk); + return bs ? bs->bl.request_alignment : BDRV_SECTOR_SIZE; +} + /* Returns the maximum transfer length, in bytes; guaranteed nonzero */ uint32_t blk_get_max_transfer(BlockBackend *blk) { -- cgit v1.2.3