diff --git a/CHANGELOG.md b/CHANGELOG.md index 74e762751..0a19bddc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ API `spdk_nvme_trtype_is_fabrics` was added to return existing transport type is fabric or not. +### bdev_nvme + +Added `num_io_queues` to `bdev_nvme_attach_controller` RPC to allow specifying amount +of requested IO queues. + ### bdev The parameter `retry_count` of the RPC `bdev_nvme_set_options` was deprecated and will be diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 8d203d0ce..26088886e 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -2898,6 +2898,7 @@ hdgst | Optional | bool | Enable TCP header digest ddgst | Optional | bool | Enable TCP data digest fabrics_connect_timeout_us | Optional | bool | Timeout for fabrics connect (in microseconds) multipath | Optional | string | Multipathing behavior: disable, failover, multipath. Default is failover. +num_io_queues | Optional | uint32_t | The number of IO queues to request during initialization. Range: (0, UINT16_MAX + 1], Default is 1024. #### Example diff --git a/module/bdev/nvme/bdev_nvme_rpc.c b/module/bdev/nvme/bdev_nvme_rpc.c index 7913b7493..08f05ebca 100644 --- a/module/bdev/nvme/bdev_nvme_rpc.c +++ b/module/bdev/nvme/bdev_nvme_rpc.c @@ -221,6 +221,7 @@ static const struct spdk_json_object_decoder rpc_bdev_nvme_attach_controller_dec {"ddgst", offsetof(struct rpc_bdev_nvme_attach_controller, opts.data_digest), spdk_json_decode_bool, true}, {"fabrics_connect_timeout_us", offsetof(struct rpc_bdev_nvme_attach_controller, opts.fabrics_connect_timeout_us), spdk_json_decode_uint64, true}, {"multipath", offsetof(struct rpc_bdev_nvme_attach_controller, multipath), spdk_json_decode_string, true}, + {"num_io_queues", offsetof(struct rpc_bdev_nvme_attach_controller, opts.num_io_queues), spdk_json_decode_uint32, true}, }; #define NVME_MAX_BDEVS_PER_RPC 128 @@ -479,6 +480,13 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request, multipath = true; } + if (ctx->req.opts.num_io_queues == 0 || ctx->req.opts.num_io_queues > UINT16_MAX + 1) { + spdk_jsonrpc_send_error_response_fmt(request, -EINVAL, + "num_io_queues out of bounds, min: %u max: %u\n", + 1, UINT16_MAX + 1); + goto cleanup; + } + ctx->request = request; ctx->count = NVME_MAX_BDEVS_PER_RPC; rc = bdev_nvme_create(&trid, ctx->req.name, ctx->names, ctx->count, prchk_flags, diff --git a/scripts/rpc.py b/scripts/rpc.py index 51cf79f84..5003d6644 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -537,7 +537,8 @@ if __name__ == "__main__": hdgst=args.hdgst, ddgst=args.ddgst, fabrics_timeout=args.fabrics_timeout, - multipath=args.multipath)) + multipath=args.multipath, + num_io_queues=args.num_io_queues)) p = subparsers.add_parser('bdev_nvme_attach_controller', aliases=['construct_nvme_bdev'], help='Add bdevs with nvme backend') @@ -568,6 +569,7 @@ if __name__ == "__main__": help='Enable TCP data digest.', action='store_true') p.add_argument('--fabrics-timeout', type=int, help='Fabrics connect timeout in microseconds') p.add_argument('-x', '--multipath', help='Set multipath behavior (disable, failover, multipath)') + p.add_argument('--num-io-queues', type=int, help='Set the number of IO queues to request during initialization.') p.set_defaults(func=bdev_nvme_attach_controller) def bdev_nvme_get_controllers(args): diff --git a/scripts/rpc/bdev.py b/scripts/rpc/bdev.py index a95dc6c84..786958954 100644 --- a/scripts/rpc/bdev.py +++ b/scripts/rpc/bdev.py @@ -523,7 +523,7 @@ def bdev_nvme_set_hotplug(client, enable, period_us=None): def bdev_nvme_attach_controller(client, name, trtype, traddr, adrfam=None, trsvcid=None, priority=None, subnqn=None, hostnqn=None, hostaddr=None, hostsvcid=None, prchk_reftag=None, prchk_guard=None, - hdgst=None, ddgst=None, fabrics_timeout=None, multipath=None): + hdgst=None, ddgst=None, fabrics_timeout=None, multipath=None, num_io_queues=None): """Construct block device for each NVMe namespace in the attached controller. Args: @@ -543,6 +543,7 @@ def bdev_nvme_attach_controller(client, name, trtype, traddr, adrfam=None, trsvc ddgst: Enable TCP data digest (optional) fabrics_timeout: Fabrics connect timeout in us (optional) multipath: The behavior when multiple paths are created ("disable", "failover", or "multipath"; failover if not specified) + num_io_queues: The number of IO queues to request during initialization. (optional) Returns: Names of created block devices. @@ -590,6 +591,9 @@ def bdev_nvme_attach_controller(client, name, trtype, traddr, adrfam=None, trsvc if multipath: params['multipath'] = multipath + if num_io_queues: + params['num_io_queues'] = num_io_queues + return client.call('bdev_nvme_attach_controller', params)