[PATCH 07/14] nvme-fabrics: Annotate nvmf_lookup_transport() with __must_hold_shared()

From: Bart Van Assche

Date: Mon Nov 02 2026 - 17:57:45 EST


Annotate nvmf_lookup_transport() with
__must_hold_shared(&nvmf_transports_rwsem).

nvmf_lookup_transport() reads nvmf_transports while holding
nvmf_transports_rwsem for reading. Currently,
lockdep_assert_held(&nvmf_transports_rwsem) implicitly assumes lock
ownership for Clang context analysis. Prepare for removing the context
assumption from lockdep_assert_held() by explicitly annotating
nvmf_lookup_transport() with __must_hold_shared() to declare that
callers must hold nvmf_transports_rwsem in shared mode.

Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
---
drivers/nvme/host/fabrics.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 3d7ad86c1955..d3d00adedd14 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -644,6 +644,7 @@ EXPORT_SYMBOL_GPL(nvmf_unregister_transport);

static struct nvmf_transport_ops *nvmf_lookup_transport(
struct nvmf_ctrl_options *opts)
+ __must_hold_shared(&nvmf_transports_rwsem)
{
struct nvmf_transport_ops *ops;