diff --git a/doc/ftl.md b/doc/ftl.md index da19ccf209..2ce99d7909 100644 --- a/doc/ftl.md +++ b/doc/ftl.md @@ -225,7 +225,7 @@ Logical blks per chunk: 24576 Similarly to other bdevs, the FTL bdevs can be created either based on config files or via RPC. Both interfaces require the same arguments which are described by the `--help` option of the -`construct_ftl_bdev` RPC call, which are: +`bdev_ftl_create` RPC call, which are: - bdev's name - transport type of the device (e.g. PCIe) - transport address of the device (e.g. `00:0a.0`) @@ -248,12 +248,12 @@ The above will result in creation of two devices: The same can be achieved with the following two RPC calls: ``` -$ scripts/rpc.py construct_ftl_bdev -b nvme0 -l 0-3 -a 00:0a.0 +$ scripts/rpc.py bdev_ftl_create -b nvme0 -l 0-3 -a 00:0a.0 { "name": "nvme0", "uuid": "b4624a89-3174-476a-b9e5-5fd27d73e870" } -$ scripts/rpc.py construct_ftl_bdev -b nvme1 -l 0-3 -a 00:0a.0 -u e9825835-b03c-49d7-bc3e-5827cbde8a88 +$ scripts/rpc.py bdev_ftl_create -b nvme1 -l 0-3 -a 00:0a.0 -u e9825835-b03c-49d7-bc3e-5827cbde8a88 { "name": "nvme1", "uuid": "e9825835-b03c-49d7-bc3e-5827cbde8a88" diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 5908e229ca..4de0949122 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -297,8 +297,8 @@ Example response: "bdev_null_create", "bdev_malloc_delete", "bdev_malloc_create", - "delete_ftl_bdev", - "construct_ftl_bdev", + "bdev_ftl_delete", + "bdev_ftl_create", "bdev_lvol_get_lvstores", "bdev_lvol_delete", "bdev_lvol_resize", @@ -2005,7 +2005,7 @@ Example response: } ~~~ -## construct_ftl_bdev {#rpc_construct_ftl_bdev} +## bdev_ftl_create {#rpc_bdev_ftl_create} Create FTL bdev. @@ -2040,7 +2040,7 @@ Example request: "uuid": "4a7481ce-786f-41a0-9b86-8f7465c8f4d3" }, "jsonrpc": "2.0", - "method": "construct_ftl_bdev", + "method": "bdev_ftl_create", "id": 1 } ~~~ @@ -2058,7 +2058,7 @@ Example response: } ~~~ -## delete_ftl_bdev {#rpc_delete_ftl_bdev} +## bdev_ftl_delete {#rpc_bdev_ftl_delete} Delete FTL bdev. @@ -2080,7 +2080,7 @@ Example request: "name": "nvme0" }, "jsonrpc": "2.0", - "method": "delete_ftl_bdev", + "method": "bdev_ftl_delete", "id": 1 } ~~~ diff --git a/module/bdev/nvme/bdev_ftl.c b/module/bdev/nvme/bdev_ftl.c index 7c3e76281a..9e5030b30c 100644 --- a/module/bdev/nvme/bdev_ftl.c +++ b/module/bdev/nvme/bdev_ftl.c @@ -437,7 +437,7 @@ bdev_ftl_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w spdk_json_write_object_begin(w); - spdk_json_write_named_string(w, "method", "construct_ftl_bdev"); + spdk_json_write_named_string(w, "method", "bdev_ftl_create"); spdk_json_write_named_object_begin(w, "params"); spdk_json_write_named_string(w, "name", ftl_bdev->bdev.name); diff --git a/module/bdev/nvme/bdev_ftl_rpc.c b/module/bdev/nvme/bdev_ftl_rpc.c index 946cf267d4..3144829288 100644 --- a/module/bdev/nvme/bdev_ftl_rpc.c +++ b/module/bdev/nvme/bdev_ftl_rpc.c @@ -39,7 +39,7 @@ #include "bdev_ftl.h" -struct rpc_construct_ftl { +struct rpc_bdev_ftl_create { char *name; char *trtype; char *traddr; @@ -50,7 +50,7 @@ struct rpc_construct_ftl { }; static void -free_rpc_construct_ftl(struct rpc_construct_ftl *req) +free_rpc_bdev_ftl_create(struct rpc_bdev_ftl_create *req) { free(req->name); free(req->trtype); @@ -60,65 +60,65 @@ free_rpc_construct_ftl(struct rpc_construct_ftl *req) free(req->cache_bdev); } -static const struct spdk_json_object_decoder rpc_construct_ftl_decoders[] = { - {"name", offsetof(struct rpc_construct_ftl, name), spdk_json_decode_string}, - {"trtype", offsetof(struct rpc_construct_ftl, trtype), spdk_json_decode_string}, - {"traddr", offsetof(struct rpc_construct_ftl, traddr), spdk_json_decode_string}, - {"punits", offsetof(struct rpc_construct_ftl, punits), spdk_json_decode_string}, - {"uuid", offsetof(struct rpc_construct_ftl, uuid), spdk_json_decode_string, true}, - {"cache", offsetof(struct rpc_construct_ftl, cache_bdev), spdk_json_decode_string, true}, +static const struct spdk_json_object_decoder rpc_bdev_ftl_create_decoders[] = { + {"name", offsetof(struct rpc_bdev_ftl_create, name), spdk_json_decode_string}, + {"trtype", offsetof(struct rpc_bdev_ftl_create, trtype), spdk_json_decode_string}, + {"traddr", offsetof(struct rpc_bdev_ftl_create, traddr), spdk_json_decode_string}, + {"punits", offsetof(struct rpc_bdev_ftl_create, punits), spdk_json_decode_string}, + {"uuid", offsetof(struct rpc_bdev_ftl_create, uuid), spdk_json_decode_string, true}, + {"cache", offsetof(struct rpc_bdev_ftl_create, cache_bdev), spdk_json_decode_string, true}, { - "allow_open_bands", offsetof(struct rpc_construct_ftl, ftl_conf) + + "allow_open_bands", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, allow_open_bands), spdk_json_decode_bool, true }, { - "overprovisioning", offsetof(struct rpc_construct_ftl, ftl_conf) + + "overprovisioning", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, lba_rsvd), spdk_json_decode_uint64, true }, { - "limit_crit", offsetof(struct rpc_construct_ftl, ftl_conf) + + "limit_crit", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, limits[SPDK_FTL_LIMIT_CRIT]) + offsetof(struct spdk_ftl_limit, limit), spdk_json_decode_uint64, true }, { - "limit_crit_threshold", offsetof(struct rpc_construct_ftl, ftl_conf) + + "limit_crit_threshold", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, limits[SPDK_FTL_LIMIT_CRIT]) + offsetof(struct spdk_ftl_limit, thld), spdk_json_decode_uint64, true }, { - "limit_high", offsetof(struct rpc_construct_ftl, ftl_conf) + + "limit_high", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, limits[SPDK_FTL_LIMIT_HIGH]) + offsetof(struct spdk_ftl_limit, limit), spdk_json_decode_uint64, true }, { - "limit_high_threshold", offsetof(struct rpc_construct_ftl, ftl_conf) + + "limit_high_threshold", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, limits[SPDK_FTL_LIMIT_HIGH]) + offsetof(struct spdk_ftl_limit, thld), spdk_json_decode_uint64, true }, { - "limit_low", offsetof(struct rpc_construct_ftl, ftl_conf) + + "limit_low", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, limits[SPDK_FTL_LIMIT_LOW]) + offsetof(struct spdk_ftl_limit, limit), spdk_json_decode_uint64, true }, { - "limit_low_threshold", offsetof(struct rpc_construct_ftl, ftl_conf) + + "limit_low_threshold", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, limits[SPDK_FTL_LIMIT_LOW]) + offsetof(struct spdk_ftl_limit, thld), spdk_json_decode_uint64, true }, { - "limit_start", offsetof(struct rpc_construct_ftl, ftl_conf) + + "limit_start", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, limits[SPDK_FTL_LIMIT_START]) + offsetof(struct spdk_ftl_limit, limit), spdk_json_decode_uint64, true }, { - "limit_start_threshold", offsetof(struct rpc_construct_ftl, ftl_conf) + + "limit_start_threshold", offsetof(struct rpc_bdev_ftl_create, ftl_conf) + offsetof(struct spdk_ftl_conf, limits[SPDK_FTL_LIMIT_START]) + offsetof(struct spdk_ftl_limit, thld), spdk_json_decode_uint64, true @@ -128,7 +128,7 @@ static const struct spdk_json_object_decoder rpc_construct_ftl_decoders[] = { #define FTL_RANGE_MAX_LENGTH 32 static void -_spdk_rpc_construct_ftl_bdev_cb(const struct ftl_bdev_info *bdev_info, void *ctx, int status) +_spdk_rpc_bdev_ftl_create_cb(const struct ftl_bdev_info *bdev_info, void *ctx, int status) { struct spdk_jsonrpc_request *request = ctx; char bdev_uuid[SPDK_UUID_STRING_LEN]; @@ -151,18 +151,18 @@ _spdk_rpc_construct_ftl_bdev_cb(const struct ftl_bdev_info *bdev_info, void *ctx } static void -spdk_rpc_construct_ftl_bdev(struct spdk_jsonrpc_request *request, - const struct spdk_json_val *params) +spdk_rpc_bdev_ftl_create(struct spdk_jsonrpc_request *request, + const struct spdk_json_val *params) { - struct rpc_construct_ftl req = {}; + struct rpc_bdev_ftl_create req = {}; struct ftl_bdev_init_opts opts = {}; char range[FTL_RANGE_MAX_LENGTH]; int rc; spdk_ftl_conf_init_defaults(&req.ftl_conf); - if (spdk_json_decode_object(params, rpc_construct_ftl_decoders, - SPDK_COUNTOF(rpc_construct_ftl_decoders), + if (spdk_json_decode_object(params, rpc_bdev_ftl_create_decoders, + SPDK_COUNTOF(rpc_bdev_ftl_create_decoders), &req)) { spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters"); @@ -220,7 +220,7 @@ spdk_rpc_construct_ftl_bdev(struct spdk_jsonrpc_request *request, } } - rc = bdev_ftl_init_bdev(&opts, _spdk_rpc_construct_ftl_bdev_cb, request); + rc = bdev_ftl_init_bdev(&opts, _spdk_rpc_bdev_ftl_create_cb, request); if (rc) { spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR, "Failed to create FTL bdev: %s", @@ -229,21 +229,22 @@ spdk_rpc_construct_ftl_bdev(struct spdk_jsonrpc_request *request, } invalid: - free_rpc_construct_ftl(&req); + free_rpc_bdev_ftl_create(&req); } -SPDK_RPC_REGISTER("construct_ftl_bdev", spdk_rpc_construct_ftl_bdev, SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER("bdev_ftl_create", spdk_rpc_bdev_ftl_create, SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_ftl_create, construct_ftl_bdev) struct rpc_delete_ftl { char *name; }; static const struct spdk_json_object_decoder rpc_delete_ftl_decoders[] = { - {"name", offsetof(struct rpc_construct_ftl, name), spdk_json_decode_string}, + {"name", offsetof(struct rpc_bdev_ftl_create, name), spdk_json_decode_string}, }; static void -_spdk_rpc_delete_ftl_bdev_cb(void *cb_arg, int bdeverrno) +_spdk_rpc_bdev_ftl_delete_cb(void *cb_arg, int bdeverrno) { struct spdk_jsonrpc_request *request = cb_arg; struct spdk_json_write_ctx *w = spdk_jsonrpc_begin_result(request); @@ -253,7 +254,7 @@ _spdk_rpc_delete_ftl_bdev_cb(void *cb_arg, int bdeverrno) } static void -spdk_rpc_delete_ftl_bdev(struct spdk_jsonrpc_request *request, +spdk_rpc_bdev_ftl_delete(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params) { struct rpc_delete_ftl attrs = {}; @@ -266,9 +267,10 @@ spdk_rpc_delete_ftl_bdev(struct spdk_jsonrpc_request *request, goto invalid; } - bdev_ftl_delete_bdev(attrs.name, _spdk_rpc_delete_ftl_bdev_cb, request); + bdev_ftl_delete_bdev(attrs.name, _spdk_rpc_bdev_ftl_delete_cb, request); invalid: free(attrs.name); } -SPDK_RPC_REGISTER("delete_ftl_bdev", spdk_rpc_delete_ftl_bdev, SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER("bdev_ftl_delete", spdk_rpc_bdev_ftl_delete, SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_ftl_delete, delete_ftl_bdev) diff --git a/scripts/gen_ftl.sh b/scripts/gen_ftl.sh index ba34f42d86..064840d3af 100755 --- a/scripts/gen_ftl.sh +++ b/scripts/gen_ftl.sh @@ -27,7 +27,7 @@ function create_json_config() echo '"subsystem": "bdev",' echo '"config": [' echo '{' - echo '"method": "construct_ftl_bdev",' + echo '"method": "bdev_ftl_create",' echo '"params": {' echo "\"name\": \"$2\"," echo '"trtype": "PCIe",' diff --git a/scripts/rpc.py b/scripts/rpc.py index b149df5595..4142f8d8da 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -1385,7 +1385,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse # ftl ftl_valid_limits = ('crit', 'high', 'low', 'start') - def construct_ftl_bdev(args): + def bdev_ftl_create(args): def parse_limits(limits, arg_dict, key_suffix=''): for limit in limits.split(','): key, value = limit.split(':', 1) @@ -1401,18 +1401,18 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse if args.limit: parse_limits(args.limit, arg_limits) - print_dict(rpc.bdev.construct_ftl_bdev(args.client, - name=args.name, - trtype=args.trtype, - traddr=args.traddr, - punits=args.punits, - uuid=args.uuid, - cache=args.cache, - allow_open_bands=args.allow_open_bands, - overprovisioning=args.overprovisioning, - **arg_limits)) + print_dict(rpc.bdev.bdev_ftl_create(args.client, + name=args.name, + trtype=args.trtype, + traddr=args.traddr, + punits=args.punits, + uuid=args.uuid, + cache=args.cache, + allow_open_bands=args.allow_open_bands, + overprovisioning=args.overprovisioning, + **arg_limits)) - p = subparsers.add_parser('construct_ftl_bdev', + p = subparsers.add_parser('bdev_ftl_create', aliases=['construct_ftl_bdev'], help='Add FTL bdev') p.add_argument('-b', '--name', help="Name of the bdev", required=True) p.add_argument('-t', '--trtype', @@ -1435,14 +1435,15 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse ' levels, e.g. crit:0,high:20,low:80') limits.add_argument('--limit-threshold', help='Number of free bands triggering a given level of' ' write limiting e.g. crit:1,high:2,low:3,start:4') - p.set_defaults(func=construct_ftl_bdev) + p.set_defaults(func=bdev_ftl_create) - def delete_ftl_bdev(args): - print_dict(rpc.bdev.delete_ftl_bdev(args.client, name=args.name)) + def bdev_ftl_delete(args): + print_dict(rpc.bdev.bdev_ftl_delete(args.client, name=args.name)) - p = subparsers.add_parser('delete_ftl_bdev', help='Delete FTL bdev') + p = subparsers.add_parser('bdev_ftl_delete', aliases=['delete_ftl_bdev'], + help='Delete FTL bdev') p.add_argument('-b', '--name', help="Name of the bdev", required=True) - p.set_defaults(func=delete_ftl_bdev) + p.set_defaults(func=bdev_ftl_delete) # vmd def enable_vmd(args): diff --git a/scripts/rpc/bdev.py b/scripts/rpc/bdev.py index 9c6ed46f8d..b272fa1880 100644 --- a/scripts/rpc/bdev.py +++ b/scripts/rpc/bdev.py @@ -671,7 +671,8 @@ def destruct_split_vbdev(client, base_bdev): return client.call('destruct_split_vbdev', params) -def construct_ftl_bdev(client, name, trtype, traddr, punits, **kwargs): +@deprecated_alias('construct_ftl_bdev') +def bdev_ftl_create(client, name, trtype, traddr, punits, **kwargs): """Construct FTL bdev Args: @@ -689,10 +690,11 @@ def construct_ftl_bdev(client, name, trtype, traddr, punits, **kwargs): if value is not None: params[key] = value - return client.call('construct_ftl_bdev', params) + return client.call('bdev_ftl_create', params) -def delete_ftl_bdev(client, name): +@deprecated_alias('delete_ftl_bdev') +def bdev_ftl_delete(client, name): """Delete FTL bdev Args: @@ -700,7 +702,7 @@ def delete_ftl_bdev(client, name): """ params = {'name': name} - return client.call('delete_ftl_bdev', params) + return client.call('bdev_ftl_delete', params) @deprecated_alias('get_bdevs') diff --git a/test/ftl/dirty_shutdown.sh b/test/ftl/dirty_shutdown.sh index 86cf2d3291..ac7ac2eb10 100755 --- a/test/ftl/dirty_shutdown.sh +++ b/test/ftl/dirty_shutdown.sh @@ -25,7 +25,7 @@ restore_kill() { rm -f $testdir/testfile.md5 rm -f $testdir/testfile2.md5 - $rpc_py delete_ftl_bdev -b nvme0 || true + $rpc_py bdev_ftl_delete -b nvme0 || true killprocess $svcpid || true rmmod nbd || true } @@ -45,7 +45,7 @@ if [ -n "$nv_cache" ]; then nvc_bdev=$(create_nv_cache_bdev nvc0 $device $nv_cache $pu_count) fi -ftl_construct_args="construct_ftl_bdev -b nvme0 -a $device -l $pu_start-$pu_end -o" +ftl_construct_args="bdev_ftl_create -b nvme0 -a $device -l $pu_start-$pu_end -o" [ -n "$nvc_bdev" ] && ftl_construct_args+=" -c $nvc_bdev" [ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" diff --git a/test/ftl/ftl.sh b/test/ftl/ftl.sh index 81345f3198..858cf56e31 100755 --- a/test/ftl/ftl.sh +++ b/test/ftl/ftl.sh @@ -80,7 +80,7 @@ if [ $SPDK_TEST_FTL_EXTENDED -eq 1 ]; then trap 'killprocess $svc_pid; exit 1' SIGINT SIGTERM EXIT waitforlisten $svc_pid - uuid=$($rpc_py construct_ftl_bdev -b nvme0 -a $device -l 0-3 | jq -r '.uuid') + uuid=$($rpc_py bdev_ftl_create -b nvme0 -a $device -l 0-3 | jq -r '.uuid') killprocess $svc_pid trap - SIGINT SIGTERM EXIT diff --git a/test/ftl/json.sh b/test/ftl/json.sh index 1400c49a2c..febc59e1cb 100755 --- a/test/ftl/json.sh +++ b/test/ftl/json.sh @@ -24,18 +24,18 @@ $rootdir/scripts/gen_ftl.sh -j -a $device -n nvme0 -l 0-1 | $rpc_py load_subsyst uuid=$($rpc_py bdev_get_bdevs | jq -r '.[0].uuid') -$rpc_py delete_ftl_bdev -b nvme0 +$rpc_py bdev_ftl_delete -b nvme0 # Restore bdev from json configuration $rootdir/scripts/gen_ftl.sh -j -a $device -n nvme0 -l 0-1 -u $uuid | $rpc_py load_subsystem_config # Create new bdev from json configuration $rootdir/scripts/gen_ftl.sh -j -a $device -n nvme1 -l 2-2 | $rpc_py load_subsystem_config # Create new bdev from RPC -$rpc_py construct_ftl_bdev -b nvme2 -a $device -l 3-3 +$rpc_py bdev_ftl_create -b nvme2 -a $device -l 3-3 -$rpc_py delete_ftl_bdev -b nvme2 -$rpc_py delete_ftl_bdev -b nvme0 -$rpc_py delete_ftl_bdev -b nvme1 +$rpc_py bdev_ftl_delete -b nvme2 +$rpc_py bdev_ftl_delete -b nvme0 +$rpc_py bdev_ftl_delete -b nvme1 # TODO: add negative test cases diff --git a/test/ftl/restore.sh b/test/ftl/restore.sh index 839d04cefd..7abba477e7 100755 --- a/test/ftl/restore.sh +++ b/test/ftl/restore.sh @@ -30,7 +30,7 @@ restore_kill() { rm -f $testdir/testfile2.md5 rm -f $testdir/config/ftl.json - $rpc_py delete_ftl_bdev -b nvme0 + $rpc_py bdev_ftl_delete -b nvme0 killprocess $svcpid rmmod nbd || true } @@ -45,7 +45,7 @@ if [ -n "$nv_cache" ]; then nvc_bdev=$(create_nv_cache_bdev nvc0 $device $nv_cache $(($pu_end - $pu_start + 1))) fi -ftl_construct_args="construct_ftl_bdev -b nvme0 -a $device -l ${pu_start}-${pu_end}" +ftl_construct_args="bdev_ftl_create -b nvme0 -a $device -l ${pu_start}-${pu_end}" [ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" [ -n "$nv_cache" ] && ftl_construct_args+=" -c $nvc_bdev"