Commit c50cb569 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

include: add STATIC_ASSERTS for opts structures with size member



Various opts structures in SPDK have a size member, to enable
ABI compatibility should fields be added in the future.

But this requires the strucures to be packed, otherwise for
example a structure may be padded at the end, and a new
field added may just consume some of that padding.

So add STATIC_ASSERTS for the current sizes in this
patch.  Upcoming patches will make the structures packed
and add in reserved fields to fill in holes.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I9107d01d7b533f8542385a3538894bcd9f8c465d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14086


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarDong Yi <dongx.yi@intel.com>
Community-CI: Mellanox Build Bot
parent af0d9076
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ struct spdk_bdev_opts {
	uint32_t small_buf_pool_size;
	uint32_t large_buf_pool_size;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_bdev_opts) == 32, "Incorrect size");

/**
 * Structure with optional IO request parameters
@@ -193,6 +194,7 @@ struct spdk_bdev_ext_io_opts {
	/** Metadata buffer, optional */
	void *metadata;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_bdev_ext_io_opts) == 32, "Incorrect size");

/**
 * Get the options for the bdev module.
+5 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#define SPDK_BLOB_H

#include "spdk/stdinc.h"
#include "spdk/assert.h"

#ifdef __cplusplus
extern "C" {
@@ -135,6 +136,7 @@ struct spdk_blob_ext_io_opts {
	/** Optional user context */
	void *user_ctx;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_blob_ext_io_opts) == 32, "Incorrect size");

struct spdk_bs_dev {
	/* Create a new channel which is a software construct that is used
@@ -237,6 +239,7 @@ struct spdk_bs_opts {
	/** Force recovery during import. This is a uint64_t for padding reasons, treated as a bool. */
	uint64_t force_recover;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_bs_opts) == 72, "Incorrect size");

/**
 * Initialize a spdk_bs_opts structure to the default blobstore option values.
@@ -449,6 +452,7 @@ struct spdk_blob_opts {
	 */
	size_t opts_size;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_blob_opts) == 64, "Incorrect size");

/**
 * Initialize a spdk_blob_opts structure to the default blob option values.
@@ -637,6 +641,7 @@ struct spdk_blob_open_opts {
	 */
	size_t opts_size;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_blob_open_opts) == 16, "Incorrect size");

/**
 * Initialize a spdk_blob_open_opts structure to the default blob option values.
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "spdk/queue.h"
#include "spdk/log.h"
#include "spdk/thread.h"
#include "spdk/assert.h"

#ifdef __cplusplus
extern "C" {
@@ -127,6 +128,7 @@ struct spdk_app_opts {
	 */
	size_t msg_mempool_size;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_app_opts) == 200, "Incorrect size");

/**
 * Initialize the default value of opts
+3 −0
Original line number Diff line number Diff line
@@ -244,6 +244,7 @@ struct spdk_nvme_ctrlr_opts {
	 */
	bool disable_read_ana_log_page;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_ctrlr_opts) == 616, "Incorrect size");

/**
 * NVMe acceleration operation callback.
@@ -551,6 +552,7 @@ struct spdk_nvme_ns_cmd_ext_io_opts {
	/** Application tag to use end-to-end protection information. */
	uint16_t apptag;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_ns_cmd_ext_io_opts) == 48, "Incorrect size");

/**
 * Parse the string representation of a transport ID.
@@ -1543,6 +1545,7 @@ struct spdk_nvme_io_qpair_opts {
	 */
	bool async_mode;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_io_qpair_opts) == 72, "Incorrect size");

/**
 * Get the default options for I/O qpair creation for a specific NVMe controller.
+3 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ struct spdk_nvmf_transport_opts {
	/* Use zero-copy operations if the underlying bdev supports them */
	bool zcopy;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_transport_opts) == 64, "Incorrect size");

struct spdk_nvmf_listen_opts {
	/**
@@ -101,6 +102,7 @@ struct spdk_nvmf_listen_opts {

	const struct spdk_json_val *transport_specific;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_listen_opts) == 16, "Incorrect size");

/**
 * Initialize listen options
@@ -741,6 +743,7 @@ struct spdk_nvmf_ns_opts {
	 */
	uint32_t anagrpid;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_ns_opts) == 64, "Incorrect size");

/**
 * Get default namespace creation options.
Loading