Commit db8a9711 authored by Atul Malakar's avatar Atul Malakar Committed by Tomasz Zawadzki
Browse files

bdev: Add helper function to get IO type strings



A helper function spdk_bdev_get_io_type_name and
string array g_io_type_strings is added to translate
spdk_bdev_io_type enum to string value.

Change-Id: Ie787eb2c7c170ba2e3ba01d492ca8628a0d4f976
Signed-off-by: default avatarAtul Malakar <a.malakar@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23660


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent ece43e80
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -574,6 +574,14 @@ int spdk_bdev_set_timeout(struct spdk_bdev_desc *desc, uint64_t timeout_in_sec,
 */
bool spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type);

/**
 * return the name of an IO type based on the io_type.
 *
 * \param io_type The specific I/O type like read, write, flush, unmap.
 * \return Name of the IO type as a null-terminated string.
 */
const char *spdk_bdev_get_io_type_name(enum spdk_bdev_io_type io_type);

/**
 * Output driver-specific information to a JSON stream.
 *
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 15
SO_MINOR := 0
SO_MINOR := 1

C_SRCS = bdev.c bdev_rpc.c bdev_zone.c part.c scsi_nvme.c
C_SRCS-$(CONFIG_VTUNE) += vtune.c
+33 −0
Original line number Diff line number Diff line
@@ -3704,6 +3704,39 @@ spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_ty
	return supported;
}

static const char *g_io_type_strings[] = {
	[SPDK_BDEV_IO_TYPE_READ] = "read",
	[SPDK_BDEV_IO_TYPE_WRITE] = "write",
	[SPDK_BDEV_IO_TYPE_UNMAP] = "unmap",
	[SPDK_BDEV_IO_TYPE_FLUSH] = "flush",
	[SPDK_BDEV_IO_TYPE_RESET] = "reset",
	[SPDK_BDEV_IO_TYPE_NVME_ADMIN] = "nvme_admin",
	[SPDK_BDEV_IO_TYPE_NVME_IO] = "nvme_io",
	[SPDK_BDEV_IO_TYPE_NVME_IO_MD] = "nvme_io_md",
	[SPDK_BDEV_IO_TYPE_WRITE_ZEROES] = "write_zeroes",
	[SPDK_BDEV_IO_TYPE_ZCOPY] = "zcopy",
	[SPDK_BDEV_IO_TYPE_GET_ZONE_INFO] = "get_zone_info",
	[SPDK_BDEV_IO_TYPE_ZONE_MANAGEMENT] = "zone_management",
	[SPDK_BDEV_IO_TYPE_ZONE_APPEND] = "zone_append",
	[SPDK_BDEV_IO_TYPE_COMPARE] = "compare",
	[SPDK_BDEV_IO_TYPE_COMPARE_AND_WRITE] = "compare_and_write",
	[SPDK_BDEV_IO_TYPE_ABORT] = "abort",
	[SPDK_BDEV_IO_TYPE_SEEK_HOLE] = "seek_hole",
	[SPDK_BDEV_IO_TYPE_SEEK_DATA] = "seek_data",
	[SPDK_BDEV_IO_TYPE_COPY] = "copy",
	[SPDK_BDEV_IO_TYPE_NVME_IOV_MD] = "nvme_iov_md",
};

const char *
spdk_bdev_get_io_type_name(enum spdk_bdev_io_type io_type)
{
	if (io_type <= SPDK_BDEV_IO_TYPE_INVALID || io_type >= SPDK_BDEV_NUM_IO_TYPES) {
		return NULL;
	}

	return g_io_type_strings[io_type];
}

uint64_t
spdk_bdev_io_get_submit_tsc(struct spdk_bdev_io *bdev_io)
{
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@
	spdk_bdev_get_max_copy;
	spdk_bdev_copy_blocks;
	spdk_bdev_get_nvme_ctratt;
	spdk_bdev_get_io_type_name;

	# Public functions in bdev_module.h
	spdk_bdev_register;