Loading
bdev/nvme: Add lock to unprotected operations around detach controller
When a NVMe bdev has a multipath configuration made of two NVMe-oF controllers and the two NVMe-oF controllers are detached, the NVMe bdev is deleted but sometimes one of NVMe-oF controllers failed to delete. The root cause analysis showed that the failed NVMe-oF controller was not tried to delete at all. It is very likely that some complex race condition occurred. Then, it was found that a few critical operations were not protected by lock. Checking nvme_ns->bdev was protected by lock but clearing nvme_ns->bdev was not protected by the same lock. Removing nvme_ns from bdev->nvme_ns_list was protected by lock but traversing bdev->nvme_ns_list was not protected by the lock. Hence, add these missing locks. The lock ordering should be nvme_bdev->mutex is first and nvme_ctrlr->mutex is second. nvme_ctrlr_depopulate_namespaces() does not hold lock while traversing nvme_ns_tree. However, nvme_ns_tree is deleted at the final controller deletion. Hence, this will not be necessary for now Signed-off-by:Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: I974adbf87ca02e1b2f167dd3eab485934ff03774 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25483 Tested-by:
SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com> Reviewed-by:
GangCao <gang.cao@intel.com> Reviewed-by:
Jim Harris <jim.harris@nvidia.com> Reviewed-by:
Ben Walker <ben@nvidia.com> Community-CI: Mellanox Build Bot