Commit 4dacace1 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

bdev/error: add queue_depth option for error injection



Change-Id: If0805475eea4b3d160ee4a39d617683df9375971
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19316


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 408a2155
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5514,6 +5514,7 @@ name | Required | string | Name of the error injection b
io_type                 | Required | string      | io type 'clear' 'read' 'write' 'unmap' 'flush' 'all'
error_type              | Required | string      | error type 'failure' 'pending' 'corrupt_data' 'nomem'
num                     | Optional | int         | the number of commands you want to fail.(default:1)
queue_depth             | Optional | int         | the queue depth at which to trigger the error
corrupt_offset          | Optional | int         | the offset in bytes to xor with corrupt_value
corrupt_value           | Optional | int         | the value for xor (1-255, 0 is invalid)

+14 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ static TAILQ_HEAD(, spdk_vbdev_error_config) g_error_config
struct vbdev_error_info {
	uint32_t			error_type;
	uint32_t			error_num;
	uint64_t			error_qd;
	uint64_t			corrupt_offset;
	uint8_t				corrupt_value;
};
@@ -44,6 +45,7 @@ struct error_disk {

struct error_channel {
	struct spdk_bdev_part_channel	part_ch;
	uint64_t			io_inflight;
};

static pthread_mutex_t g_vbdev_error_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -120,6 +122,7 @@ vbdev_error_inject_error(char *name, const struct vbdev_error_inject_opts *opts)
		for (i = 0; i < SPDK_COUNTOF(error_disk->error_vector); i++) {
			error_disk->error_vector[i].error_type = opts->error_type;
			error_disk->error_vector[i].error_num = opts->error_num;
			error_disk->error_vector[i].error_qd = opts->error_qd;
			error_disk->error_vector[i].corrupt_offset = opts->corrupt_offset;
			error_disk->error_vector[i].corrupt_value = opts->corrupt_value;
		}
@@ -130,6 +133,7 @@ vbdev_error_inject_error(char *name, const struct vbdev_error_inject_opts *opts)
	} else {
		error_disk->error_vector[opts->io_type].error_type = opts->error_type;
		error_disk->error_vector[opts->io_type].error_num = opts->error_num;
		error_disk->error_vector[opts->io_type].error_qd = opts->error_qd;
		error_disk->error_vector[opts->io_type].corrupt_offset = opts->corrupt_offset;
		error_disk->error_vector[opts->io_type].corrupt_value = opts->corrupt_value;
	}
@@ -199,8 +203,12 @@ vbdev_error_complete_request(struct spdk_bdev_io *bdev_io, bool success, void *c
{
	int status = success ? SPDK_BDEV_IO_STATUS_SUCCESS : SPDK_BDEV_IO_STATUS_FAILED;
	struct error_disk *error_disk = bdev_io->bdev->ctxt;
	struct error_channel *ch = spdk_io_channel_get_ctx(spdk_bdev_io_get_io_channel(bdev_io));
	uint32_t error_type;

	assert(ch->io_inflight > 0);
	ch->io_inflight--;

	if (success && bdev_io->type == SPDK_BDEV_IO_TYPE_READ) {
		error_type = vbdev_error_get_error_type(error_disk, bdev_io->type);
		if (error_type == VBDEV_IO_CORRUPT_DATA) {
@@ -229,6 +237,11 @@ vbdev_error_submit_request(struct spdk_io_channel *_ch, struct spdk_bdev_io *bde
	}

	error_type = vbdev_error_get_error_type(error_disk, bdev_io->type);

	if (ch->io_inflight < error_disk->error_vector[bdev_io->type].error_qd) {
		error_type = 0;
	}

	switch (error_type) {
	case VBDEV_IO_FAILURE:
		error_disk->error_vector[bdev_io->type].error_num--;
@@ -259,6 +272,7 @@ vbdev_error_submit_request(struct spdk_io_channel *_ch, struct spdk_bdev_io *bde
			SPDK_ERRLOG("bdev_error: submit request failed, rc=%d\n", rc);
			spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
		}
		ch->io_inflight++;
		break;
	default:
		assert(false);
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ struct vbdev_error_inject_opts {
	uint32_t io_type;
	uint32_t error_type;
	uint32_t error_num;
	uint64_t error_qd;
	uint64_t corrupt_offset;
	uint8_t corrupt_value;
};
+1 −0
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ static const struct spdk_json_object_decoder rpc_error_information_decoders[] =
	{"io_type", offsetof(struct rpc_error_information, opts.io_type), rpc_error_bdev_decode_io_type},
	{"error_type", offsetof(struct rpc_error_information, opts.error_type), rpc_error_bdev_decode_error_type},
	{"num", offsetof(struct rpc_error_information, opts.error_num), spdk_json_decode_uint32, true},
	{"queue_depth", offsetof(struct rpc_error_information, opts.error_qd), spdk_json_decode_uint64, true},
	{"corrupt_offset", offsetof(struct rpc_error_information, opts.corrupt_offset), spdk_json_decode_uint64, true},
	{"corrupt_value", offsetof(struct rpc_error_information, opts.corrupt_value), spdk_json_decode_uint8, true},
};
+4 −1
Original line number Diff line number Diff line
@@ -1658,7 +1658,7 @@ def bdev_get_histogram(client, name):


def bdev_error_inject_error(client, name, io_type, error_type, num,
                            corrupt_offset, corrupt_value):
                            queue_depth, corrupt_offset, corrupt_value):
    """Inject an error via an error bdev.

    Args:
@@ -1666,6 +1666,7 @@ def bdev_error_inject_error(client, name, io_type, error_type, num,
        io_type: one of "clear", "read", "write", "unmap", "flush", or "all"
        error_type: one of "failure", "pending", "corrupt_data" or "nomem"
        num: number of commands to fail
        queue_depth: the queue depth at which to trigger the error
        corrupt_offset: offset in bytes to xor with corrupt_value
        corrupt_value: value for xor (1-255, 0 is invalid)
    """
@@ -1677,6 +1678,8 @@ def bdev_error_inject_error(client, name, io_type, error_type, num,

    if num:
        params['num'] = num
    if queue_depth:
        params['queue_depth'] = queue_depth
    if corrupt_offset:
        params['corrupt_offset'] = corrupt_offset
    if corrupt_value:
Loading