bdev: Alloc spdk_bdev_io_stat dynamically for spdk_bdev
The following patches will extend I/O statistics to include error counters and module specific counters to output these via the bdev_get_iostat RPC. In this case, the size of the struct spdk_bdev_iostat will be variable. As a preparation, allocate spdk_bdev_io_stat dynamically. Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: I1979a9d867859d5cb5d05717bfcc677f07fa03f8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15479 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
e84bc517c3
commit
571638b9b9
@ -540,7 +540,7 @@ struct spdk_bdev {
|
||||
uint64_t weighted_io_time;
|
||||
|
||||
/** accumulated I/O statistics for previously deleted channels of this bdev */
|
||||
struct spdk_bdev_io_stat stat;
|
||||
struct spdk_bdev_io_stat *stat;
|
||||
|
||||
/** true if tracking the queue_depth of a device is in progress */
|
||||
bool qd_poll_in_progress;
|
||||
|
@ -3711,7 +3711,7 @@ bdev_channel_destroy(void *io_device, void *ctx_buf)
|
||||
|
||||
/* This channel is going away, so add its statistics into the bdev so that they don't get lost. */
|
||||
spdk_spin_lock(&ch->bdev->internal.spinlock);
|
||||
bdev_io_stat_add(&ch->bdev->internal.stat, ch->stat);
|
||||
bdev_io_stat_add(ch->bdev->internal.stat, ch->stat);
|
||||
spdk_spin_unlock(&ch->bdev->internal.spinlock);
|
||||
|
||||
bdev_abort_all_queued_io(&ch->queued_resets, ch);
|
||||
@ -5645,7 +5645,7 @@ spdk_bdev_get_device_stat(struct spdk_bdev *bdev, struct spdk_bdev_io_stat *stat
|
||||
|
||||
/* Start with the statistics from previously deleted channels. */
|
||||
spdk_spin_lock(&bdev->internal.spinlock);
|
||||
bdev_io_stat_add(bdev_iostat_ctx->stat, &bdev->internal.stat);
|
||||
bdev_io_stat_add(bdev_iostat_ctx->stat, bdev->internal.stat);
|
||||
spdk_spin_unlock(&bdev->internal.spinlock);
|
||||
|
||||
/* Then iterate and add the statistics from each existing channel. */
|
||||
@ -6430,6 +6430,13 @@ bdev_register(struct spdk_bdev *bdev)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
bdev->internal.stat = calloc(1, sizeof(struct spdk_bdev_io_stat));
|
||||
if (!bdev->internal.stat) {
|
||||
SPDK_ERRLOG("Unable to allocate I/O statistics structure.\n");
|
||||
free(bdev_name);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
bdev->internal.status = SPDK_BDEV_STATUS_READY;
|
||||
bdev->internal.measured_queue_depth = UINT64_MAX;
|
||||
bdev->internal.claim_module = NULL;
|
||||
@ -6443,6 +6450,7 @@ bdev_register(struct spdk_bdev *bdev)
|
||||
|
||||
ret = bdev_name_add(&bdev->internal.bdev_name, bdev, bdev->name);
|
||||
if (ret != 0) {
|
||||
free(bdev->internal.stat);
|
||||
free(bdev_name);
|
||||
return ret;
|
||||
}
|
||||
@ -6458,6 +6466,7 @@ bdev_register(struct spdk_bdev *bdev)
|
||||
if (ret != 0) {
|
||||
SPDK_ERRLOG("Unable to add uuid:%s alias for bdev %s\n", uuid, bdev->name);
|
||||
bdev_name_del(&bdev->internal.bdev_name);
|
||||
free(bdev->internal.stat);
|
||||
free(bdev_name);
|
||||
return ret;
|
||||
}
|
||||
@ -6522,6 +6531,7 @@ bdev_destroy_cb(void *io_device)
|
||||
|
||||
spdk_spin_destroy(&bdev->internal.spinlock);
|
||||
free(bdev->internal.qos);
|
||||
free(bdev->internal.stat);
|
||||
|
||||
rc = bdev->fn_table->destruct(bdev->ctxt);
|
||||
if (rc < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user