bdev: make spdk_bdev_register_module_xxx function names predictable

Currently, the SPDK_BDEV_REGISTER_MODULE() macro uses __LINE__
to generate functions like spdk_bdev_module_register_187().

Typically, this is not a problem as these functions are not called directly
rather, they are only used as constructor functions to load the bdevs during
system startup.

There are languages however, (e.g rust) that require these functions to be
referenced explicitly to prevent them from being removed during the linking phase.

In order to reference them, having the names predictable (and potentially
changed per commit) makes things easier.

Change-Id: I15947ed9136912cfe2368db7e5bba833f1d94b15
Signed-off-by: gila <jeffry.molanus@gmail.com>
Reviewed-on: https://review.gerrithub.io/c/443536
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
gila 2019-02-05 11:46:48 +01:00 committed by Jim Harris
parent e8ccc71e83
commit df6b55fd8c
22 changed files with 29 additions and 41 deletions

View File

@ -1004,24 +1004,12 @@ struct spdk_bdev *spdk_bdev_part_get_base_bdev(struct spdk_bdev_part *part);
uint64_t spdk_bdev_part_get_offset_blocks(struct spdk_bdev_part *part);
/*
* Macro used to register module for later initialization.
* Macro used to register module for later initialization.
*/
#define SPDK_BDEV_MODULE_REGISTER(_module) \
__attribute__((constructor)) static void \
SPDK_BDEV_MODULE_REGISTER_FN_NAME(__LINE__) (void) \
{ \
spdk_bdev_module_list_add(_module); \
}
/*
* This is helper macro for automatic function generation.
*
*/
#define SPDK_BDEV_MODULE_REGISTER_FN_NAME(line) SPDK_BDEV_MODULE_REGISTER_FN_NAME_(line)
/*
* Second helper macro for "stringize" trick to work.
*/
#define SPDK_BDEV_MODULE_REGISTER_FN_NAME_(line) spdk_bdev_module_register_ ## line
#define SPDK_BDEV_MODULE_REGISTER(name, module) \
static void __attribute__((constructor)) spdk_bdev_module_register_##name(void) \
{ \
spdk_bdev_module_list_add(module); \
} \
#endif /* SPDK_BDEV_MODULE_H */

View File

@ -98,7 +98,7 @@ static struct spdk_bdev_module aio_if = {
.get_ctx_size = bdev_aio_get_ctx_size,
};
SPDK_BDEV_MODULE_REGISTER(&aio_if)
SPDK_BDEV_MODULE_REGISTER(aio, &aio_if)
static int
bdev_aio_open(struct file_disk *disk)

View File

@ -1394,7 +1394,7 @@ static struct spdk_bdev_module crypto_if = {
.config_json = vbdev_crypto_config_json
};
SPDK_BDEV_MODULE_REGISTER(&crypto_if)
SPDK_BDEV_MODULE_REGISTER(crypto, &crypto_if)
static int
vbdev_crypto_claim(struct spdk_bdev *bdev)

View File

@ -93,7 +93,7 @@ static struct spdk_bdev_module error_if = {
};
SPDK_BDEV_MODULE_REGISTER(&error_if)
SPDK_BDEV_MODULE_REGISTER(error, &error_if)
int
spdk_vbdev_inject_error(char *name, uint32_t io_type, uint32_t error_type, uint32_t error_num)

View File

@ -123,7 +123,7 @@ static struct spdk_bdev_module g_ftl_if = {
.get_ctx_size = bdev_ftl_get_ctx_size,
};
SPDK_BDEV_MODULE_REGISTER(&g_ftl_if)
SPDK_BDEV_MODULE_REGISTER(ftl, &g_ftl_if)
static struct ftl_bdev_ctrlr *
bdev_ftl_ctrlr_find(const struct spdk_nvme_transport_id *trid)

View File

