Commit 3a9b5f3c authored by Maciej Szwed's avatar Maciej Szwed Committed by Jim Harris
Browse files

bdev/nvme: Do not use the same pointer in rpc and bdev code



Due to upcoming change we cannot use the same count
pointer in rpc call and bdev creation function.
With async bdev creation there will be a problem
when freeing context.

Signed-off-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Change-Id: I98da89481d7f506161d8adf5a1b2365907385a13
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468463


Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 05e97101
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1214,17 +1214,17 @@ bdev_nvme_create_bdevs(struct nvme_async_probe_ctx *ctx)
			continue;
		}
		assert(nvme_bdev->id == nsid);
		if (j < *ctx->count) {
		if (j < ctx->count) {
			ctx->names[j] = nvme_bdev->disk.name;
			j++;
		} else {
			SPDK_ERRLOG("Maximum number of namespaces supported per NVMe controller is %du. Unable to return all names of created bdevs\n",
				    *ctx->count);
				    ctx->count);
			return -1;
		}
	}

	*ctx->count = j;
	ctx->count = j;

	return 0;
}
@@ -1254,7 +1254,7 @@ connect_attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,

end:
	if (ctx->cb_fn) {
		ctx->cb_fn(ctx->cb_ctx, rc);
		ctx->cb_fn(ctx->cb_ctx, ctx->count, rc);
	}
}

@@ -1279,7 +1279,7 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
		      struct spdk_nvme_host_id *hostid,
		      const char *base_name,
		      const char **names,
		      uint32_t *count,
		      uint32_t count,
		      const char *hostnqn,
		      uint32_t prchk_flags,
		      spdk_bdev_create_nvme_fn cb_fn,
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ int spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
			  struct spdk_nvme_host_id *hostid,
			  const char *base_name,
			  const char **names,
			  uint32_t *count,
			  uint32_t count,
			  const char *hostnqn,
			  uint32_t prchk_flags,
			  spdk_bdev_create_nvme_fn cb_fn,
+3 −3
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ struct rpc_bdev_nvme_attach_controller_ctx {
};

static void
spdk_rpc_bdev_nvme_attach_controller_done(void *cb_ctx, int rc)
spdk_rpc_bdev_nvme_attach_controller_done(void *cb_ctx, size_t bdev_count, int rc)
{
	struct rpc_bdev_nvme_attach_controller_ctx *ctx = cb_ctx;
	struct spdk_jsonrpc_request *request = ctx->request;
@@ -230,7 +230,7 @@ spdk_rpc_bdev_nvme_attach_controller_done(void *cb_ctx, int rc)

	w = spdk_jsonrpc_begin_result(request);
	spdk_json_write_array_begin(w);
	for (i = 0; i < ctx->count; i++) {
	for (i = 0; i < bdev_count; i++) {
		spdk_json_write_string(w, ctx->names[i]);
	}
	spdk_json_write_array_end(w);
@@ -317,7 +317,7 @@ spdk_rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,

	ctx->request = request;
	ctx->count = NVME_MAX_BDEVS_PER_RPC;
	rc = spdk_bdev_nvme_create(&trid, &hostid, ctx->req.name, ctx->names, &ctx->count, ctx->req.hostnqn,
	rc = spdk_bdev_nvme_create(&trid, &hostid, ctx->req.name, ctx->names, ctx->count, ctx->req.hostnqn,
				   prchk_flags, spdk_rpc_bdev_nvme_attach_controller_done, ctx);
	if (rc) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
+2 −2
Original line number Diff line number Diff line
@@ -81,13 +81,13 @@ struct nvme_bdev {
	struct spdk_nvme_ns	*ns;
};

typedef void (*spdk_bdev_create_nvme_fn)(void *ctx, int rc);
typedef void (*spdk_bdev_create_nvme_fn)(void *ctx, size_t bdev_count, int rc);

struct nvme_async_probe_ctx {
	struct spdk_nvme_probe_ctx *probe_ctx;
	const char *base_name;
	const char **names;
	uint32_t *count;
	uint32_t count;
	uint32_t prchk_flags;
	struct spdk_poller *poller;
	struct spdk_nvme_transport_id trid;