From 915270db6864d02d94a13455d968a90c69fe3726 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Mon, 29 Apr 2019 08:02:40 -0700 Subject: [PATCH] bdev: make bdevs array for get_bdevs_iostat RPC Fixes issue #775. Signed-off-by: Jim Harris Change-Id: I5e07084599c2363b64619f38bd826fe100217020 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452477 Tested-by: SPDK CI Jenkins Reviewed-by: Seth Howell Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- CHANGELOG.md | 6 ++++++ doc/jsonrpc.md | 42 ++++++++++++++++++------------------ lib/bdev/rpc/bdev_rpc.c | 6 ++++-- test/iscsi_tgt/qos/qos.sh | 8 +++---- test/nvmf/target/shutdown.sh | 2 +- 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c599e3d6c7..39f186a63f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,12 @@ The function `spdk_notify_get_types()` and `spdk_notify_get_events()` were renamed to `spdk_notify_foreach_type()` and `spdk_notify_foreach_event()`, respectively. And update type name of callback accordingly. +### bdev + +The format of the data returned by the get_bdevs_iostat RPC has changed to +make it easier to parse. It now returns an object with a "ticks" object +and "bdevs" array with the per-bdev statistics. + ## v19.04: ### nvme diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 683c83c2bc..902f3e1f0f 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -623,27 +623,27 @@ Example response: { "jsonrpc": "2.0", "id": 1, - "result": [ - { - "tick_rate": 2200000000 - }, - { - "name": "Nvme0n1", - "bytes_read": 36864, - "num_read_ops": 2, - "bytes_written": 0, - "num_write_ops": 0, - "bytes_unmapped": 0, - "num_unmap_ops": 0, - "read_latency_ticks": 178904, - "write_latency_ticks": 0, - "unmap_latency_ticks": 0, - "queue_depth_polling_period": 2, - "queue_depth": 0, - "io_time": 0, - "weighted_io_time": 0 - } - ] + "result": { + "tick_rate": 2200000000, + "bdevs" : [ + { + "name": "Nvme0n1", + "bytes_read": 36864, + "num_read_ops": 2, + "bytes_written": 0, + "num_write_ops": 0, + "bytes_unmapped": 0, + "num_unmap_ops": 0, + "read_latency_ticks": 178904, + "write_latency_ticks": 0, + "unmap_latency_ticks": 0, + "queue_depth_polling_period": 2, + "queue_depth": 0, + "io_time": 0, + "weighted_io_time": 0 + } + ] + } } ~~~ diff --git a/lib/bdev/rpc/bdev_rpc.c b/lib/bdev/rpc/bdev_rpc.c index cea85b7a39..6f003178af 100644 --- a/lib/bdev/rpc/bdev_rpc.c +++ b/lib/bdev/rpc/bdev_rpc.c @@ -102,6 +102,7 @@ done: free(stat); if (--ctx->bdev_count == 0) { spdk_json_write_array_end(ctx->w); + spdk_json_write_object_end(w); spdk_jsonrpc_end_result(ctx->request, ctx->w); free(ctx); } @@ -171,11 +172,11 @@ spdk_rpc_get_bdevs_iostat(struct spdk_jsonrpc_request *request, ctx->request = request; ctx->w = w; - spdk_json_write_array_begin(w); spdk_json_write_object_begin(w); spdk_json_write_named_uint64(w, "tick_rate", spdk_get_ticks_hz()); - spdk_json_write_object_end(w); + + spdk_json_write_named_array_begin(w, "bdevs"); if (bdev != NULL) { stat = calloc(1, sizeof(struct spdk_bdev_io_stat)); @@ -199,6 +200,7 @@ spdk_rpc_get_bdevs_iostat(struct spdk_jsonrpc_request *request, if (--ctx->bdev_count == 0) { spdk_json_write_array_end(w); + spdk_json_write_object_end(w); spdk_jsonrpc_end_result(request, w); free(ctx); } diff --git a/test/iscsi_tgt/qos/qos.sh b/test/iscsi_tgt/qos/qos.sh index 878f7f9fdc..9eeeceb767 100755 --- a/test/iscsi_tgt/qos/qos.sh +++ b/test/iscsi_tgt/qos/qos.sh @@ -20,17 +20,17 @@ function check_qos_works_well() { fi if [ $LIMIT_TYPE = IOPS ]; then - start_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.[1].num_read_ops') + start_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.bdevs[0].num_read_ops') else - start_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.[1].bytes_read') + start_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.bdevs[0].bytes_read') fi $fio_py iscsi 1024 128 randread 5 1 if [ $LIMIT_TYPE = IOPS ]; then - end_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.[1].num_read_ops') + end_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.bdevs[0].num_read_ops') else - end_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.[1].bytes_read') + end_io_count=$($rpc_py get_bdevs_iostat -b $3 | jq -r '.bdevs[0].bytes_read') fi read_result=$(((end_io_count-start_io_count)/5)) diff --git a/test/nvmf/target/shutdown.sh b/test/nvmf/target/shutdown.sh index b157b31659..2534c462ec 100755 --- a/test/nvmf/target/shutdown.sh +++ b/test/nvmf/target/shutdown.sh @@ -35,7 +35,7 @@ function waitforio() { local ret=1 local i for (( i = 10; i != 0; i-- )); do - read_io_count=$($rpc_py -s $1 get_bdevs_iostat -b $2 | jq -r '.[1].num_read_ops') + read_io_count=$($rpc_py -s $1 get_bdevs_iostat -b $2 | jq -r '.bdevs[0].num_read_ops') # A few I/O will happen during initial examine. So wait until at least 100 I/O # have completed to know that bdevperf is really generating the I/O. if [ $read_io_count -ge 100 ]; then