bdev/nvme: respond to attach RPC after bdev is examined
This makes use of newly added spdk_bdev_wait_for_examine(),
to only respond to RPC when bdev was fully examined.
Fixes #1760
Issue above was triggered in DD tests where application
finished before the examine had a chance to fully finish.
This patch addresses it by making sure that nvme attach
RPC waits for completion of the examine.
Later patch in series adds the bdev_wait_for_examine RPC
to multiple static configuration files. Making sure similar
issues do no occur for bdev modules which do not have changes
in their RPC as here.
The issue does not occur for JSON configs generated from apps,
see patch:
(e57bb1af
)lib/bdev: build bdev_wait_for_examine into subsystem
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie3ca2933af97a40ae01ecc3eefe2161d2d34c602
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5483
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
54bc83dcc7
commit
64c6ddbf95
@ -218,36 +218,48 @@ static const struct spdk_json_object_decoder rpc_bdev_nvme_attach_controller_dec
|
||||
struct rpc_bdev_nvme_attach_controller_ctx {
|
||||
struct rpc_bdev_nvme_attach_controller req;
|
||||
uint32_t count;
|
||||
size_t bdev_count;
|
||||
const char *names[NVME_MAX_BDEVS_PER_RPC];
|
||||
struct spdk_jsonrpc_request *request;
|
||||
};
|
||||
|
||||
static void
|
||||
rpc_bdev_nvme_attach_controller_done(void *cb_ctx, size_t bdev_count, int rc)
|
||||
rpc_bdev_nvme_attach_controller_examined(void *cb_ctx)
|
||||
{
|
||||
struct rpc_bdev_nvme_attach_controller_ctx *ctx = cb_ctx;
|
||||
struct spdk_jsonrpc_request *request = ctx->request;
|
||||
struct spdk_json_write_ctx *w;
|
||||
size_t i;
|
||||
|
||||
if (rc < 0) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
spdk_json_write_array_begin(w);
|
||||
for (i = 0; i < bdev_count; i++) {
|
||||
for (i = 0; i < ctx->bdev_count; i++) {
|
||||
spdk_json_write_string(w, ctx->names[i]);
|
||||
}
|
||||
spdk_json_write_array_end(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
|
||||
exit:
|
||||
free_rpc_bdev_nvme_attach_controller(&ctx->req);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
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;
|
||||
|
||||
if (rc < 0) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_bdev_nvme_attach_controller(&ctx->req);
|
||||
free(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->bdev_count = bdev_count;
|
||||
spdk_bdev_wait_for_examine(rpc_bdev_nvme_attach_controller_examined, ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
|
Loading…
Reference in New Issue
Block a user