Commit 0b99cd6f authored by Cunyin Chang's avatar Cunyin Chang Committed by Ben Walker
Browse files

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: default avatarCunyin Chang <cunyin.chang@intel.com>
Reviewed-on: https://review.gerrithub.io/391697


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent a6bf23e2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+5 −20
Original line number Diff line number Diff line
@@ -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;