From 06557b0a4d6afed3baa2b4c8c830054c3788e029 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 6 Dec 2016 10:36:34 -0700 Subject: [PATCH] nvme: Add remove callback to transport scan Scanning the transport may result in both new devices and removed devices, so pass the callback for both operations. Change-Id: I6f73dbe6fd7cf61575c354b43f8ae3e2a01e2965 Signed-off-by: Ben Walker --- lib/nvme/nvme.c | 2 +- lib/nvme/nvme_internal.h | 2 +- lib/nvme/nvme_pcie.c | 4 +++- lib/nvme/nvme_rdma.c | 4 +++- lib/nvme/nvme_transport.c | 6 ++++-- test/lib/nvme/unit/nvme_c/nvme_ut.c | 4 +++- test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c | 4 +++- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/nvme/nvme.c b/lib/nvme/nvme.c index 2db9557c0..12e265b50 100644 --- a/lib/nvme/nvme.c +++ b/lib/nvme/nvme.c @@ -426,7 +426,7 @@ _spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx, } } - nvme_transport_ctrlr_scan(trid, probe_cb, cb_ctx); + nvme_transport_ctrlr_scan(trid, cb_ctx, probe_cb, remove_cb); if (!spdk_process_is_primary()) { TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) { diff --git a/lib/nvme/nvme_internal.h b/lib/nvme/nvme_internal.h index 875c0a357..ed02c3371 100644 --- a/lib/nvme/nvme_internal.h +++ b/lib/nvme/nvme_internal.h @@ -558,7 +558,7 @@ void nvme_qpair_print_completion(struct spdk_nvme_qpair *qpair, struct spdk_nvme struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport_type trtype, const struct spdk_nvme_ctrlr_opts *opts, \ const struct spdk_nvme_probe_info *probe_info, void *devhandle); \ int nvme_ ## name ## _ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr); \ - int nvme_ ## name ## _ctrlr_scan(const struct spdk_nvme_transport_id *trid, spdk_nvme_probe_cb probe_cb, void *cb_ctx); \ + int nvme_ ## name ## _ctrlr_scan(const struct spdk_nvme_transport_id *trid, void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_remove_cb remove_cb); \ int nvme_ ## name ## _ctrlr_attach(enum spdk_nvme_transport_type trtype, spdk_nvme_probe_cb probe_cb, void *cb_ctx, struct spdk_pci_addr *addr); \ int nvme_ ## name ## _ctrlr_enable(struct spdk_nvme_ctrlr *ctrlr); \ int nvme_ ## name ## _ctrlr_get_pci_id(struct spdk_nvme_ctrlr *ctrlr, struct spdk_pci_id *pci_id); \ diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index b6c7b1625..410aca006 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -553,7 +553,9 @@ pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev) int nvme_pcie_ctrlr_scan(const struct spdk_nvme_transport_id *trid, - spdk_nvme_probe_cb probe_cb, void *cb_ctx) + void *cb_ctx, + spdk_nvme_probe_cb probe_cb, + spdk_nvme_remove_cb remove_cb) { struct nvme_pcie_enum_ctx enum_ctx; diff --git a/lib/nvme/nvme_rdma.c b/lib/nvme/nvme_rdma.c index f6433560e..d359f2cfb 100644 --- a/lib/nvme/nvme_rdma.c +++ b/lib/nvme/nvme_rdma.c @@ -1052,7 +1052,9 @@ nvme_fabrics_get_log_discovery_page(struct spdk_nvme_ctrlr *ctrlr, /* This function must only be called while holding g_spdk_nvme_driver->lock */ int nvme_rdma_ctrlr_scan(const struct spdk_nvme_transport_id *trid, - spdk_nvme_probe_cb probe_cb, void *cb_ctx) + void *cb_ctx, + spdk_nvme_probe_cb probe_cb, + spdk_nvme_remove_cb remove_cb) { struct spdk_nvme_probe_info probe_info; struct spdk_nvme_ctrlr_opts discovery_opts; diff --git a/lib/nvme/nvme_transport.c b/lib/nvme/nvme_transport.c index ca6b0f5ca..545e78157 100644 --- a/lib/nvme/nvme_transport.c +++ b/lib/nvme/nvme_transport.c @@ -92,9 +92,11 @@ struct spdk_nvme_ctrlr * int nvme_transport_ctrlr_scan(const struct spdk_nvme_transport_id *trid, - spdk_nvme_probe_cb probe_cb, void *cb_ctx) + void *cb_ctx, + spdk_nvme_probe_cb probe_cb, + spdk_nvme_remove_cb remove_cb) { - NVME_TRANSPORT_CALL(trid->trtype, ctrlr_scan, (trid, probe_cb, cb_ctx)); + NVME_TRANSPORT_CALL(trid->trtype, ctrlr_scan, (trid, cb_ctx, probe_cb, remove_cb)); } int diff --git a/test/lib/nvme/unit/nvme_c/nvme_ut.c b/test/lib/nvme/unit/nvme_c/nvme_ut.c index c91bb9d27..bbbb37b9b 100644 --- a/test/lib/nvme/unit/nvme_c/nvme_ut.c +++ b/test/lib/nvme/unit/nvme_c/nvme_ut.c @@ -72,7 +72,9 @@ struct spdk_nvme_ctrlr * int nvme_transport_ctrlr_scan(const struct spdk_nvme_transport_id *trid, - spdk_nvme_probe_cb probe_cb, void *cb_ctx) + void *cb_ctx, + spdk_nvme_probe_cb probe_cb, + spdk_nvme_remove_cb remove_cb) { return 0; } diff --git a/test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c b/test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c index 957a10599..823e4de2c 100644 --- a/test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c +++ b/test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c @@ -195,7 +195,9 @@ nvme_ctrlr_get_ref_count(struct spdk_nvme_ctrlr *ctrlr) int nvme_transport_ctrlr_scan(const struct spdk_nvme_transport_id *trid, - spdk_nvme_probe_cb probe_cb, void *cb_ctx) + void *cb_ctx, + spdk_nvme_probe_cb probe_cb, + spdk_nvme_remove_cb remove_cb) { return 0; }