lib/bdev: spdk_bdev_get_write_unit_size() interface

Added write_unit_size field to bdev structure.
It describes required number of logical blocks
for write operation. For legacy bdevs this value
will be equal to logical block size.
For bdevs working on top of Open Channel/Zoned
Namespace SSDs or RAID 5 volumes write size unit
could be greater than logical block size and
upper layer should perform write operations
with size of multiple of write unit size.

Change-Id: I55eb6687912a7d0d1157874b2778e7d6c2d44e37
Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463802
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
Wojciech Malikowski 2019-07-31 10:51:50 -04:00 committed by Ben Walker
parent 04cf752414
commit 18ed0c7f6b
4 changed files with 34 additions and 0 deletions

View File

@ -2,6 +2,11 @@
## v19.10: (Upcoming Release)
### bdev
Added `spdk_bdev_get_write_unit_size()` function for retrieving required number
of logical blocks for write operation.
### nvmf
The `spdk_nvmf_tgt_create` function now accepts an object of type `spdk_nvmf_target_opts`

View File

@ -368,6 +368,21 @@ const char *spdk_bdev_get_product_name(const struct spdk_bdev *bdev);
*/
uint32_t spdk_bdev_get_block_size(const struct spdk_bdev *bdev);
/**
* Get the write unit size for this bdev.
*
* Write unit size is required number of logical blocks to perform write
* operation on block device.
*
* Unit of write unit size is logical block and the minimum of write unit
* size is one. Write operations must be multiple of write unit size.
*
* \param bdev Block device to query.
*
* \return The write unit size in logical blocks.
*/
uint32_t spdk_bdev_get_write_unit_size(const struct spdk_bdev *bdev);
/**
* Get size of block device in logical blocks.
*

View File

@ -265,6 +265,9 @@ struct spdk_bdev {
/** Number of blocks */
uint64_t blockcnt;
/** Number of blocks required for write */
uint32_t write_unit_size;
/**
* Specifies an alignment requirement for data buffers associated with an spdk_bdev_io.
* 0 = no alignment requirement

View File

@ -2437,6 +2437,12 @@ spdk_bdev_get_block_size(const struct spdk_bdev *bdev)
return bdev->blocklen;
}
uint32_t
spdk_bdev_get_write_unit_size(const struct spdk_bdev *bdev)
{
return bdev->write_unit_size;
}
uint64_t
spdk_bdev_get_num_blocks(const struct spdk_bdev *bdev)
{
@ -4073,6 +4079,11 @@ spdk_bdev_init(struct spdk_bdev *bdev)
}
}
/* If the user didn't specify a write unit size, set it to one. */
if (bdev->write_unit_size == 0) {
bdev->write_unit_size = 1;
}
TAILQ_INIT(&bdev->internal.open_descs);
TAILQ_INIT(&bdev->aliases);