diff --git a/include/spdk_internal/thread.h b/include/spdk_internal/thread.h index ae3b99757..98fe1ee2a 100644 --- a/include/spdk_internal/thread.h +++ b/include/spdk_internal/thread.h @@ -108,6 +108,8 @@ const char *spdk_poller_get_state_str(struct spdk_poller *poller); uint64_t spdk_poller_get_period_ticks(struct spdk_poller *poller); void spdk_poller_get_stats(struct spdk_poller *poller, struct spdk_poller_stats *stats); +int spdk_io_channel_get_ref_count(struct spdk_io_channel *ch); + const char *spdk_io_device_get_name(struct io_device *dev); struct spdk_poller *spdk_thread_get_first_active_poller(struct spdk_thread *thread); @@ -117,4 +119,7 @@ struct spdk_poller *spdk_thread_get_next_timed_poller(struct spdk_poller *prev); struct spdk_poller *spdk_thread_get_first_paused_poller(struct spdk_thread *thread); struct spdk_poller *spdk_thread_get_next_paused_poller(struct spdk_poller *prev); +struct spdk_io_channel *spdk_thread_get_first_io_channel(struct spdk_thread *thread); +struct spdk_io_channel *spdk_thread_get_next_io_channel(struct spdk_io_channel *prev); + #endif /* SPDK_THREAD_INTERNAL_H_ */ diff --git a/lib/event/app_rpc.c b/lib/event/app_rpc.c index a5cd18464..dba215898 100644 --- a/lib/event/app_rpc.c +++ b/lib/event/app_rpc.c @@ -322,7 +322,7 @@ rpc_get_io_channel(struct spdk_io_channel *ch, struct spdk_json_write_ctx *w) { spdk_json_write_object_begin(w); spdk_json_write_named_string(w, "name", spdk_io_device_get_name(ch->dev)); - spdk_json_write_named_uint32(w, "ref", ch->ref); + spdk_json_write_named_uint32(w, "ref", spdk_io_channel_get_ref_count(ch)); spdk_json_write_object_end(w); } @@ -337,7 +337,8 @@ _rpc_thread_get_io_channels(void *arg) spdk_json_write_named_string(ctx->w, "name", spdk_thread_get_name(thread)); spdk_json_write_named_array_begin(ctx->w, "io_channels"); - TAILQ_FOREACH(ch, &thread->io_channels, tailq) { + for (ch = spdk_thread_get_first_io_channel(thread); ch != NULL; + ch = spdk_thread_get_next_io_channel(ch)) { rpc_get_io_channel(ch, ctx->w); } spdk_json_write_array_end(ctx->w); diff --git a/lib/thread/spdk_thread.map b/lib/thread/spdk_thread.map index 501f5a8be..ff8488ea9 100644 --- a/lib/thread/spdk_thread.map +++ b/lib/thread/spdk_thread.map @@ -61,6 +61,7 @@ spdk_poller_get_state_str; spdk_poller_get_period_ticks; spdk_poller_get_stats; + spdk_io_channel_get_ref_count; spdk_io_device_get_name; spdk_thread_get_first_active_poller; spdk_thread_get_next_active_poller; @@ -68,6 +69,8 @@ spdk_thread_get_next_timed_poller; spdk_thread_get_first_paused_poller; spdk_thread_get_next_paused_poller; + spdk_thread_get_first_io_channel; + spdk_thread_get_next_io_channel; local: *; }; diff --git a/lib/thread/thread.c b/lib/thread/thread.c index bed569ac3..48950bac1 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -1606,6 +1606,18 @@ spdk_thread_get_next_paused_poller(struct spdk_poller *prev) return TAILQ_NEXT(prev, tailq); } +struct spdk_io_channel * +spdk_thread_get_first_io_channel(struct spdk_thread *thread) +{ + return TAILQ_FIRST(&thread->io_channels); +} + +struct spdk_io_channel * +spdk_thread_get_next_io_channel(struct spdk_io_channel *prev) +{ + return TAILQ_NEXT(prev, tailq); +} + struct call_thread { struct spdk_thread *cur_thread; spdk_msg_fn fn; @@ -2068,6 +2080,12 @@ spdk_io_channel_get_io_device(struct spdk_io_channel *ch) return ch->dev->io_device; } +int +spdk_io_channel_get_ref_count(struct spdk_io_channel *ch) +{ + return ch->ref; +} + struct spdk_io_channel_iter { void *io_device; struct io_device *dev;