From d0c013a7e3167418041779055da1f6d5fe3621f4 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 8 Aug 2017 17:54:26 -0700 Subject: [PATCH] bdev/rbd: add get_bdevs JSON dump function Report the Ceph pool and RBD name in the get_bdevs output for RBD bdevs. Change-Id: I0e9be0b540e90503ce052c968f979b5887673c24 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/373416 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/bdev/rbd/bdev_rbd.c | 21 +++++++++++++++++++++ test/iscsi_tgt/rbd/rbd.sh | 1 + 2 files changed, 22 insertions(+) diff --git a/lib/bdev/rbd/bdev_rbd.c b/lib/bdev/rbd/bdev_rbd.c index 60d62a7ba..94422210c 100644 --- a/lib/bdev/rbd/bdev_rbd.c +++ b/lib/bdev/rbd/bdev_rbd.c @@ -44,6 +44,7 @@ #include "spdk/log.h" #include "spdk/bdev.h" #include "spdk/io_channel.h" +#include "spdk/json.h" #include "spdk/string.h" #include "spdk_internal/bdev.h" @@ -455,11 +456,31 @@ bdev_rbd_get_io_channel(void *ctx) return spdk_get_io_channel(&rbd_bdev->info); } +static int +bdev_rbd_dump_config_json(void *ctx, struct spdk_json_write_ctx *w) +{ + struct bdev_rbd *rbd_bdev = ctx; + + spdk_json_write_name(w, "rbd"); + spdk_json_write_object_begin(w); + + spdk_json_write_name(w, "pool_name"); + spdk_json_write_string(w, rbd_bdev->pool_name); + + spdk_json_write_name(w, "rbd_name"); + spdk_json_write_string(w, rbd_bdev->rbd_name); + + spdk_json_write_object_end(w); + + return 0; +} + static const struct spdk_bdev_fn_table rbd_fn_table = { .destruct = bdev_rbd_destruct, .submit_request = bdev_rbd_submit_request, .io_type_supported = bdev_rbd_io_type_supported, .get_io_channel = bdev_rbd_get_io_channel, + .dump_config_json = bdev_rbd_dump_config_json, }; static void diff --git a/test/iscsi_tgt/rbd/rbd.sh b/test/iscsi_tgt/rbd/rbd.sh index bcf81d744..66617b079 100755 --- a/test/iscsi_tgt/rbd/rbd.sh +++ b/test/iscsi_tgt/rbd/rbd.sh @@ -37,6 +37,7 @@ timing_exit start_iscsi_tgt $rpc_py add_portal_group 1 $TARGET_IP:$PORT $rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK $rpc_py construct_rbd_bdev $RBD_POOL $RBD_NAME 4096 +$rpc_py get_bdevs # "Ceph0:0" ==> use Ceph0 blockdev for LUN0 # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64