From 0b99cd6f1ef1d58f155ca975d68777f4fe05f929 Mon Sep 17 00:00:00 2001 From: Cunyin Chang Date: Thu, 14 Dec 2017 10:19:57 +0800 Subject: [PATCH] nvmf: remove the data structure spdk_nvmf_subsystem_add_ns_ctx. Add pointer of subsystem in namespace data structure, then we can remove the spdk_nvmf_subsystem_add_ns_ctx. Change-Id: I2d024f10d35fdac64fc34d0cb6523cfca74a8164 Signed-off-by: Cunyin Chang Reviewed-on: https://review.gerrithub.io/391697 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/nvmf/nvmf_internal.h | 1 + lib/nvmf/subsystem.c | 25 +++++-------------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index 4e7b09f8a..e3f1790b6 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -125,6 +125,7 @@ struct spdk_nvmf_request { }; struct spdk_nvmf_ns { + struct spdk_nvmf_subsystem *subsystem; struct spdk_bdev *bdev; struct spdk_bdev_desc *desc; uint32_t id; diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index a4eb8952c..4661a5f7c 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -426,29 +426,21 @@ spdk_nvmf_listener_get_trid(struct spdk_nvmf_listener *listener) return &listener->trid; } -struct spdk_nvmf_subsystem_add_ns_ctx { - struct spdk_nvmf_subsystem *subsystem; - struct spdk_nvmf_ns *ns; -}; - static void spdk_nvmf_subsystem_add_ns_done(struct spdk_io_channel_iter *i, int status) { - void *ctx = spdk_io_channel_iter_get_ctx(i); - - free(ctx); + return; } static void spdk_nvmf_subsystem_ns_update_poll_group(struct spdk_io_channel_iter *i) { - struct spdk_nvmf_subsystem_add_ns_ctx *ctx = spdk_io_channel_iter_get_ctx(i); + struct spdk_nvmf_ns *ns = spdk_io_channel_iter_get_ctx(i); struct spdk_io_channel *ch = spdk_io_channel_iter_get_channel(i); struct spdk_nvmf_poll_group *group = spdk_io_channel_get_ctx(ch); int rc; - rc = spdk_nvmf_poll_group_add_ns(group, ctx->subsystem, ctx->ns); - + rc = spdk_nvmf_poll_group_add_ns(group, ns->subsystem, ns); spdk_for_each_channel_continue(i, rc); } @@ -457,7 +449,6 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd uint32_t nsid) { struct spdk_nvmf_ns *ns; - struct spdk_nvmf_subsystem_add_ns_ctx *ctx; uint32_t i; int rc; @@ -518,6 +509,7 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd memset(ns, 0, sizeof(*ns)); ns->bdev = bdev; ns->id = nsid; + ns->subsystem = subsystem; rc = spdk_bdev_open(bdev, true, NULL, NULL, &ns->desc); if (rc != 0) { SPDK_ERRLOG("Subsystem %s: bdev %s cannot be opened, error=%d\n", @@ -534,13 +526,6 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd subsystem->max_nsid = spdk_max(subsystem->max_nsid, nsid); subsystem->num_allocated_nsid++; - ctx = calloc(1, sizeof(*ctx)); - if (!ctx) { - return -ENOMEM; - } - ctx->subsystem = subsystem; - ctx->ns = ns; - /* Send a message to each poll group to notify it that a new namespace * is available. * TODO: This call does not currently allow the user to wait for these @@ -549,7 +534,7 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd */ spdk_for_each_channel(subsystem->tgt, spdk_nvmf_subsystem_ns_update_poll_group, - ctx, + ns, spdk_nvmf_subsystem_add_ns_done); return nsid;