numam-spdk/lib/bdev
Shuhei Matsumoto 563f69ebe8 bdev: spdk_bdev_get_by_name() hold mutex itself while traversing bdev name tree
spdk_bdev_register() and spdk_bdev_add_alias() had not held mutex when
adding bdev name or alias to global bdev name tree. This bug caused unexpected
error when traversing global bdev name tree.

The next patch will fix the bug. This patch is a preparation for the fix.

spdk_bdev_get_by_name() had not held mutex while traversing bdev
name tree. The major callers to spdk_bdev_get_by_name() had held mutex
when calling it. However, this was not clear.

Factor out the internal of spdk_bdev_get_by_name() into a helper
function bdev_get_by_name() and then change spdk_bdev_get_by_name()
to lock and unlock when calling bdev_get_by_name().

Then replace spdk_bdev_get_by_name() call in spdk_bdev_alias_add() and
bdev_register() by bdev_get_by_name() call.

spdk_bdev_get_by_name() call in spdk_bdev_examine() is not changed.
This is called only from JSON RPC and not related with the bug. So
we want to fix only unlocked access to global bdev name tree.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I25f07694e569eec10dba6c3c8543f6ce77412fe8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8523
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2021-07-05 14:46:30 +00:00
..
bdev_internal.h bdev: rename spdk_bdev_get_io to bdev_channel_get_io 2019-11-20 09:34:18 +00:00
bdev_rpc.c bdev: speed up bdev name lookup by using rbtree 2021-05-26 09:22:06 +00:00
bdev_zone.c bdev/zone: add support for get num zones 2021-04-26 16:16:42 +00:00
bdev.c bdev: spdk_bdev_get_by_name() hold mutex itself while traversing bdev name tree 2021-07-05 14:46:30 +00:00
Makefile nvmf: Support physical block size if exposed by bdev 2021-05-06 07:14:40 +00:00
part.c lib/bdev: Added iov to spdk_bdev_zcopy_start 2021-06-04 20:10:07 +00:00
scsi_nvme.c nvme: fix command specific status code 2020-02-20 09:49:24 +00:00
spdk_bdev.map bdev: remove all references to spdk_bdev_open 2021-05-20 15:02:59 +00:00
vtune.c mk: don't use '-include spdk/config.h' 2018-10-02 23:13:32 +00:00