Spdk/lib/bdev
Shuhei Matsumoto 139940d6c1 bdev/rpc: Fix race condition for per channel bdev_get_iostat
With per channel stats called on thread A,
spdk_bdev_for_each_channel calls
spdk_for_each_channel which immediately sends
a message to thread B.
If thread B has no workload, it may execute the
message relatively fast trying to write stats to
json_write_ctx.
As result, we may have 2 scenarious:
1. json_write_ctx is still not initialized on
thread A, so thread B dereferences a NULL pointer.
1. json_write_ctx is initialized but thread A writes
response header while thread B writes stats - it leads
to corrupted json response.

To fix this race condition, initialize json_write_ctx
before iterating bdevs/channels

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Signed-off-by: Alexey Marchuk <alexeymar@nvidia.com>
Reported-by: Or Gerlitz <ogerlitz@nvidia.com>
Change-Id: I5dae37f1f527437528fc8a8e9c6066f69687dec9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16366
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2023-01-23 17:48:55 +00:00
..
bdev_internal.h bdev: add public APIs for IO statictics processing 2023-01-19 01:57:11 +00:00
bdev_rpc.c bdev/rpc: Fix race condition for per channel bdev_get_iostat 2023-01-23 17:48:55 +00:00
bdev_zone.c update Intel copyright notices 2022-11-10 08:28:53 +00:00
bdev.c bdev: rename values of enum spdk_bdev_reset_stat_mode 2023-01-19 17:33:24 +00:00
Makefile update Intel copyright notices 2022-11-10 08:28:53 +00:00
part.c lib/part: check the return of spdk_bdev_register 2023-01-18 15:15:02 +00:00
scsi_nvme.c update Intel copyright notices 2022-11-10 08:28:53 +00:00
spdk_bdev.map bdev: add public APIs for IO statictics processing 2023-01-19 01:57:11 +00:00
vtune.c update Intel copyright notices 2022-11-10 08:28:53 +00:00