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 <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/405052
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Pawel Wodkowski 2018-03-23 14:55:07 +01:00 committed by Jim Harris
parent d78e3bbf76
commit e7cb376aad
5 changed files with 16 additions and 27 deletions

View File

@ -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.

View File

@ -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;
};

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);