examples/nvme: Use spdk_nvme_detach_async() and spdk_nvme_detach_poll_async()
Use spdk_nvme_detach_async() and spdk_nvme_detach_poll_async() with a local variable detach_ctx to detach multiple controllers. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I05c504428df56f4ab5d1ffdd19ac81e6c062c89d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4439 Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
d8f4bbeb43
commit
0a903c91ac
@ -904,12 +904,17 @@ static void
|
|||||||
unregister_controllers(void)
|
unregister_controllers(void)
|
||||||
{
|
{
|
||||||
struct ctrlr_entry *entry, *tmp;
|
struct ctrlr_entry *entry, *tmp;
|
||||||
|
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) {
|
TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) {
|
||||||
TAILQ_REMOVE(&g_controllers, entry, link);
|
TAILQ_REMOVE(&g_controllers, entry, link);
|
||||||
spdk_nvme_detach(entry->ctrlr);
|
spdk_nvme_detach_async(entry->ctrlr, &detach_ctx);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -867,6 +867,7 @@ static void
|
|||||||
unregister_controllers(void)
|
unregister_controllers(void)
|
||||||
{
|
{
|
||||||
struct ctrlr_entry *entry, *tmp;
|
struct ctrlr_entry *entry, *tmp;
|
||||||
|
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) {
|
TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) {
|
||||||
TAILQ_REMOVE(&g_controllers, entry, link);
|
TAILQ_REMOVE(&g_controllers, entry, link);
|
||||||
@ -874,9 +875,13 @@ unregister_controllers(void)
|
|||||||
spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) {
|
spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) {
|
||||||
set_latency_tracking_feature(entry->ctrlr, false);
|
set_latency_tracking_feature(entry->ctrlr, false);
|
||||||
}
|
}
|
||||||
spdk_nvme_detach(entry->ctrlr);
|
spdk_nvme_detach_async(entry->ctrlr, &detach_ctx);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1006,13 +1006,18 @@ static void spdk_fio_cleanup(struct thread_data *td)
|
|||||||
g_td_count--;
|
g_td_count--;
|
||||||
if (g_td_count == 0) {
|
if (g_td_count == 0) {
|
||||||
struct spdk_fio_ctrlr *fio_ctrlr, *fio_ctrlr_tmp;
|
struct spdk_fio_ctrlr *fio_ctrlr, *fio_ctrlr_tmp;
|
||||||
|
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(fio_ctrlr, &g_ctrlrs, link, fio_ctrlr_tmp) {
|
TAILQ_FOREACH_SAFE(fio_ctrlr, &g_ctrlrs, link, fio_ctrlr_tmp) {
|
||||||
TAILQ_REMOVE(&g_ctrlrs, fio_ctrlr, link);
|
TAILQ_REMOVE(&g_ctrlrs, fio_ctrlr, link);
|
||||||
spdk_nvme_detach(fio_ctrlr->ctrlr);
|
spdk_nvme_detach_async(fio_ctrlr->ctrlr, &detach_ctx);
|
||||||
free(fio_ctrlr);
|
free(fio_ctrlr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
if (fio_options->enable_vmd) {
|
if (fio_options->enable_vmd) {
|
||||||
spdk_vmd_fini();
|
spdk_vmd_fini();
|
||||||
}
|
}
|
||||||
|
@ -372,6 +372,7 @@ cleanup(void)
|
|||||||
{
|
{
|
||||||
struct ns_entry *ns_entry, *tmp_ns_entry;
|
struct ns_entry *ns_entry, *tmp_ns_entry;
|
||||||
struct ctrlr_entry *ctrlr_entry, *tmp_ctrlr_entry;
|
struct ctrlr_entry *ctrlr_entry, *tmp_ctrlr_entry;
|
||||||
|
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(ns_entry, &g_namespaces, link, tmp_ns_entry) {
|
TAILQ_FOREACH_SAFE(ns_entry, &g_namespaces, link, tmp_ns_entry) {
|
||||||
TAILQ_REMOVE(&g_namespaces, ns_entry, link);
|
TAILQ_REMOVE(&g_namespaces, ns_entry, link);
|
||||||
@ -380,9 +381,13 @@ cleanup(void)
|
|||||||
|
|
||||||
TAILQ_FOREACH_SAFE(ctrlr_entry, &g_controllers, link, tmp_ctrlr_entry) {
|
TAILQ_FOREACH_SAFE(ctrlr_entry, &g_controllers, link, tmp_ctrlr_entry) {
|
||||||
TAILQ_REMOVE(&g_controllers, ctrlr_entry, link);
|
TAILQ_REMOVE(&g_controllers, ctrlr_entry, link);
|
||||||
spdk_nvme_detach(ctrlr_entry->ctrlr);
|
spdk_nvme_detach_async(ctrlr_entry->ctrlr, &detach_ctx);
|
||||||
free(ctrlr_entry);
|
free(ctrlr_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1616,6 +1616,7 @@ int main(int argc, char **argv)
|
|||||||
int rc;
|
int rc;
|
||||||
struct spdk_env_opts opts;
|
struct spdk_env_opts opts;
|
||||||
struct dev *dev;
|
struct dev *dev;
|
||||||
|
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
|
||||||
|
|
||||||
rc = parse_args(argc, argv);
|
rc = parse_args(argc, argv);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
@ -1696,7 +1697,11 @@ int main(int argc, char **argv)
|
|||||||
printf("Cleaning up...\n");
|
printf("Cleaning up...\n");
|
||||||
|
|
||||||
foreach_dev(dev) {
|
foreach_dev(dev) {
|
||||||
spdk_nvme_detach(dev->ctrlr);
|
spdk_nvme_detach_async(dev->ctrlr, &detach_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2168,6 +2168,7 @@ static void
|
|||||||
unregister_controllers(void)
|
unregister_controllers(void)
|
||||||
{
|
{
|
||||||
struct ctrlr_entry *entry, *tmp;
|
struct ctrlr_entry *entry, *tmp;
|
||||||
|
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) {
|
TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) {
|
||||||
TAILQ_REMOVE(&g_controllers, entry, link);
|
TAILQ_REMOVE(&g_controllers, entry, link);
|
||||||
@ -2188,10 +2189,14 @@ unregister_controllers(void)
|
|||||||
free(entry->unused_qpairs);
|
free(entry->unused_qpairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_nvme_detach(entry->ctrlr);
|
spdk_nvme_detach_async(entry->ctrlr, &detach_ctx);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_vmd) {
|
if (g_vmd) {
|
||||||
spdk_vmd_fini();
|
spdk_vmd_fini();
|
||||||
}
|
}
|
||||||
|
@ -955,12 +955,17 @@ static void
|
|||||||
unregister_controllers(void)
|
unregister_controllers(void)
|
||||||
{
|
{
|
||||||
struct ctrlr_entry *entry, *tmp;
|
struct ctrlr_entry *entry, *tmp;
|
||||||
|
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) {
|
TAILQ_FOREACH_SAFE(entry, &g_controllers, link, tmp) {
|
||||||
TAILQ_REMOVE(&g_controllers, entry, link);
|
TAILQ_REMOVE(&g_controllers, entry, link);
|
||||||
spdk_nvme_detach(entry->ctrlr);
|
spdk_nvme_detach_async(entry->ctrlr, &detach_ctx);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user