rpc: add keep alive parameter in bdev nvme

Add keep alive timetout parameter in bdev_nvme_set_options.
NVMe bdev can set this value especially when we test with
bdevperf.

Fix github issue: #1690

Change-Id: I255c935671b74cdb615a8d393e7d7e84524f3c23
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5306
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: <dongx.yi@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jin Yu 2020-11-28 00:10:36 +08:00 committed by Tomasz Zawadzki
parent 7083e01b9f
commit 46a3485971
7 changed files with 18 additions and 2 deletions

View File

@ -32,6 +32,8 @@ be notified of any discovery log changes.
A new API `spdk_jsonrpc_send_bool_response` was added to allow sending response for A new API `spdk_jsonrpc_send_bool_response` was added to allow sending response for
writing json bool results into one function. writing json bool results into one function.
Update API `bdev_nvme_set_options` and add a keep_alive_timeout_ms parameter. Now you
can specify the keep_alive_timeout before creating NVMe bdev.
### rpc ### rpc

View File

@ -2171,6 +2171,7 @@ Name | Optional | Type | Description
-------------------------- | -------- | ----------- | ----------- -------------------------- | -------- | ----------- | -----------
action_on_timeout | Optional | string | Action to take on command time out: none, reset or abort action_on_timeout | Optional | string | Action to take on command time out: none, reset or abort
timeout_us | Optional | number | Timeout for each command, in microseconds. If 0, don't track timeouts timeout_us | Optional | number | Timeout for each command, in microseconds. If 0, don't track timeouts
keep_alive_timeout_ms | Optional | number | Keep alive timeout period in milliseconds, default is 10s
retry_count | Optional | number | The number of attempts per I/O before an I/O fails retry_count | Optional | number | The number of attempts per I/O before an I/O fails
arbitration_burst | Optional | number | The value is expressed as a power of two, a value of 111b indicates no limit arbitration_burst | Optional | number | The value is expressed as a power of two, a value of 111b indicates no limit
low_priority_weight | Optional | number | The maximum number of commands that the controller may launch at one time from a low priority queue low_priority_weight | Optional | number | The maximum number of commands that the controller may launch at one time from a low priority queue
@ -2196,6 +2197,7 @@ request:
"high_priority_weight": 8, "high_priority_weight": 8,
"nvme_adminq_poll_period_us": 2000, "nvme_adminq_poll_period_us": 2000,
"timeout_us": 10000000, "timeout_us": 10000000,
"keep_alive_timeout_ms": 600000,
"action_on_timeout": "reset", "action_on_timeout": "reset",
"io_queue_requests" : 2048, "io_queue_requests" : 2048,
"delay_cmd_submit": true "delay_cmd_submit": true

View File

