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

accel/error: add an option to inject failures



In this mode, the error module will complete the tasks with an status
defined by the user simulating an error during operation execution.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent dce597cb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2047,8 +2047,9 @@ actually injected, the error module must be assigned to that operation via `acce
Name                    | Optional | Type        | Description
----------------------- |----------| ----------- | -----------------
opcode                  | Required | string      | Operation to inject errors.
type                    | Required | string      | Type of errors to inject ("corrupt": corrupt the data, "disable": disable error injection).
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).
errcode                 | Optional | number      | Error code to inject (only relevant for type=failure).

#### Example

+4 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ accel_error_task_complete_cb(void *arg, int status)
		case ACCEL_ERROR_INJECT_CORRUPT:
			accel_error_corrupt_task(task);
			break;
		case ACCEL_ERROR_INJECT_FAILURE:
			status = info->opts.errcode;
			break;
		default:
			break;
		}
@@ -213,6 +216,7 @@ accel_error_get_type_name(enum accel_error_inject_type type)
	const char *typenames[] = {
		[ACCEL_ERROR_INJECT_DISABLE] = "disable",
		[ACCEL_ERROR_INJECT_CORRUPT] = "corrupt",
		[ACCEL_ERROR_INJECT_FAILURE] = "failure",
		[ACCEL_ERROR_INJECT_MAX] = NULL
	};

+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
enum accel_error_inject_type {
	ACCEL_ERROR_INJECT_DISABLE,
	ACCEL_ERROR_INJECT_CORRUPT,
	ACCEL_ERROR_INJECT_FAILURE,
	ACCEL_ERROR_INJECT_MAX,
};

@@ -17,6 +18,7 @@ struct accel_error_inject_opts {
	enum spdk_accel_opcode		opcode;
	enum accel_error_inject_type	type;
	uint64_t			count;
	int				errcode;
};

int accel_error_inject_error(struct accel_error_inject_opts *opts);
+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},
	{"errcode", offsetof(struct accel_error_inject_opts, errcode), spdk_json_decode_int32, true},
};

static void
+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):
def accel_error_inject_error(client, opcode, type, count=None, errcode=None):
    """Inject an error to processing accel operation"""
    params = {}
    if count is not None:
        params['count'] = count
    if errcode is not None:
        params['errcode'] = errcode

    return client.call('accel_error_inject_error',
                       {'opcode': opcode, 'type': type, **params})
Loading