passthru: add RPC testing

And change names of parms to be consistent with others used in
RPC testing.

Change-Id: I8331c6a22866d89a2a4ffb5fc8d41d74b4b7b07d
Signed-off-by: paul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/428724
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
paul luse 2018-10-10 10:54:43 -07:00 committed by Jim Harris
parent 7259370ca4
commit 164d79143b
6 changed files with 26 additions and 18 deletions

View File

@ -1589,7 +1589,7 @@ and a starting point in development of new bdev type.
Name | Optional | Type | Description Name | Optional | Type | Description
----------------------- | -------- | ----------- | ----------- ----------------------- | -------- | ----------- | -----------
passthru_bdev_name | Required | string | Bdev name name | Required | string | Bdev name
base_bdev_name | Required | string | Base bdev name base_bdev_name | Required | string | Base bdev name
### Result ### Result
@ -1604,7 +1604,7 @@ Example request:
{ {
"params": { "params": {
"base_bdev_name": "Malloc0", "base_bdev_name": "Malloc0",
"passthru_bdev_name": "Passsthru0" "name": "Passsthru0"
}, },
"jsonrpc": "2.0", "jsonrpc": "2.0",
"method": "construct_passthru_bdev", "method": "construct_passthru_bdev",

View File

@ -618,14 +618,20 @@ create_passthru_disk(const char *bdev_name, const char *vbdev_name)
struct spdk_bdev *bdev = NULL; struct spdk_bdev *bdev = NULL;
int rc = 0; int rc = 0;
bdev = spdk_bdev_get_by_name(bdev_name); /* Insert the bdev into our global name list even if it doesn't exist yet,
if (!bdev) { * it may show up soon...
return -1; */
rc = vbdev_passthru_insert_name(bdev_name, vbdev_name);
if (rc) {
return rc;
} }
rc = vbdev_passthru_insert_name(bdev_name, vbdev_name); bdev = spdk_bdev_get_by_name(bdev_name);
if (rc != 0) { if (!bdev) {
return rc; /* This is not an error, we tracked the name above and it still
* may show up later.
*/
return 0;
} }
vbdev_passthru_register(bdev); vbdev_passthru_register(bdev);

View File

@ -40,7 +40,7 @@
/* Structure to hold the parameters for this RPC method. */ /* Structure to hold the parameters for this RPC method. */
struct rpc_construct_passthru { struct rpc_construct_passthru {
char *base_bdev_name; char *base_bdev_name;
char *passthru_bdev_name; char *name;
}; };
/* Free the allocated memory resource after the RPC handling. */ /* 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_rpc_construct_passthru(struct rpc_construct_passthru *r)
{ {
free(r->base_bdev_name); free(r->base_bdev_name);
free(r->passthru_bdev_name); free(r->name);
} }
/* Structure to decode the input parameters for this RPC method. */ /* Structure to decode the input parameters for this RPC method. */
static const struct spdk_json_object_decoder rpc_construct_passthru_decoders[] = { 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}, {"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 /* 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; 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) { if (rc != 0) {
goto invalid; goto invalid;
} }
@ -86,7 +86,7 @@ spdk_rpc_construct_passthru_bdev(struct spdk_jsonrpc_request *request,
return; return;
} }
spdk_json_write_string(w, req.passthru_bdev_name); spdk_json_write_string(w, req.name);
spdk_jsonrpc_end_result(request, w); spdk_jsonrpc_end_result(request, w);
free_rpc_construct_passthru(&req); free_rpc_construct_passthru(&req);
return; return;

View File

@ -402,12 +402,12 @@ if __name__ == "__main__":
def construct_passthru_bdev(args): def construct_passthru_bdev(args):
print(rpc.bdev.construct_passthru_bdev(args.client, print(rpc.bdev.construct_passthru_bdev(args.client,
base_bdev_name=args.base_bdev_name, base_bdev_name=args.base_bdev_name,
passthru_bdev_name=args.passthru_bdev_name)) name=args.name))
p = subparsers.add_parser('construct_passthru_bdev', p = subparsers.add_parser('construct_passthru_bdev',
help='Add a pass through bdev on existing 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('-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) p.set_defaults(func=construct_passthru_bdev)
@call_cmd @call_cmd

View File

@ -366,19 +366,19 @@ def delete_pmem_bdev(client, name):
return client.call('delete_pmem_bdev', params) 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. """Construct a pass-through block device.
Args: Args:
base_bdev_name: name of the existing bdev base_bdev_name: name of the existing bdev
passthru_bdev_name: name of block device name: name of block device
Returns: Returns:
Name of created block device. Name of created block device.
""" """
params = { params = {
'base_bdev_name': base_bdev_name, 'base_bdev_name': base_bdev_name,
'passthru_bdev_name': passthru_bdev_name, 'name': name,
} }
return client.call('construct_passthru_bdev', params) return client.call('construct_passthru_bdev', params)

View File

@ -156,6 +156,8 @@ function create_bdev_subsystem_config() {
$rpc_py construct_crypto_bdev -b Malloc3 -c CryMalloc3 -d crypto_qat -k 0123456789123456 $rpc_py construct_crypto_bdev -b Malloc3 -c CryMalloc3 -d crypto_qat -k 0123456789123456
fi fi
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 $rpc_py construct_error_bdev Malloc2
if [ $(uname -s) = Linux ]; then if [ $(uname -s) = Linux ]; then
dd if=/dev/zero of=/tmp/sample_aio bs=2048 count=5000 dd if=/dev/zero of=/tmp/sample_aio bs=2048 count=5000