From e7cb376aad1db6867cfb5dee5debd83853a13335 Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Fri, 23 Mar 2018 14:55:07 +0100 Subject: [PATCH] subsystem,bdev: rework RPC JSON config dump Changes: - change write_config_json to return void as return value is useless. - int spdk_bdev_config_json() -> void spdk_bdev_subsystem_config_json() - int spdk_bdev_write_config_json -> void spdk_bdev_config_json() Change-Id: I46e2e974abada0df67c07ba961543900f8334a8d Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/405052 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Shuhei Matsumoto --- include/spdk/bdev.h | 13 ++++--------- include/spdk_internal/event.h | 2 +- lib/bdev/bdev.c | 22 ++++++++-------------- lib/bdev/rpc/bdev_rpc.c | 4 ++-- lib/event/subsystems/bdev/bdev.c | 2 +- 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/include/spdk/bdev.h b/include/spdk/bdev.h index 87b4ff9fe..60a2d716d 100644 --- a/include/spdk/bdev.h +++ b/include/spdk/bdev.h @@ -151,11 +151,9 @@ void spdk_bdev_config_text(FILE *fp); /** * Get the full configuration options for the registered block device modules and created bdevs. * - * \param w The pointer to a JSON write context where the configuration will be written. - * \return result of \c spdk_bdev_dump_bdev_config_json() or negative error code: - * -EINVAL if w == NULL + * \param w pointer to a JSON write context where the configuration will be written. */ -int spdk_bdev_config_json(struct spdk_json_write_ctx *w); +void spdk_bdev_subsystem_config_json(struct spdk_json_write_ctx *w); /** * Get block device by the block device name. @@ -262,13 +260,10 @@ int spdk_bdev_dump_info_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx * If \c bdev does not support writing JSON configuration then object will be written * with only one key - the name of this bdev. * - * \param w JSON write context. It will store the driver-specific configuration context. * \param bdev block device to query configuration. - * \return 0 on success, negated errno on failure. - * -EINVAL - bdev == NULL or w == NULL - * -ENOSYS - this block device doesn't support dumping configuration. + * \param w pointer to a JSON write context where \c bdev the configuration will be written. */ -int spdk_bdev_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w); +void spdk_bdev_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w); /** * Get block device name. diff --git a/include/spdk_internal/event.h b/include/spdk_internal/event.h index 6d72ea3e7..7be3a0ea1 100644 --- a/include/spdk_internal/event.h +++ b/include/spdk_internal/event.h @@ -58,7 +58,7 @@ struct spdk_subsystem { void (*init)(void); void (*fini)(void); void (*config)(FILE *fp); - int (*write_config_json)(struct spdk_json_write_ctx *w); + void (*write_config_json)(struct spdk_json_write_ctx *w); TAILQ_ENTRY(spdk_subsystem) tailq; }; diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 3b78defb4..0c147ce5b 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -426,15 +426,13 @@ spdk_bdev_config_text(FILE *fp) } } -int -spdk_bdev_config_json(struct spdk_json_write_ctx *w) +void +spdk_bdev_subsystem_config_json(struct spdk_json_write_ctx *w) { struct spdk_bdev_module *bdev_module; struct spdk_bdev *bdev; - if (!w) { - return -EINVAL; - } + assert(w != NULL); spdk_json_write_array_begin(w); @@ -445,11 +443,10 @@ spdk_bdev_config_json(struct spdk_json_write_ctx *w) } TAILQ_FOREACH(bdev, &g_bdev_mgr.bdevs, link) { - spdk_bdev_write_config_json(bdev, w); + spdk_bdev_config_json(bdev, w); } spdk_json_write_array_end(w); - return 0; } static int @@ -978,12 +975,11 @@ spdk_bdev_dump_info_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w) return 0; } -int -spdk_bdev_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w) +void +spdk_bdev_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w) { - if (bdev == NULL || w == NULL) { - return -EINVAL; - } + assert(bdev == NULL); + assert(w == NULL); if (bdev->fn_table->write_config_json) { bdev->fn_table->write_config_json(bdev, w); @@ -992,8 +988,6 @@ spdk_bdev_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx * spdk_json_write_named_string(w, "name", bdev->name); spdk_json_write_object_end(w); } - - return 0; } static void diff --git a/lib/bdev/rpc/bdev_rpc.c b/lib/bdev/rpc/bdev_rpc.c index 310477116..f61972475 100644 --- a/lib/bdev/rpc/bdev_rpc.c +++ b/lib/bdev/rpc/bdev_rpc.c @@ -226,10 +226,10 @@ spdk_rpc_get_bdevs_config(struct spdk_jsonrpc_request *request, spdk_json_write_array_begin(w); if (bdev != NULL) { - spdk_bdev_write_config_json(bdev, w); + spdk_bdev_config_json(bdev, w); } else { for (bdev = spdk_bdev_first(); bdev != NULL; bdev = spdk_bdev_next(bdev)) { - spdk_bdev_write_config_json(bdev, w); + spdk_bdev_config_json(bdev, w); } } diff --git a/lib/event/subsystems/bdev/bdev.c b/lib/event/subsystems/bdev/bdev.c index a63fd1890..da58a6473 100644 --- a/lib/event/subsystems/bdev/bdev.c +++ b/lib/event/subsystems/bdev/bdev.c @@ -69,7 +69,7 @@ static struct spdk_subsystem g_spdk_subsystem_bdev = { .init = spdk_bdev_subsystem_initialize, .fini = spdk_bdev_subsystem_finish, .config = spdk_bdev_config_text, - .write_config_json = spdk_bdev_config_json, + .write_config_json = spdk_bdev_subsystem_config_json, }; SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_bdev);