diff --git a/include/spdk/bdev.h b/include/spdk/bdev.h index 903464b7b..0b1092987 100644 --- a/include/spdk/bdev.h +++ b/include/spdk/bdev.h @@ -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. diff --git a/include/spdk/blob.h b/include/spdk/blob.h index 99786ff53..a2f5f7c54 100644 --- a/include/spdk/blob.h +++ b/include/spdk/blob.h @@ -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. diff --git a/include/spdk/event.h b/include/spdk/event.h index 0eba71f0b..82cf2ac77 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -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 diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 836a10ae5..f17019242 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -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. diff --git a/include/spdk/nvmf.h b/include/spdk/nvmf.h index 26db09422..94fc435fa 100644 --- a/include/spdk/nvmf.h +++ b/include/spdk/nvmf.h @@ -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. diff --git a/include/spdk/sock.h b/include/spdk/sock.h index 5ac3bf0ff..c0827496a 100644 --- a/include/spdk/sock.h +++ b/include/spdk/sock.h @@ -14,6 +14,7 @@ #include "spdk/queue.h" #include "spdk/json.h" +#include "spdk/assert.h" #ifdef __cplusplus extern "C" { @@ -191,6 +192,7 @@ struct spdk_sock_opts { */ size_t impl_opts_size; }; +SPDK_STATIC_ASSERT(sizeof(struct spdk_sock_opts) == 40, "Incorrect size"); /** * Initialize the default value of opts. diff --git a/lib/nvme/nvme.c b/lib/nvme/nvme.c index 4c455c3bb..6a21cfa3e 100644 --- a/lib/nvme/nvme.c +++ b/lib/nvme/nvme.c @@ -962,11 +962,6 @@ nvme_ctrlr_opts_init(struct spdk_nvme_ctrlr_opts *opts, SET_FIELD(fabrics_connect_timeout_us); SET_FIELD(disable_read_ana_log_page); - /* Do not remove this statement. When you add a new field, please do update this - * assert with the correct size. And do not forget to add a new SET_FIELD statement - * related with your new added field. */ - SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_ctrlr_opts) == 616, "Incorrect size"); - #undef FIELD_OK #undef SET_FIELD #undef SET_FIELD_ARRAY