From 8c439a6799b87349cbd12d3fced71d4e7d4d7904 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 15 Dec 2022 12:35:32 +0900 Subject: [PATCH] bdev: Add function pointers to display and reset module specific I/O statistics However, when querying or resetting module specific statistics, the generic bdev layer have to access it. For this purpose, add functions pointers. Signed-off-by: Shuhei Matsumoto Change-Id: Ie86d0a4a406cec7e0f1e9a62de5982cd3d877eae Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14839 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- CHANGELOG.md | 4 ++++ include/spdk/bdev_module.h | 10 ++++++++++ lib/bdev/bdev_rpc.c | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36c4e4ed1..2563b91cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,10 @@ that no internal bdev locks can be held when a poller or message goes off CPU. A new RPC `bdev_reset_iostat` was added to reset I/O statistics of bdevs. Note that if one consumer reset I/O statistics, it affects all other consumers. +Add function pointers, `dump_device_stat_json` and `reset_device_stat` to the bdev module +function table to display and reset I/O statistics specific for the module specific bdev +context. + ### event Added core lock file mechanism to prevent the same CPU cores from being used by multiple diff --git a/include/spdk/bdev_module.h b/include/spdk/bdev_module.h index 61c3c566a..275815a65 100644 --- a/include/spdk/bdev_module.h +++ b/include/spdk/bdev_module.h @@ -247,6 +247,16 @@ struct spdk_bdev_fn_table { * Vbdev module must inspect types of memory domains returned by base bdev and report only those * memory domains that it can work with. */ int (*get_memory_domains)(void *ctx, struct spdk_memory_domain **domains, int array_size); + + /** + * Reset I/O statistics specific for this bdev context. + */ + void (*reset_device_stat)(void *ctx); + + /** + * Dump I/O statistics specific for this bdev context. + */ + void (*dump_device_stat_json)(void *ctx, struct spdk_json_write_ctx *w); }; /** bdev I/O completion status */ diff --git a/lib/bdev/bdev_rpc.c b/lib/bdev/bdev_rpc.c index 00a689b3e..3beaf52e9 100644 --- a/lib/bdev/bdev_rpc.c +++ b/lib/bdev/bdev_rpc.c @@ -277,6 +277,12 @@ bdev_get_iostat_done(struct spdk_bdev *bdev, struct spdk_bdev_io_stat *stat, spdk_bdev_get_weighted_io_time(bdev)); } + if (bdev->fn_table->dump_device_stat_json) { + spdk_json_write_named_object_begin(w, "driver_specific"); + bdev->fn_table->dump_device_stat_json(bdev->ctxt, w); + spdk_json_write_object_end(w); + } + spdk_json_write_object_end(w); done: @@ -526,6 +532,10 @@ bdev_reset_iostat(void *ctx, struct spdk_bdev *bdev) return rc; } + if (bdev->fn_table->reset_device_stat) { + bdev->fn_table->reset_device_stat(bdev->ctxt); + } + rpc_ctx->bdev_count++; bdev_ctx->rpc_ctx = rpc_ctx; bdev_reset_device_stat(bdev, rpc_ctx->mode, bdev_reset_iostat_done, bdev_ctx);