bdev: add getter for maximum unmap descriptors

Change-Id: Ifbdd29e2081600bf0d860582d80696546107cf1b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2017-05-12 16:08:38 -07:00
parent 8651c2eb47
commit 1aea6c5b6f
4 changed files with 25 additions and 5 deletions

View File

@ -233,6 +233,14 @@ uint32_t spdk_bdev_get_block_size(const struct spdk_bdev *bdev);
*/ */
uint64_t spdk_bdev_get_num_blocks(const struct spdk_bdev *bdev); uint64_t spdk_bdev_get_num_blocks(const struct spdk_bdev *bdev);
/**
* Get maximum number of descriptors per unmap request.
*
* \param bdev Block device to query.
* \return Maximum number of unmap descriptors per request.
*/
uint32_t spdk_bdev_get_max_unmap_descriptors(const struct spdk_bdev *bdev);
/** /**
* Get minimum I/O buffer address alignment for a bdev. * Get minimum I/O buffer address alignment for a bdev.
* *

View File

@ -557,6 +557,12 @@ spdk_bdev_get_num_blocks(const struct spdk_bdev *bdev)
return bdev->blockcnt; return bdev->blockcnt;
} }
uint32_t
spdk_bdev_get_max_unmap_descriptors(const struct spdk_bdev *bdev)
{
return bdev->max_unmap_bdesc_count;
}
size_t size_t
spdk_bdev_get_buf_align(const struct spdk_bdev *bdev) spdk_bdev_get_buf_align(const struct spdk_bdev *bdev)
{ {

View File

@ -546,6 +546,8 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
len = 20 - hlen; len = 20 - hlen;
if (spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_UNMAP)) { if (spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_UNMAP)) {
uint32_t max_unmap_desc;
/* /*
* MAXIMUM UNMAP LBA COUNT: indicates the * MAXIMUM UNMAP LBA COUNT: indicates the
* maximum number of LBAs that may be * maximum number of LBAs that may be
@ -560,11 +562,9 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
* in the parameter data transferred to the * in the parameter data transferred to the
* device server for an UNMAP command. * device server for an UNMAP command.
*/ */
if (bdev->max_unmap_bdesc_count < max_unmap_desc = spdk_min(spdk_bdev_get_max_unmap_descriptors(bdev),
g_spdk_scsi.scsi_params.max_unmap_block_descriptor_count) g_spdk_scsi.scsi_params.max_unmap_block_descriptor_count);
to_be32(&data[24], bdev->max_unmap_bdesc_count); to_be32(&data[24], max_unmap_desc);
else
to_be32(&data[24], g_spdk_scsi.scsi_params.max_unmap_block_descriptor_count);
/* /*
* OPTIMAL UNMAP GRANULARITY: indicates the * OPTIMAL UNMAP GRANULARITY: indicates the

View File

@ -106,6 +106,12 @@ spdk_bdev_get_product_name(const struct spdk_bdev *bdev)
return "test product"; return "test product";
} }
uint32_t
spdk_bdev_get_max_unmap_descriptors(const struct spdk_bdev *bdev)
{
return 1;
}
void void
spdk_scsi_lun_clear_all(struct spdk_scsi_lun *lun) spdk_scsi_lun_clear_all(struct spdk_scsi_lun *lun)
{ {