Commit 70a0bc30 authored by Jim Harris's avatar Jim Harris
Browse files

bdev: add bdev_io optimizations



First, improve packing of spdk_bdev_io.  Move any
fields which must be zeroed into the first cacheline.
Also change type and status from enums (needing 4 bytes)
to int16_t which is still a far bigger range than
needed.

Next, modify spdk_bdev_get_io to only zero the
first cacheline (actually a bit less).

SPDK_BDEV_IO_TYPE_INVALID is also added, making it
explicit that 0 is an invalid value for the IO type.
Previously this was somewhat inferred.

There are still additional improvements that can
be made to this area - primarily combining
spdk_bdev_get_io() and spdk_bdev_io_init() into
a single function.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I1916d6d5db02c93622b9725ec1095148e3f384d8

Reviewed-on: https://review.gerrithub.io/377799


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 0491b3cb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -81,7 +81,8 @@ struct spdk_bdev_desc;

/** bdev I/O type */
enum spdk_bdev_io_type {
	SPDK_BDEV_IO_TYPE_READ = 1,
	SPDK_BDEV_IO_TYPE_INVALID = 0,
	SPDK_BDEV_IO_TYPE_READ,
	SPDK_BDEV_IO_TYPE_WRITE,
	SPDK_BDEV_IO_TYPE_UNMAP,
	SPDK_BDEV_IO_TYPE_FLUSH,
+12 −12
Original line number Diff line number Diff line
@@ -260,7 +260,18 @@ struct spdk_bdev_io {
	TAILQ_ENTRY(spdk_bdev_io) buf_link;

	/** Enumerated value representing the I/O type. */
	enum spdk_bdev_io_type type;
	int16_t type;

	/** Status for the IO */
	int16_t status;

	/**
	 * Set to true while the bdev module submit_request function is in progress.
	 *
	 * This is used to decide whether spdk_bdev_io_complete() can complete the I/O directly
	 * or if completion must be deferred via an event.
	 */
	bool in_submit_request;

	union {
		struct {
@@ -321,9 +332,6 @@ struct spdk_bdev_io {
		} nvme_passthru;
	} u;

	/** Status for the IO */
	enum spdk_bdev_io_status status;

	/** Error information from a device */
	union {
		/** Only valid when status is SPDK_BDEV_IO_STATUS_NVME_ERROR */
@@ -352,14 +360,6 @@ struct spdk_bdev_io {
	/** Context that will be passed to the completion callback */
	void *caller_ctx;

	/**
	 * Set to true while the bdev module submit_request function is in progress.
	 *
	 * This is used to decide whether spdk_bdev_io_complete() can complete the I/O directly
	 * or if completion must be deferred via an event.
	 */
	bool in_submit_request;

	/** Member used for linking child I/Os together. */
	TAILQ_ENTRY(spdk_bdev_io) link;

+1 −1
Original line number Diff line number Diff line
@@ -581,7 +581,7 @@ spdk_bdev_get_io(void)
		abort();
	}

	memset(bdev_io, 0, sizeof(*bdev_io));
	memset(bdev_io, 0, offsetof(struct spdk_bdev_io, u));

	return bdev_io;
}