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: Maciej 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: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Maciej Szwed 2019-09-16 10:34:07 +02:00 committed by Jim Harris
parent 05e97101b2
commit 3a9b5f3cd2
4 changed files with 11 additions and 11 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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));

View File

@ -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;