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 <smatsumoto@nvidia.com>
Change-Id: Ie86d0a4a406cec7e0f1e9a62de5982cd3d877eae
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14839
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Shuhei Matsumoto 2022-12-15 12:35:32 +09:00 committed by Tomasz Zawadzki
parent 53a9a8c4d1
commit 8c439a6799
3 changed files with 24 additions and 0 deletions

View File

@ -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 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. 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 ### event
Added core lock file mechanism to prevent the same CPU cores from being used by multiple Added core lock file mechanism to prevent the same CPU cores from being used by multiple

View File

@ -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 * Vbdev module must inspect types of memory domains returned by base bdev and report only those
* memory domains that it can work with. */ * memory domains that it can work with. */
int (*get_memory_domains)(void *ctx, struct spdk_memory_domain **domains, int array_size); 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 */ /** bdev I/O completion status */

View File

@ -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)); 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); spdk_json_write_object_end(w);
done: done:
@ -526,6 +532,10 @@ bdev_reset_iostat(void *ctx, struct spdk_bdev *bdev)
return rc; return rc;
} }
if (bdev->fn_table->reset_device_stat) {
bdev->fn_table->reset_device_stat(bdev->ctxt);
}
rpc_ctx->bdev_count++; rpc_ctx->bdev_count++;
bdev_ctx->rpc_ctx = rpc_ctx; bdev_ctx->rpc_ctx = rpc_ctx;
bdev_reset_device_stat(bdev, rpc_ctx->mode, bdev_reset_iostat_done, bdev_ctx); bdev_reset_device_stat(bdev, rpc_ctx->mode, bdev_reset_iostat_done, bdev_ctx);