bdev/nvme: Factor out each RPC config from config_json()
Factor out each RPC configuration from bdev_nvme_config_json() and bdev_ocssd_namespace_config_json() into a helper function, respectively. These changes will make us easier to introduce subsystem into the NVMe bdev module. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I297f3fb47893d45463e742834c58d2b1213a4b01 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5468 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: <dongx.yi@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
17afd268df
commit
4dc86079b7
@ -2769,13 +2769,10 @@ nvme_namespace_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *n
|
||||
g_config_json_namespace_fn[nvme_ns->type](w, nvme_ns);
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_nvme_config_json(struct spdk_json_write_ctx *w)
|
||||
static void
|
||||
bdev_nvme_opts_config_json(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
|
||||
struct spdk_nvme_transport_id *trid;
|
||||
const char *action;
|
||||
uint32_t nsid;
|
||||
|
||||
if (g_opts.action_on_timeout == SPDK_BDEV_NVME_TIMEOUT_ACTION_RESET) {
|
||||
action = "reset";
|
||||
@ -2805,9 +2802,14 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
static void
|
||||
nvme_bdev_ctrlr_config_json(struct spdk_json_write_ctx *w,
|
||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr)
|
||||
{
|
||||
struct spdk_nvme_transport_id *trid;
|
||||
|
||||
pthread_mutex_lock(&g_bdev_nvme_mutex);
|
||||
TAILQ_FOREACH(nvme_bdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) {
|
||||
trid = nvme_bdev_ctrlr->connected_trid;
|
||||
|
||||
spdk_json_write_object_begin(w);
|
||||
@ -2825,6 +2827,34 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_nvme_hotplug_config_json(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
spdk_json_write_object_begin(w);
|
||||
spdk_json_write_named_string(w, "method", "bdev_nvme_set_hotplug");
|
||||
|
||||
spdk_json_write_named_object_begin(w, "params");
|
||||
spdk_json_write_named_uint64(w, "period_us", g_nvme_hotplug_poll_period_us);
|
||||
spdk_json_write_named_bool(w, "enable", g_nvme_hotplug_enabled);
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_nvme_config_json(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
|
||||
uint32_t nsid;
|
||||
|
||||
bdev_nvme_opts_config_json(w);
|
||||
|
||||
pthread_mutex_lock(&g_bdev_nvme_mutex);
|
||||
|
||||
TAILQ_FOREACH(nvme_bdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) {
|
||||
nvme_bdev_ctrlr_config_json(w, nvme_bdev_ctrlr);
|
||||
|
||||
for (nsid = 0; nsid < nvme_bdev_ctrlr->num_ns; ++nsid) {
|
||||
if (!nvme_bdev_ctrlr->namespaces[nsid]->populated) {
|
||||
@ -2838,15 +2868,7 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)
|
||||
/* Dump as last parameter to give all NVMe bdevs chance to be constructed
|
||||
* before enabling hotplug poller.
|
||||
*/
|
||||
spdk_json_write_object_begin(w);
|
||||
spdk_json_write_named_string(w, "method", "bdev_nvme_set_hotplug");
|
||||
|
||||
spdk_json_write_named_object_begin(w, "params");
|
||||
spdk_json_write_named_uint64(w, "period_us", g_nvme_hotplug_poll_period_us);
|
||||
spdk_json_write_named_bool(w, "enable", g_nvme_hotplug_enabled);
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
bdev_nvme_hotplug_config_json(w);
|
||||
|
||||
pthread_mutex_unlock(&g_bdev_nvme_mutex);
|
||||
return 0;
|
||||
|
@ -129,16 +129,14 @@ bdev_ocssd_config_json(struct spdk_json_write_ctx *w)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
bdev_ocssd_namespace_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *nvme_ns)
|
||||
static void
|
||||
ocssd_bdev_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev *nvme_bdev)
|
||||
{
|
||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
|
||||
struct nvme_bdev *nvme_bdev;
|
||||
struct ocssd_bdev *ocssd_bdev;
|
||||
char range_buf[128];
|
||||
int rc;
|
||||
|
||||
TAILQ_FOREACH(nvme_bdev, &nvme_ns->bdevs, tailq) {
|
||||
nvme_bdev_ctrlr = nvme_bdev->nvme_ns->ctrlr;
|
||||
ocssd_bdev = SPDK_CONTAINEROF(nvme_bdev, struct ocssd_bdev, nvme_bdev);
|
||||
|
||||
@ -146,7 +144,7 @@ bdev_ocssd_namespace_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev
|
||||
ocssd_bdev->range.begin, ocssd_bdev->range.end);
|
||||
if (rc < 0 || rc >= (int)sizeof(range_buf)) {
|
||||
SPDK_ERRLOG("Failed to convert parallel unit range\n");
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
spdk_json_write_object_begin(w);
|
||||
@ -161,6 +159,15 @@ bdev_ocssd_namespace_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
void
|
||||
bdev_ocssd_namespace_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *nvme_ns)
|
||||
{
|
||||
struct nvme_bdev *nvme_bdev;
|
||||
|
||||
TAILQ_FOREACH(nvme_bdev, &nvme_ns->bdevs, tailq) {
|
||||
ocssd_bdev_config_json(w, nvme_bdev);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user