@ -51,6 +51,7 @@
#include "spdk/log.h" #include "spdk/log.h"
#define SPDK_BDEV_NVME_DEFAULT_DELAY_CMD_SUBMIT true #define SPDK_BDEV_NVME_DEFAULT_DELAY_CMD_SUBMIT true
#define SPDK_BDEV_NVME_DEFAULT_KEEP_ALIVE_TIMEOUT_IN_MS (10000)
static int bdev_nvme_config_json(struct spdk_json_write_ctx *w); static int bdev_nvme_config_json(struct spdk_json_write_ctx *w);
@ -109,6 +110,7 @@ static TAILQ_HEAD(, nvme_probe_skip_entry) g_skipped_nvme_ctrlrs = TAILQ_HEAD_IN
static struct spdk_bdev_nvme_opts g_opts = { static struct spdk_bdev_nvme_opts g_opts = {
.action_on_timeout = SPDK_BDEV_NVME_TIMEOUT_ACTION_NONE, .action_on_timeout = SPDK_BDEV_NVME_TIMEOUT_ACTION_NONE,
.timeout_us = 0, .timeout_us = 0,
.keep_alive_timeout_ms = SPDK_BDEV_NVME_DEFAULT_KEEP_ALIVE_TIMEOUT_IN_MS,
.retry_count = 4, .retry_count = 4,
.arbitration_burst = 0, .arbitration_burst = 0,
.low_priority_weight = 0, .low_priority_weight = 0,
@ -1957,6 +1959,7 @@ bdev_nvme_create(struct spdk_nvme_transport_id *trid,
spdk_nvme_ctrlr_get_default_ctrlr_opts(&ctx->opts, sizeof(ctx->opts)); spdk_nvme_ctrlr_get_default_ctrlr_opts(&ctx->opts, sizeof(ctx->opts));
ctx->opts.transport_retry_count = g_opts.retry_count; ctx->opts.transport_retry_count = g_opts.retry_count;
ctx->opts.keep_alive_timeout_ms = g_opts.keep_alive_timeout_ms;
if (hostnqn) { if (hostnqn) {
snprintf(ctx->opts.hostnqn, sizeof(ctx->opts.hostnqn), "%s", hostnqn); snprintf(ctx->opts.hostnqn, sizeof(ctx->opts.hostnqn), "%s", hostnqn);

View File

@ -51,6 +51,7 @@ enum spdk_bdev_timeout_action {
struct spdk_bdev_nvme_opts { struct spdk_bdev_nvme_opts {
enum spdk_bdev_timeout_action action_on_timeout; enum spdk_bdev_timeout_action action_on_timeout;
uint64_t timeout_us; uint64_t timeout_us;
uint32_t keep_alive_timeout_ms;
uint32_t retry_count; uint32_t retry_count;
uint32_t arbitration_burst; uint32_t arbitration_burst;
uint32_t low_priority_weight; uint32_t low_priority_weight;

View File

@ -75,6 +75,7 @@ rpc_decode_action_on_timeout(const struct spdk_json_val *val, void *out)
static const struct spdk_json_object_decoder rpc_bdev_nvme_options_decoders[] = { static const struct spdk_json_object_decoder rpc_bdev_nvme_options_decoders[] = {
{"action_on_timeout", offsetof(struct spdk_bdev_nvme_opts, action_on_timeout), rpc_decode_action_on_timeout, true}, {"action_on_timeout", offsetof(struct spdk_bdev_nvme_opts, action_on_timeout), rpc_decode_action_on_timeout, true},
{"timeout_us", offsetof(struct spdk_bdev_nvme_opts, timeout_us), spdk_json_decode_uint64, true}, {"timeout_us", offsetof(struct spdk_bdev_nvme_opts, timeout_us), spdk_json_decode_uint64, true},
{"keep_alive_timeout_ms", offsetof(struct spdk_bdev_nvme_opts, keep_alive_timeout_ms), spdk_json_decode_uint32, true},
{"retry_count", offsetof(struct spdk_bdev_nvme_opts, retry_count), spdk_json_decode_uint32, true}, {"retry_count", offsetof(struct spdk_bdev_nvme_opts, retry_count), spdk_json_decode_uint32, true},
{"arbitration_burst", offsetof(struct spdk_bdev_nvme_opts, arbitration_burst), spdk_json_decode_uint32, true}, {"arbitration_burst", offsetof(struct spdk_bdev_nvme_opts, arbitration_burst), spdk_json_decode_uint32, true},
{"low_priority_weight", offsetof(struct spdk_bdev_nvme_opts, low_priority_weight), spdk_json_decode_uint32, true}, {"low_priority_weight", offsetof(struct spdk_bdev_nvme_opts, low_priority_weight), spdk_json_decode_uint32, true},

View File

@ -415,6 +415,7 @@ if __name__ == "__main__":
rpc.bdev.bdev_nvme_set_options(args.client, rpc.bdev.bdev_nvme_set_options(args.client,
action_on_timeout=args.action_on_timeout, action_on_timeout=args.action_on_timeout,
timeout_us=args.timeout_us, timeout_us=args.timeout_us,
keep_alive_timeout_ms=args.keep_alive_timeout_ms,
retry_count=args.retry_count, retry_count=args.retry_count,
arbitration_burst=args.arbitration_burst, arbitration_burst=args.arbitration_burst,
low_priority_weight=args.low_priority_weight, low_priority_weight=args.low_priority_weight,
@ -431,6 +432,8 @@ if __name__ == "__main__":
help="Action to take on command time out. Valid valies are: none, reset, abort") help="Action to take on command time out. Valid valies are: none, reset, abort")
p.add_argument('-t', '--timeout-us', p.add_argument('-t', '--timeout-us',
help="Timeout for each command, in microseconds. If 0, don't track timeouts.", type=int) help="Timeout for each command, in microseconds. If 0, don't track timeouts.", type=int)
p.add_argument('-k', '--keep-alive-timeout-ms',
help="Keep alive timeout period in millisecond. If 0, disable keep-alive.", type=int)
p.add_argument('-n', '--retry-count', p.add_argument('-n', '--retry-count',
help='the number of attempts per I/O when an I/O fails', type=int) help='the number of attempts per I/O when an I/O fails', type=int)
p.add_argument('--arbitration-burst', p.add_argument('--arbitration-burst',

View File

@ -381,8 +381,8 @@ def bdev_uring_delete(client, name):
@deprecated_alias('set_bdev_nvme_options') @deprecated_alias('set_bdev_nvme_options')
def bdev_nvme_set_options(client, action_on_timeout=None, timeout_us=None, retry_count=None, def bdev_nvme_set_options(client, action_on_timeout=None, timeout_us=None, keep_alive_timeout_ms=None,
arbitration_burst=None, low_priority_weight=None, retry_count=None, arbitration_burst=None, low_priority_weight=None,
medium_priority_weight=None, high_priority_weight=None, medium_priority_weight=None, high_priority_weight=None,
nvme_adminq_poll_period_us=None, nvme_ioq_poll_period_us=None, io_queue_requests=None, nvme_adminq_poll_period_us=None, nvme_ioq_poll_period_us=None, io_queue_requests=None,
delay_cmd_submit=None): delay_cmd_submit=None):
@ -391,6 +391,7 @@ def bdev_nvme_set_options(client, action_on_timeout=None, timeout_us=None, retry
Args: Args:
action_on_timeout: action to take on command time out. Valid values are: none, reset, abort (optional) action_on_timeout: action to take on command time out. Valid values are: none, reset, abort (optional)
timeout_us: Timeout for each command, in microseconds. If 0, don't track timeouts (optional) timeout_us: Timeout for each command, in microseconds. If 0, don't track timeouts (optional)
keep_alive_timeout_ms: Keep alive timeout period in millisecond, default is 10s (optional)
retry_count: The number of attempts per I/O when an I/O fails (optional) retry_count: The number of attempts per I/O when an I/O fails (optional)
arbitration_burst: The value is expressed as a power of two (optional) arbitration_burst: The value is expressed as a power of two (optional)
low_prioity_weight: The number of commands that may be executed from the low priority queue at one time (optional) low_prioity_weight: The number of commands that may be executed from the low priority queue at one time (optional)
@ -409,6 +410,9 @@ def bdev_nvme_set_options(client, action_on_timeout=None, timeout_us=None, retry
if timeout_us is not None: if timeout_us is not None:
params['timeout_us'] = timeout_us params['timeout_us'] = timeout_us
if keep_alive_timeout_ms is not None:
params['keep_alive_timeout_ms'] = keep_alive_timeout_ms
if retry_count is not None: if retry_count is not None:
params['retry_count'] = retry_count params['retry_count'] = retry_count