Commit 760cb023 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

accel/error: add an option to specify injection interval



With this option, an error is only injected after executing a number of
operations specified by its value.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I02c3f7d8685222d43d34fa59005327ef5467c8ce
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20442


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent bb019612
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2049,6 +2049,7 @@ Name | Optional | Type | Description
opcode                  | Required | string      | Operation to inject errors.
type                    | Required | string      | Type of errors to inject ("corrupt": corrupt the data, "failure": fail the operation, "disable": disable error injection).
count                   | Optional | number      | Numbers of errors to inject on each IO channel (`UINT64_MAX` by default).
interval                | Optional | number      | Interval between injections.
errcode                 | Optional | number      | Error code to inject (only relevant for type=failure).

#### Example
@@ -2061,7 +2062,8 @@ Example request:
  "params": {
    "opcode": "crc32c",
    "type": "corrupt",
    "count": 10000
    "count": 10000,
    "interval": 8
  }
}
~~~
+21 −13
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ struct accel_error_inject_info {
	struct accel_error_inject_opts	opts;
	/* Number of errors already injected on this channel */
	uint64_t			count;
	/* Number of operations executed since last error injection */
	uint64_t			interval;
};

struct accel_error_channel {
@@ -58,7 +60,11 @@ accel_error_task_complete_cb(void *arg, int status)
	spdk_accel_completion_cb cb_fn = errtask->cb_fn;
	void *cb_arg = errtask->cb_arg;

	info->interval++;
	if (info->interval >= info->opts.interval) {
		info->interval = 0;
		info->count++;

		if (info->count <= info->opts.count) {
			switch (info->opts.type) {
			case ACCEL_ERROR_INJECT_CORRUPT:
@@ -73,6 +79,7 @@ accel_error_task_complete_cb(void *arg, int status)
		} else {
			info->opts.type = ACCEL_ERROR_INJECT_DISABLE;
		}
	}

	cb_fn(cb_arg, status);
}
@@ -244,6 +251,7 @@ accel_error_write_config_json(struct spdk_json_write_ctx *w)
		spdk_json_write_named_string(w, "opcode", spdk_accel_get_opcode_name(opcode));
		spdk_json_write_named_string(w, "type", accel_error_get_type_name(opts->type));
		spdk_json_write_named_uint64(w, "count", opts->count);
		spdk_json_write_named_uint64(w, "interval", opts->interval);
		spdk_json_write_object_end(w);
		spdk_json_write_object_end(w);
	}
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ struct accel_error_inject_opts {
	enum spdk_accel_opcode		opcode;
	enum accel_error_inject_type	type;
	uint64_t			count;
	uint64_t			interval;
	int				errcode;
};

+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ static const struct spdk_json_object_decoder rpc_accel_error_inject_error_decode
	{"opcode", offsetof(struct accel_error_inject_opts, opcode), rpc_accel_error_decode_opcode},
	{"type", offsetof(struct accel_error_inject_opts, type), rpc_accel_error_decode_type},
	{"count", offsetof(struct accel_error_inject_opts, count), spdk_json_decode_uint64, true},
	{"interval", offsetof(struct accel_error_inject_opts, interval), spdk_json_decode_uint64, true},
	{"errcode", offsetof(struct accel_error_inject_opts, errcode), spdk_json_decode_int32, true},
};

+3 −1
Original line number Diff line number Diff line
@@ -118,11 +118,13 @@ def accel_get_stats(client):
    return client.call('accel_get_stats')


def accel_error_inject_error(client, opcode, type, count=None, errcode=None):
def accel_error_inject_error(client, opcode, type, count=None, interval=None, errcode=None):
    """Inject an error to processing accel operation"""
    params = {}
    if count is not None:
        params['count'] = count
    if interval is not None:
        params['interval'] = interval
    if errcode is not None:
        params['errcode'] = errcode

Loading