Skip to content

Commit a7b321f

Browse files
committed
Write bdev's cluster information to json config file.
Signed-off-by: Gil Bregman <gbregman@il.ibm.com>
1 parent c0adcaa commit a7b321f

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

module/bdev/rbd/bdev_rbd.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,36 @@ bdev_rbd_get_ctx_size(void)
695695
return sizeof(struct bdev_rbd_io);
696696
}
697697

698+
static int
699+
bdev_rbd_config_json(struct spdk_json_write_ctx *w)
700+
{
701+
struct bdev_rbd_cluster *entry;
702+
703+
pthread_mutex_lock(&g_map_bdev_rbd_cluster_mutex);
704+
STAILQ_FOREACH(entry, &g_map_bdev_rbd_cluster, link) {
705+
spdk_json_write_object_begin(w);
706+
spdk_json_write_named_string(w, "method", "bdev_rbd_register_cluster");
707+
spdk_json_write_named_object_begin(w, "params");
708+
spdk_json_write_named_string(w, "name", entry->name);
709+
if (entry->user_id && *entry->user_id) {
710+
spdk_json_write_named_string(w, "user_id", entry->user_id);
711+
}
712+
if (entry->core_mask && *entry->core_mask) {
713+
spdk_json_write_named_string(w, "core_mask", entry->core_mask);
714+
}
715+
spdk_json_write_object_end(w);
716+
spdk_json_write_object_end(w);
717+
}
718+
pthread_mutex_unlock(&g_map_bdev_rbd_cluster_mutex);
719+
return 0;
720+
}
721+
698722
static struct spdk_bdev_module rbd_if = {
699723
.name = "rbd",
700724
.module_init = bdev_rbd_library_init,
701725
.module_fini = bdev_rbd_library_fini,
702726
.get_ctx_size = bdev_rbd_get_ctx_size,
727+
.config_json = bdev_rbd_config_json,
703728

704729
};
705730
SPDK_BDEV_MODULE_REGISTER(rbd, &rbd_if)
@@ -1014,8 +1039,9 @@ bdev_rbd_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)
10141039
static void
10151040
bdev_rbd_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w)
10161041
{
1017-
struct bdev_rbd *rbd = bdev->ctxt;
1042+
struct bdev_rbd *rbd;
10181043

1044+
rbd = bdev->ctxt;
10191045
spdk_json_write_object_begin(w);
10201046

10211047
spdk_json_write_named_string(w, "method", "bdev_rbd_create");
@@ -1024,7 +1050,7 @@ bdev_rbd_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w
10241050
spdk_json_write_named_string(w, "name", bdev->name);
10251051
spdk_json_write_named_string(w, "pool_name", rbd->pool_name);
10261052
if (rbd->namespace_name) {
1027-
spdk_json_write_named_string(w, "namespace_name", rbd->namespace_name);
1053+
spdk_json_write_named_string(w, "namespace_name", rbd->namespace_name);
10281054
}
10291055
spdk_json_write_named_string(w, "rbd_name", rbd->rbd_name);
10301056
spdk_json_write_named_bool(w, "read_only", rbd->rbd_read_only);
@@ -1045,6 +1071,9 @@ bdev_rbd_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w
10451071
}
10461072

10471073
spdk_json_write_named_uuid(w, "uuid", &bdev->uuid);
1074+
if (rbd->cluster_name) {
1075+
spdk_json_write_named_string(w, "cluster_name", rbd->cluster_name);
1076+
}
10481077

10491078
spdk_json_write_object_end(w);
10501079

0 commit comments

Comments
 (0)