bdev/nvme: add RPC returning information about discovery service
The RPC returns a list of active discovery service connections. Each discovery service is described by a name, its trid, and a list of discovery service trids it refers to. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: Ifa4b9501dd353e7b4948ad830575a6c94dafd86b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12380 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
d71a91bb74
commit
f331ae167b
@ -3344,6 +3344,43 @@ Example response:
|
||||
}
|
||||
~~~
|
||||
|
||||
### bdev_nvme_get_discovery_info {#rpc_bdev_nvme_get_discovery_info}
|
||||
|
||||
Get information about the discovery service.
|
||||
|
||||
#### Example
|
||||
|
||||
Example request:
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "bdev_nvme_get_discovery_info",
|
||||
"id": 1
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": [
|
||||
{
|
||||
"name": "nvme-disc",
|
||||
"trid": {
|
||||
"trtype": "TCP",
|
||||
"adrfam": "IPv4",
|
||||
"traddr": "127.0.0.1",
|
||||
"trsvcid": "8009",
|
||||
"subnqn": "nqn.2014-08.org.nvmexpress.discovery"
|
||||
},
|
||||
"referrals": []
|
||||
}
|
||||
]
|
||||
}
|
||||
~~~
|
||||
|
||||
### bdev_nvme_get_io_paths {#rpc_bdev_nvme_get_io_paths}
|
||||
|
||||
Display all or the specified NVMe bdev's active I/O paths.
|
||||
|
@ -6500,4 +6500,34 @@ nvme_io_path_info_json(struct spdk_json_write_ctx *w, struct nvme_io_path *io_pa
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
void
|
||||
bdev_nvme_get_discovery_info(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
struct discovery_ctx *ctx;
|
||||
struct discovery_entry_ctx *entry_ctx;
|
||||
|
||||
spdk_json_write_array_begin(w);
|
||||
TAILQ_FOREACH(ctx, &g_discovery_ctxs, tailq) {
|
||||
spdk_json_write_object_begin(w);
|
||||
spdk_json_write_named_string(w, "name", ctx->name);
|
||||
|
||||
spdk_json_write_named_object_begin(w, "trid");
|
||||
nvme_bdev_dump_trid_json(&ctx->trid, w);
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_json_write_named_array_begin(w, "referrals");
|
||||
TAILQ_FOREACH(entry_ctx, &ctx->discovery_entry_ctxs, tailq) {
|
||||
spdk_json_write_object_begin(w);
|
||||
spdk_json_write_named_object_begin(w, "trid");
|
||||
nvme_bdev_dump_trid_json(&entry_ctx->trid, w);
|
||||
spdk_json_write_object_end(w);
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
spdk_json_write_array_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
spdk_json_write_array_end(w);
|
||||
}
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT(bdev_nvme)
|
||||
|
@ -300,6 +300,7 @@ int bdev_nvme_start_discovery(struct spdk_nvme_transport_id *trid, const char *b
|
||||
spdk_bdev_nvme_start_discovery_fn cb_fn, void *cb_ctx);
|
||||
int bdev_nvme_stop_discovery(const char *name, spdk_bdev_nvme_stop_discovery_fn cb_fn,
|
||||
void *cb_ctx);
|
||||
void bdev_nvme_get_discovery_info(struct spdk_json_write_ctx *w);
|
||||
|
||||
struct spdk_nvme_ctrlr *bdev_nvme_get_ctrlr(struct spdk_bdev *bdev);
|
||||
|
||||
|
@ -1766,6 +1766,19 @@ cleanup:
|
||||
SPDK_RPC_REGISTER("bdev_nvme_stop_discovery", rpc_bdev_nvme_stop_discovery,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
rpc_bdev_nvme_get_discovery_info(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct spdk_json_write_ctx *w;
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
bdev_nvme_get_discovery_info(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("bdev_nvme_get_discovery_info", rpc_bdev_nvme_get_discovery_info,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
enum error_injection_cmd_type {
|
||||
NVME_ADMIN_CMD = 1,
|
||||
NVME_IO_CMD,
|
||||
|
@ -811,6 +811,12 @@ def bdev_nvme_stop_discovery(client, name):
|
||||
return client.call('bdev_nvme_stop_discovery', params)
|
||||
|
||||
|
||||
def bdev_nvme_get_discovery_info(client):
|
||||
"""Get information about the automatic discovery
|
||||
"""
|
||||
return client.call('bdev_nvme_get_discovery_info')
|
||||
|
||||
|
||||
def bdev_nvme_get_io_paths(client, name):
|
||||
"""Display all or the specified NVMe bdev's active I/O paths
|
||||
|
||||
|
@ -761,6 +761,12 @@ if __name__ == "__main__":
|
||||
p.add_argument('-b', '--name', help="Name of the service to stop", required=True)
|
||||
p.set_defaults(func=bdev_nvme_stop_discovery)
|
||||
|
||||
def bdev_nvme_get_discovery_info(args):
|
||||
print_dict(rpc.bdev.bdev_nvme_get_discovery_info(args.client))
|
||||
|
||||
p = subparsers.add_parser('bdev_nvme_get_discovery_info', help='Get information about the automatic discovery')
|
||||
p.set_defaults(func=bdev_nvme_get_discovery_info)
|
||||
|
||||
def bdev_nvme_get_io_paths(args):
|
||||
print_dict(rpc.bdev.bdev_nvme_get_io_paths(args.client, name=args.name))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user