@ -60,7 +60,7 @@ static struct spdk_bdev_module gpt_if = {
.examine_disk = vbdev_gpt_examine,
};
SPDK_BDEV_MODULE_REGISTER(&gpt_if)
SPDK_BDEV_MODULE_REGISTER(gpt, &gpt_if)
/* Base block device gpt context */
struct gpt_base {

View File

@ -167,7 +167,7 @@ static struct spdk_bdev_module g_iscsi_bdev_module = {
.async_init = true,
};
SPDK_BDEV_MODULE_REGISTER(&g_iscsi_bdev_module);
SPDK_BDEV_MODULE_REGISTER(iscsi, &g_iscsi_bdev_module);
static void
_bdev_iscsi_io_complete(void *_iscsi_io)

View File

@ -55,7 +55,7 @@ static struct spdk_bdev_module g_lvol_if = {
};
SPDK_BDEV_MODULE_REGISTER(&g_lvol_if)
SPDK_BDEV_MODULE_REGISTER(lvol, &g_lvol_if)
struct lvol_store_bdev *
vbdev_get_lvs_bdev_by_lvs(struct spdk_lvol_store *lvs_orig)

View File

@ -109,7 +109,7 @@ static struct spdk_bdev_module malloc_if = {
};
SPDK_BDEV_MODULE_REGISTER(&malloc_if)
SPDK_BDEV_MODULE_REGISTER(malloc, &malloc_if)
static void
malloc_disk_free(struct malloc_disk *malloc_disk)

View File

@ -70,7 +70,7 @@ static struct spdk_bdev_module null_if = {
.async_fini = true,
};
SPDK_BDEV_MODULE_REGISTER(&null_if)
SPDK_BDEV_MODULE_REGISTER(null, &null_if)
static int
bdev_null_destruct(void *ctx)

View File

@ -184,7 +184,7 @@ static struct spdk_bdev_module nvme_if = {
.get_ctx_size = bdev_nvme_get_ctx_size,
};
SPDK_BDEV_MODULE_REGISTER(&nvme_if)
SPDK_BDEV_MODULE_REGISTER(nvme, &nvme_if)
static int
bdev_nvme_readv(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,

View File

@ -966,6 +966,6 @@ static struct spdk_bdev_module ocf_if = {
.get_ctx_size = vbdev_ocf_get_ctx_size,
.examine_config = vbdev_ocf_examine,
};
SPDK_BDEV_MODULE_REGISTER(&ocf_if);
SPDK_BDEV_MODULE_REGISTER(ocf, &ocf_if);
SPDK_LOG_REGISTER_COMPONENT("vbdev_ocf", SPDK_TRACE_VBDEV_OCF)

View File

@ -68,7 +68,7 @@ static struct spdk_bdev_module passthru_if = {
.config_json = vbdev_passthru_config_json
};
SPDK_BDEV_MODULE_REGISTER(&passthru_if)
SPDK_BDEV_MODULE_REGISTER(passthru, &passthru_if)
/* List of pt_bdev names and their base bdevs via configuration file.
* Used so we can parse the conf once at init and use this list in examine().

View File

@ -63,7 +63,7 @@ static struct spdk_bdev_module pmem_if = {
};
SPDK_BDEV_MODULE_REGISTER(&pmem_if)
SPDK_BDEV_MODULE_REGISTER(pmem, &pmem_if)
typedef int(*spdk_bdev_pmem_io_request)(PMEMblkpool *pbp, void *buf, long long blockno);

View File

@ -1190,7 +1190,7 @@ static struct spdk_bdev_module g_raid_if = {
.async_init = false,
.async_fini = false,
};
SPDK_BDEV_MODULE_REGISTER(&g_raid_if)
SPDK_BDEV_MODULE_REGISTER(raid, &g_raid_if)
/*
* brief:

View File

@ -278,7 +278,7 @@ static struct spdk_bdev_module rbd_if = {
.get_ctx_size = bdev_rbd_get_ctx_size,
};
SPDK_BDEV_MODULE_REGISTER(&rbd_if)
SPDK_BDEV_MODULE_REGISTER(rbd, &rbd_if)
static int64_t
bdev_rbd_rw(struct bdev_rbd *disk, struct spdk_io_channel *ch,

View File

@ -95,7 +95,7 @@ static struct spdk_bdev_module split_if = {
.config_json = vbdev_split_config_json,
};
SPDK_BDEV_MODULE_REGISTER(&split_if)
SPDK_BDEV_MODULE_REGISTER(split, &split_if)
static void
vbdev_split_base_free(void *ctx)

View File

@ -96,7 +96,7 @@ static struct spdk_bdev_module virtio_blk_if = {
.get_ctx_size = bdev_virtio_blk_get_ctx_size,
};
SPDK_BDEV_MODULE_REGISTER(&virtio_blk_if)
SPDK_BDEV_MODULE_REGISTER(virtio_blk, &virtio_blk_if)
static int bdev_virtio_blk_ch_create_cb(void *io_device, void *ctx_buf);
static void bdev_virtio_blk_ch_destroy_cb(void *io_device, void *ctx_buf);

View File

@ -456,7 +456,7 @@ static struct spdk_bdev_module virtio_scsi_if = {
.async_fini = true,
};
SPDK_BDEV_MODULE_REGISTER(&virtio_scsi_if)
SPDK_BDEV_MODULE_REGISTER(virtio_scsi, &virtio_scsi_if)
static struct virtio_scsi_io_ctx *
bdev_virtio_init_io_vreq(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)

View File

@ -287,8 +287,8 @@ struct spdk_bdev_module vbdev_ut_if = {
.examine_config = vbdev_ut_examine,
};
SPDK_BDEV_MODULE_REGISTER(&bdev_ut_if)
SPDK_BDEV_MODULE_REGISTER(&vbdev_ut_if)
SPDK_BDEV_MODULE_REGISTER(bdev_ut, &bdev_ut_if)
SPDK_BDEV_MODULE_REGISTER(vbdev_ut, &vbdev_ut_if)
static void
vbdev_ut_examine(struct spdk_bdev *bdev)

View File

@ -216,7 +216,7 @@ struct spdk_bdev_module bdev_ut_if = {
.fini_start = fini_start,
};
SPDK_BDEV_MODULE_REGISTER(&bdev_ut_if)
SPDK_BDEV_MODULE_REGISTER(bdev_ut, &bdev_ut_if)
static void
register_bdev(struct ut_bdev *ut_bdev, char *name, void *io_target)

View File

@ -86,8 +86,8 @@ struct spdk_bdev_module vbdev_ut_if = {
.examine_config = vbdev_ut_examine,
};
SPDK_BDEV_MODULE_REGISTER(&bdev_ut_if)
SPDK_BDEV_MODULE_REGISTER(&vbdev_ut_if)
SPDK_BDEV_MODULE_REGISTER(bdev_ut, &bdev_ut_if)
SPDK_BDEV_MODULE_REGISTER(vbdev_ut, &vbdev_ut_if)
static void
vbdev_ut_examine(struct spdk_bdev *bdev)