From f208699589bd4342090df2b03563625f6b968d1d Mon Sep 17 00:00:00 2001 From: Pawel Kaminski Date: Thu, 29 Aug 2019 05:54:36 -0400 Subject: [PATCH] rpc: Rename construct_pmem_bdev to bdev_pmem_create Change-Id: I8cc7a13e45395c19f67d6b22d01a2542cc18634c Signed-off-by: Pawel Kaminski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466703 Tested-by: SPDK CI Jenkins Reviewed-by: Broadcom SPDK FC-NVMe CI Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- doc/bdev.md | 4 +-- doc/jsonrpc.md | 4 +-- module/bdev/pmem/bdev_pmem.c | 2 +- module/bdev/pmem/bdev_pmem_rpc.c | 11 +++--- scripts/config_converter.py | 4 +-- scripts/rpc.py | 13 +++---- scripts/rpc/bdev.py | 5 +-- scripts/spdkcli/ui_node.py | 2 +- scripts/spdkcli/ui_root.py | 4 +-- test/config_converter/spdk_config.json | 2 +- test/iscsi_tgt/pmem/iscsi_pmem.sh | 2 +- test/json_config/clear_config.py | 2 +- test/json_config/json_config.sh | 2 +- test/pmem/pmem.sh | 48 +++++++++++++------------- test/pmem/test_plan.md | 36 +++++++++---------- 15 files changed, 72 insertions(+), 69 deletions(-) diff --git a/doc/bdev.md b/doc/bdev.md index 4f6155ab94..7b2f9e99e6 100644 --- a/doc/bdev.md +++ b/doc/bdev.md @@ -527,12 +527,12 @@ Example command `rpc.py delete_pmem_pool /path/to/pmem_pool` -To create bdev based on pmemblk pool file user should use `construct_pmem_bdev ` RPC +To create bdev based on pmemblk pool file user should use `bdev_pmem_create ` RPC command. Example command -`rpc.py construct_pmem_bdev /path/to/pmem_pool -n pmem` +`rpc.py bdev_pmem_create /path/to/pmem_pool -n pmem` To remove a block device representation use the delete_pmem_bdev command. diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index fa13957825..b6520637ca 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -2231,7 +2231,7 @@ Example response: } ~~~ -## construct_pmem_bdev {#rpc_construct_pmem_bdev} +## bdev_pmem_create {#rpc_bdev_pmem_create} Construct @ref bdev_config_pmem bdev. @@ -2259,7 +2259,7 @@ Example request: "name": "Pmem0" }, "jsonrpc": "2.0", - "method": "construct_pmem_bdev", + "method": "bdev_pmem_create", "id": 1 } ~~~ diff --git a/module/bdev/pmem/bdev_pmem.c b/module/bdev/pmem/bdev_pmem.c index 92657e7800..3c51b4f332 100644 --- a/module/bdev/pmem/bdev_pmem.c +++ b/module/bdev/pmem/bdev_pmem.c @@ -290,7 +290,7 @@ bdev_pmem_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx * spdk_json_write_object_begin(w); - spdk_json_write_named_string(w, "method", "construct_pmem_bdev"); + spdk_json_write_named_string(w, "method", "bdev_pmem_create"); spdk_json_write_named_object_begin(w, "params"); spdk_json_write_named_string(w, "name", bdev->name); diff --git a/module/bdev/pmem/bdev_pmem_rpc.c b/module/bdev/pmem/bdev_pmem_rpc.c index 2744673f65..aa1b2f14b0 100644 --- a/module/bdev/pmem/bdev_pmem_rpc.c +++ b/module/bdev/pmem/bdev_pmem_rpc.c @@ -45,7 +45,7 @@ struct rpc_construct_pmem { }; static void -free_rpc_construct_pmem_bdev(struct rpc_construct_pmem *req) +free_rpc_bdev_pmem_create(struct rpc_construct_pmem *req) { free(req->pmem_file); free(req->name); @@ -57,8 +57,8 @@ static const struct spdk_json_object_decoder rpc_construct_pmem_decoders[] = { }; static void -spdk_rpc_construct_pmem_bdev(struct spdk_jsonrpc_request *request, - const struct spdk_json_val *params) +spdk_rpc_bdev_pmem_create(struct spdk_jsonrpc_request *request, + const struct spdk_json_val *params) { struct rpc_construct_pmem req = {}; struct spdk_json_write_ctx *w; @@ -84,9 +84,10 @@ spdk_rpc_construct_pmem_bdev(struct spdk_jsonrpc_request *request, spdk_jsonrpc_end_result(request, w); cleanup: - free_rpc_construct_pmem_bdev(&req); + free_rpc_bdev_pmem_create(&req); } -SPDK_RPC_REGISTER("construct_pmem_bdev", spdk_rpc_construct_pmem_bdev, SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER("bdev_pmem_create", spdk_rpc_bdev_pmem_create, SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_pmem_create, construct_pmem_bdev) struct rpc_delete_pmem { char *name; diff --git a/scripts/config_converter.py b/scripts/config_converter.py index 8bfa2d2c02..da4e125461 100755 --- a/scripts/config_converter.py +++ b/scripts/config_converter.py @@ -14,7 +14,7 @@ bdev_dict["construct_nvme_bdev"] = [] bdev_dict["bdev_nvme_set_hotplug"] = [] bdev_dict["bdev_malloc_create"] = [] bdev_dict["bdev_aio_create"] = [] -bdev_dict["construct_pmem_bdev"] = [] +bdev_dict["bdev_pmem_create"] = [] bdev_dict["construct_virtio_dev"] = [] vhost_dict = OrderedDict() @@ -258,7 +258,7 @@ def get_pmem_bdev_json(config, section): "name": items[1], "pmem_file": items[0] }, - "method": "construct_pmem_bdev" + "method": "bdev_pmem_create" }) return pmem_json diff --git a/scripts/rpc.py b/scripts/rpc.py index 8dd95182fc..80163208c3 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -529,15 +529,16 @@ if __name__ == "__main__": p.add_argument('name', help='iSCSI bdev name') p.set_defaults(func=bdev_iscsi_delete) - def construct_pmem_bdev(args): - print_json(rpc.bdev.construct_pmem_bdev(args.client, - pmem_file=args.pmem_file, - name=args.name)) + def bdev_pmem_create(args): + print_json(rpc.bdev.bdev_pmem_create(args.client, + pmem_file=args.pmem_file, + name=args.name)) - p = subparsers.add_parser('construct_pmem_bdev', help='Add a bdev with pmem backend') + p = subparsers.add_parser('bdev_pmem_create', aliases=['construct_pmem_bdev'], + help='Add a bdev with pmem backend') p.add_argument('pmem_file', help='Path to pmemblk pool file') p.add_argument('-n', '--name', help='Block device name', required=True) - p.set_defaults(func=construct_pmem_bdev) + p.set_defaults(func=bdev_pmem_create) def delete_pmem_bdev(args): rpc.bdev.delete_pmem_bdev(args.client, diff --git a/scripts/rpc/bdev.py b/scripts/rpc/bdev.py index 5e51954f8b..d022324449 100644 --- a/scripts/rpc/bdev.py +++ b/scripts/rpc/bdev.py @@ -578,7 +578,8 @@ def bdev_iscsi_delete(client, name): return client.call('bdev_iscsi_delete', params) -def construct_pmem_bdev(client, pmem_file, name): +@deprecated_alias('construct_pmem_bdev') +def bdev_pmem_create(client, pmem_file, name): """Construct a libpmemblk block device. Args: @@ -592,7 +593,7 @@ def construct_pmem_bdev(client, pmem_file, name): 'pmem_file': pmem_file, 'name': name } - return client.call('construct_pmem_bdev', params) + return client.call('bdev_pmem_create', params) def delete_pmem_bdev(client, name): diff --git a/scripts/spdkcli/ui_node.py b/scripts/spdkcli/ui_node.py index 4cae48f764..fd2734b571 100644 --- a/scripts/spdkcli/ui_node.py +++ b/scripts/spdkcli/ui_node.py @@ -442,7 +442,7 @@ class UIPmemBdev(UIBdev): self.shell.log.info(json.dumps(ret, indent=2)) def ui_command_create(self, pmem_file, name): - ret_name = self.get_root().create_pmem_bdev(pmem_file=pmem_file, + ret_name = self.get_root().bdev_pmem_create(pmem_file=pmem_file, name=name) self.shell.log.info(ret_name) diff --git a/scripts/spdkcli/ui_root.py b/scripts/spdkcli/ui_root.py index f940c528b2..f56659bdbf 100644 --- a/scripts/spdkcli/ui_root.py +++ b/scripts/spdkcli/ui_root.py @@ -220,8 +220,8 @@ class UIRoot(UINode): return response @verbose - def create_pmem_bdev(self, **kwargs): - response = rpc.bdev.construct_pmem_bdev(self.client, **kwargs) + def bdev_pmem_create(self, **kwargs): + response = rpc.bdev.bdev_pmem_create(self.client, **kwargs) return response @verbose diff --git a/test/config_converter/spdk_config.json b/test/config_converter/spdk_config.json index be2fb363ef..8fddffda62 100644 --- a/test/config_converter/spdk_config.json +++ b/test/config_converter/spdk_config.json @@ -164,7 +164,7 @@ "name": "Pmem0", "pmem_file": "/tmp/sample_pmem" }, - "method": "construct_pmem_bdev" + "method": "bdev_pmem_create" } ] }, diff --git a/test/iscsi_tgt/pmem/iscsi_pmem.sh b/test/iscsi_tgt/pmem/iscsi_pmem.sh index fc8dd62636..c02e08552c 100755 --- a/test/iscsi_tgt/pmem/iscsi_pmem.sh +++ b/test/iscsi_tgt/pmem/iscsi_pmem.sh @@ -39,7 +39,7 @@ for i in $(seq 1 $TGT_NR); do luns="" for j in $(seq 1 $PMEM_PER_TGT); do $rpc_py create_pmem_pool /tmp/pool_file${i}_${j} $PMEM_SIZE $PMEM_BLOCK_SIZE - bdevs_name="$($rpc_py construct_pmem_bdev -n pmem${i}_${j} /tmp/pool_file${i}_${j})" + bdevs_name="$($rpc_py bdev_pmem_create -n pmem${i}_${j} /tmp/pool_file${i}_${j})" PMEM_BDEVS+="$bdevs_name " luns+="$bdevs_name:$((j - 1)) " done diff --git a/test/json_config/clear_config.py b/test/json_config/clear_config.py index 6c4bc9b481..c04a59c292 100755 --- a/test/json_config/clear_config.py +++ b/test/json_config/clear_config.py @@ -34,7 +34,7 @@ def get_bdev_destroy_method(bdev): destroy_method_map = {'bdev_malloc_create': "delete_malloc_bdev", 'bdev_null_create': "bdev_null_delete", 'construct_rbd_bdev': "delete_rbd_bdev", - 'construct_pmem_bdev': "delete_pmem_bdev", + 'bdev_pmem_create': "delete_pmem_bdev", 'bdev_aio_create': "bdev_aio_delete", 'bdev_error_create': "bdev_error_delete", 'construct_split_vbdev': "destruct_split_vbdev", diff --git a/test/json_config/json_config.sh b/test/json_config/json_config.sh index 257959c266..8c396b7525 100755 --- a/test/json_config/json_config.sh +++ b/test/json_config/json_config.sh @@ -233,7 +233,7 @@ function create_bdev_subsystem_config() { pmem_pool_file=$(mktemp /tmp/pool_file1.XXXXX) rm -f $pmem_pool_file tgt_rpc create_pmem_pool $pmem_pool_file 128 4096 - tgt_rpc construct_pmem_bdev -n pmem1 $pmem_pool_file + tgt_rpc bdev_pmem_create -n pmem1 $pmem_pool_file expected_notifications+=( bdev_register:pmem1 ) fi diff --git a/test/pmem/pmem.sh b/test/pmem/pmem.sh index 4ef799bfc0..bed7b2aa4a 100755 --- a/test/pmem/pmem.sh +++ b/test/pmem/pmem.sh @@ -440,46 +440,46 @@ function delete_pmem_pool_tc4() } #================================================ -# construct_pmem_bdev tests +# bdev_pmem_create tests #================================================ -function construct_pmem_bdev_tc1() +function bdev_pmem_create_tc1() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file pmem_create_pool_file - if $rpc_py construct_pmem_bdev; then - error "construct_pmem_bdev passed with missing argument!" + if $rpc_py bdev_pmem_create; then + error "bdev_pmem_create passed with missing argument!" fi pmem_clean_pool_file return 0 } -function construct_pmem_bdev_tc2() +function bdev_pmem_create_tc2() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file pmem_create_pool_file - if $rpc_py construct_pmem_bdev -n $bdev_name $rootdir/non/existing/path/non_existent_file; then + if $rpc_py bdev_pmem_create -n $bdev_name $rootdir/non/existing/path/non_existent_file; then error "Created pmem bdev w/out valid pool file!" fi if $rpc_py get_bdevs | jq -r '.[] .name' | grep -qi pmem; then - error "construct_pmem_bdev passed with invalid argument!" + error "bdev_pmem_create passed with invalid argument!" fi pmem_clean_pool_file return 0 } -function construct_pmem_bdev_tc3() +function bdev_pmem_create_tc3() { pmem_print_tc_name ${FUNCNAME[0]} truncate -s 32M $rootdir/test/pmem/random_file - if $rpc_py construct_pmem_bdev -n $bdev_name $rootdir/test/pmem/random_file; then + if $rpc_py bdev_pmem_create -n $bdev_name $rootdir/test/pmem/random_file; then error "Created pmem bdev from random file!" fi @@ -491,7 +491,7 @@ function construct_pmem_bdev_tc3() return 0 } -function construct_pmem_bdev_tc4() +function bdev_pmem_create_tc4() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file $obj_pool_file @@ -504,7 +504,7 @@ function construct_pmem_bdev_tc4() truncate -s "32M" $obj_pool_file fi - if $rpc_py construct_pmem_bdev -n $bdev_name $obj_pool_file; then + if $rpc_py bdev_pmem_create -n $bdev_name $obj_pool_file; then pmem_clean_pool_file $obj_pool_file error "Created pmem bdev from obj type pmem file!" fi @@ -513,7 +513,7 @@ function construct_pmem_bdev_tc4() return 0 } -function construct_pmem_bdev_tc5() +function bdev_pmem_create_tc5() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -524,7 +524,7 @@ function construct_pmem_bdev_tc5() error "Failed to get pmem info!" fi - pmem_bdev_name=$($rpc_py construct_pmem_bdev -n $bdev_name $default_pool_file) + pmem_bdev_name=$($rpc_py bdev_pmem_create -n $bdev_name $default_pool_file) if [ $? != 0 ]; then error "Failed to create pmem bdev" fi @@ -545,7 +545,7 @@ function construct_pmem_bdev_tc5() return 0 } -function construct_pmem_bdev_tc6() +function bdev_pmem_create_tc6() { pmem_print_tc_name ${FUNCNAME[0]} local pmem_bdev_name @@ -556,7 +556,7 @@ function construct_pmem_bdev_tc6() error "Failed to get info on pmem pool file!" fi - pmem_bdev_name=$($rpc_py construct_pmem_bdev -n $bdev_name $default_pool_file) + pmem_bdev_name=$($rpc_py bdev_pmem_create -n $bdev_name $default_pool_file) if [ $? != 0 ]; then error "Failed to create pmem bdev!" fi @@ -565,7 +565,7 @@ function construct_pmem_bdev_tc6() error "Pmem bdev not found!" fi - if $rpc_py construct_pmem_bdev -n $bdev_name $default_pool_file; then + if $rpc_py bdev_pmem_create -n $bdev_name $default_pool_file; then error "Constructed pmem bdev with occupied path!" fi @@ -596,7 +596,7 @@ function delete_bdev_tc1() error "Failed to get pmem info!" fi - pmem_bdev_name=$($rpc_py construct_pmem_bdev -n $bdev_name $default_pool_file) + pmem_bdev_name=$($rpc_py bdev_pmem_create -n $bdev_name $default_pool_file) if [ $? != 0 ]; then error "Failed to create pmem bdev!" fi @@ -629,7 +629,7 @@ function delete_bdev_tc2() error "Failed to get pmem info!" fi - pmem_bdev_name=$($rpc_py construct_pmem_bdev -n $bdev_name $default_pool_file) + pmem_bdev_name=$($rpc_py bdev_pmem_create -n $bdev_name $default_pool_file) if [ $? != 0 ]; then error "Failed to create pmem bdev" fi @@ -683,12 +683,12 @@ if $test_delete || $test_all; then fi if $test_construct_bdev || $test_all; then - construct_pmem_bdev_tc1 - construct_pmem_bdev_tc2 - construct_pmem_bdev_tc3 - construct_pmem_bdev_tc4 - construct_pmem_bdev_tc5 - construct_pmem_bdev_tc6 + bdev_pmem_create_tc1 + bdev_pmem_create_tc2 + bdev_pmem_create_tc3 + bdev_pmem_create_tc4 + bdev_pmem_create_tc5 + bdev_pmem_create_tc6 fi if $test_delete_bdev || $test_all; then diff --git a/test/pmem/test_plan.md b/test/pmem/test_plan.md index 10150a51b9..8759cd24bb 100644 --- a/test/pmem/test_plan.md +++ b/test/pmem/test_plan.md @@ -199,46 +199,46 @@ Steps & expected results: - call delete_pmem_pool on already deleted pmem pool - return code !=0 and error code = ENODEV -### construct_pmem_bdev +### bdev_pmem_create -#### construct_pmem_bdev_tc1 +#### bdev_pmem_create_tc1 Negative test for constructing new pmem bdev. -Call create_pmem_bdev with missing argument. +Call bdev_pmem_create with missing argument. Steps & expected results: -- Call construct_pmem_bdev with missing path argument. +- Call bdev_pmem_create with missing path argument. - Check that return code != 0 -#### construct_pmem_bdev_tc2 +#### bdev_pmem_create_tc2 Negative test for constructing new pmem bdev. -Call construct_pmem_bdev with not existing path argument. +Call bdev_pmem_create with not existing path argument. Steps & expected results: -- call construct_pmem_bdev with incorrect (not existing) path +- call bdev_pmem_create with incorrect (not existing) path - call return code != 0 and error code = ENODEV - using get_bdevs check that no pmem bdev was created -#### construct_pmem_bdev_tc3 +#### bdev_pmem_create_tc3 Negative test for constructing pmem bdevs with random file instead of pmemblk pool. Steps & expected results: - using a system tool (like dd) create a random file -- call construct_pmem_bdev with path pointing to that file +- call bdev_pmem_create with path pointing to that file - return code != 0, error code = ENOTBLK -#### construct_pmem_bdev_tc4 +#### bdev_pmem_create_tc4 Negative test for constructing pmem bdevs with pmemobj instead of pmemblk pool. Steps & expected results: - Using pmem utility tools create pool of OBJ type instead of BLK (if needed utility tools are not available - create random file in filesystem) -- call construct_pmem_bdev with path pointing to that pool +- call bdev_pmem_create with path pointing to that pool - return code != 0, error code = ENOTBLK -#### construct_pmem_bdev_tc5 +#### bdev_pmem_create_tc5 Positive test for constructing pmem bdev. Steps & expected results: - call create_pmem_pool with correct arguments - return code = 0, no errors - call pmem_pool_info and check if pmem files exists - return code = 0, no errors -- call construct_pmem_bdev with with correct arguments to create a pmem bdev +- call bdev_pmem_create with with correct arguments to create a pmem bdev - return code = 0, no errors - using get_bdevs check that pmem bdev was created - delete pmem bdev using delete_pmem_bdev @@ -246,17 +246,17 @@ Steps & expected results: - delete previously created pmem pool - return code = 0, no error code -#### construct_pmem_bdev_tc6 +#### bdev_pmem_create_tc6 Negative test for constructing pmem bdevs twice on the same pmem. Steps & expected results: - call create_pmem_pool with correct arguments - return code = 0, no errors - call pmem_pool_info and check if pmem files exists - return code = 0, no errors -- call construct_pmem_bdev with with correct arguments to create a pmem bdev +- call bdev_pmem_create with with correct arguments to create a pmem bdev - return code = 0, no errors - using get_bdevs check that pmem bdev was created -- call construct_pmem_bdev again on the same pmem file +- call bdev_pmem_create again on the same pmem file - return code != 0, error code = EEXIST - delete pmem bdev using delete_pmem_bdev - return code = 0, no error code @@ -275,7 +275,7 @@ block size=512, total size=256M - return code = 0, no errors - call pmem_pool_info and check if pmem file exists - return code = 0, no errors -- call construct_pmem_bdev and create a pmem bdev +- call bdev_pmem_create and create a pmem bdev - return code = 0, no errors - using get_bdevs check that pmem bdev was created - delete pmem bdev using delete_pmem_bdev @@ -291,7 +291,7 @@ block size=512, total size=256M - return code = 0, no errors - call pmem_pool_info and check if pmem file exists - return code = 0, no errors -- call construct_pmem_bdev and create a pmem bdev +- call bdev_pmem_create and create a pmem bdev - return code = 0, no errors - using get_bdevs check that pmem bdev was created - delete pmem bdev using delete_pmem_bdev