Commit 45d4b197 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

bdev: add API to get optimal I/O boundary



Allow passing the NVMe namespace optimal I/O boundary through the bdev
layer.

Change-Id: I27a2d5498df56775d3330e40c31bd7c23bbc77a5
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/374532


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent e5f6a99b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -219,6 +219,15 @@ uint64_t spdk_bdev_get_num_blocks(const struct spdk_bdev *bdev);
 */
size_t spdk_bdev_get_buf_align(const struct spdk_bdev *bdev);

/**
 * Get optimal I/O boundary for a bdev.
 *
 * \param bdev Block device to query.
 * \return Optimal I/O boundary in blocks that should not be crossed for best performance, or 0 if
 *         no optimal boundary is reported.
 */
uint32_t spdk_bdev_get_optimal_io_boundary(const struct spdk_bdev *bdev);

/**
 * Query whether block device has an enabled write cache.
 *
+5 −0
Original line number Diff line number Diff line
@@ -192,6 +192,11 @@ struct spdk_bdev {
	 */
	int need_aligned_buffer;

	/**
	 * Optimal I/O boundary in blocks, or 0 for no value reported.
	 */
	uint32_t optimal_io_boundary;

	/**
	 * Pointer to the bdev module that registered this bdev.
	 */
+6 −0
Original line number Diff line number Diff line
@@ -740,6 +740,12 @@ spdk_bdev_get_buf_align(const struct spdk_bdev *bdev)
	return 1;
}

uint32_t
spdk_bdev_get_optimal_io_boundary(const struct spdk_bdev *bdev)
{
	return bdev->optimal_io_boundary;
}

bool
spdk_bdev_has_write_cache(const struct spdk_bdev *bdev)
{
+1 −0
Original line number Diff line number Diff line
@@ -1138,6 +1138,7 @@ nvme_ctrlr_create_bdevs(struct nvme_ctrlr *nvme_ctrlr)
		}
		bdev->disk.blocklen = spdk_nvme_ns_get_sector_size(ns);
		bdev->disk.blockcnt = spdk_nvme_ns_get_num_sectors(ns);
		bdev->disk.optimal_io_boundary = spdk_nvme_ns_get_optimal_io_boundary(ns);
		bdev->disk.ctxt = bdev;
		bdev->disk.fn_table = &nvmelib_fn_table;
		bdev->disk.module = SPDK_GET_BDEV_MODULE(nvme);