diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 951fe5e59..79d845208 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -1589,7 +1589,7 @@ and a starting point in development of new bdev type. Name | Optional | Type | Description ----------------------- | -------- | ----------- | ----------- -passthru_bdev_name | Required | string | Bdev name +name | Required | string | Bdev name base_bdev_name | Required | string | Base bdev name ### Result @@ -1604,7 +1604,7 @@ Example request: { "params": { "base_bdev_name": "Malloc0", - "passthru_bdev_name": "Passsthru0" + "name": "Passsthru0" }, "jsonrpc": "2.0", "method": "construct_passthru_bdev", diff --git a/lib/bdev/passthru/vbdev_passthru.c b/lib/bdev/passthru/vbdev_passthru.c index 7bc624648..63d707be1 100644 --- a/lib/bdev/passthru/vbdev_passthru.c +++ b/lib/bdev/passthru/vbdev_passthru.c @@ -618,14 +618,20 @@ create_passthru_disk(const char *bdev_name, const char *vbdev_name) struct spdk_bdev *bdev = NULL; int rc = 0; - bdev = spdk_bdev_get_by_name(bdev_name); - if (!bdev) { - return -1; + /* Insert the bdev into our global name list even if it doesn't exist yet, + * it may show up soon... + */ + rc = vbdev_passthru_insert_name(bdev_name, vbdev_name); + if (rc) { + return rc; } - rc = vbdev_passthru_insert_name(bdev_name, vbdev_name); - if (rc != 0) { - return rc; + bdev = spdk_bdev_get_by_name(bdev_name); + if (!bdev) { + /* This is not an error, we tracked the name above and it still + * may show up later. + */ + return 0; } vbdev_passthru_register(bdev); diff --git a/lib/bdev/passthru/vbdev_passthru_rpc.c b/lib/bdev/passthru/vbdev_passthru_rpc.c index 9f0f95218..823427029 100644 --- a/lib/bdev/passthru/vbdev_passthru_rpc.c +++ b/lib/bdev/passthru/vbdev_passthru_rpc.c @@ -40,7 +40,7 @@ /* Structure to hold the parameters for this RPC method. */ struct rpc_construct_passthru { char *base_bdev_name; - char *passthru_bdev_name; + char *name; }; /* Free the allocated memory resource after the RPC handling. */ @@ -48,13 +48,13 @@ static void free_rpc_construct_passthru(struct rpc_construct_passthru *r) { free(r->base_bdev_name); - free(r->passthru_bdev_name); + free(r->name); } /* Structure to decode the input parameters for this RPC method. */ static const struct spdk_json_object_decoder rpc_construct_passthru_decoders[] = { {"base_bdev_name", offsetof(struct rpc_construct_passthru, base_bdev_name), spdk_json_decode_string}, - {"passthru_bdev_name", offsetof(struct rpc_construct_passthru, passthru_bdev_name), spdk_json_decode_string}, + {"name", offsetof(struct rpc_construct_passthru, name), spdk_json_decode_string}, }; /* Decode the parameters for this RPC method and properly construct the passthru @@ -75,7 +75,7 @@ spdk_rpc_construct_passthru_bdev(struct spdk_jsonrpc_request *request, goto invalid; } - rc = create_passthru_disk(req.base_bdev_name, req.passthru_bdev_name); + rc = create_passthru_disk(req.base_bdev_name, req.name); if (rc != 0) { goto invalid; } @@ -86,7 +86,7 @@ spdk_rpc_construct_passthru_bdev(struct spdk_jsonrpc_request *request, return; } - spdk_json_write_string(w, req.passthru_bdev_name); + spdk_json_write_string(w, req.name); spdk_jsonrpc_end_result(request, w); free_rpc_construct_passthru(&req); return; diff --git a/scripts/rpc.py b/scripts/rpc.py index 6fc7a7eda..076ec15c1 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -402,12 +402,12 @@ if __name__ == "__main__": def construct_passthru_bdev(args): print(rpc.bdev.construct_passthru_bdev(args.client, base_bdev_name=args.base_bdev_name, - passthru_bdev_name=args.passthru_bdev_name)) + name=args.name)) p = subparsers.add_parser('construct_passthru_bdev', help='Add a pass through bdev on existing bdev') p.add_argument('-b', '--base-bdev-name', help="Name of the existing bdev", required=True) - p.add_argument('-p', '--passthru-bdev-name', help="Name of the pass through bdev", required=True) + p.add_argument('-p', '--name', help="Name of the pass through bdev", required=True) p.set_defaults(func=construct_passthru_bdev) @call_cmd diff --git a/scripts/rpc/bdev.py b/scripts/rpc/bdev.py index b65b2d9ea..86d1e333c 100644 --- a/scripts/rpc/bdev.py +++ b/scripts/rpc/bdev.py @@ -366,19 +366,19 @@ def delete_pmem_bdev(client, name): return client.call('delete_pmem_bdev', params) -def construct_passthru_bdev(client, base_bdev_name, passthru_bdev_name): +def construct_passthru_bdev(client, base_bdev_name, name): """Construct a pass-through block device. Args: base_bdev_name: name of the existing bdev - passthru_bdev_name: name of block device + name: name of block device Returns: Name of created block device. """ params = { 'base_bdev_name': base_bdev_name, - 'passthru_bdev_name': passthru_bdev_name, + 'name': name, } return client.call('construct_passthru_bdev', params) diff --git a/test/json_config/common.sh b/test/json_config/common.sh index 84657d086..8172c4f91 100644 --- a/test/json_config/common.sh +++ b/test/json_config/common.sh @@ -156,6 +156,8 @@ function create_bdev_subsystem_config() { $rpc_py construct_crypto_bdev -b Malloc3 -c CryMalloc3 -d crypto_qat -k 0123456789123456 fi fi + $rpc_py construct_malloc_bdev 8 1024 --name Malloc4 + $rpc_py construct_passthru_bdev -b Malloc4 -p PTMalloc4 $rpc_py construct_error_bdev Malloc2 if [ $(uname -s) = Linux ]; then dd if=/dev/zero of=/tmp/sample_aio bs=2048 count=5000