2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2022-11-01 20:26:26 +00:00
|
|
|
* Copyright (C) 2017 Intel Corporation.
|
2017-03-17 06:10:32 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2017-07-13 04:08:53 +00:00
|
|
|
#ifndef SPDK_VBDEV_ERROR_H
|
|
|
|
#define SPDK_VBDEV_ERROR_H
|
2017-03-17 06:10:32 +00:00
|
|
|
|
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
#include "spdk/bdev.h"
|
2023-03-06 14:25:36 +00:00
|
|
|
#include "spdk/uuid.h"
|
2017-03-17 06:10:32 +00:00
|
|
|
|
2017-06-05 08:04:04 +00:00
|
|
|
enum vbdev_error_type {
|
|
|
|
VBDEV_IO_FAILURE = 1,
|
|
|
|
VBDEV_IO_PENDING,
|
2022-10-28 02:01:10 +00:00
|
|
|
VBDEV_IO_CORRUPT_DATA,
|
2017-06-05 08:04:04 +00:00
|
|
|
};
|
|
|
|
|
2018-06-15 14:06:38 +00:00
|
|
|
typedef void (*spdk_delete_error_complete)(void *cb_arg, int bdeverrno);
|
|
|
|
|
2018-03-29 23:11:53 +00:00
|
|
|
/**
|
|
|
|
* Create a vbdev on the base bdev to inject error into it.
|
|
|
|
*
|
|
|
|
* \param base_bdev_name Name of the base bdev.
|
2023-03-06 14:25:36 +00:00
|
|
|
* \param uuid Optional UUID to assign to the bdev.
|
2018-03-29 23:11:53 +00:00
|
|
|
* \return 0 on success or negative on failure.
|
|
|
|
*/
|
2023-03-06 14:25:36 +00:00
|
|
|
int vbdev_error_create(const char *base_bdev_name, const struct spdk_uuid *uuid);
|
2018-03-29 23:11:53 +00:00
|
|
|
|
2018-06-15 14:06:38 +00:00
|
|
|
/**
|
|
|
|
* Delete vbdev used to inject errors.
|
|
|
|
*
|
2022-03-29 05:55:53 +00:00
|
|
|
* \param error_vbdev_name Name of the error vbdev.
|
2018-06-15 14:06:38 +00:00
|
|
|
* \param cb_fn Function to call after deletion.
|
|
|
|
* \param cb_arg Arguments to pass to cb_fn.
|
|
|
|
*/
|
2022-03-29 05:55:53 +00:00
|
|
|
void vbdev_error_delete(const char *error_vbdev_name, spdk_delete_error_complete cb_fn,
|
2020-05-10 07:16:18 +00:00
|
|
|
void *cb_arg);
|
2018-06-15 14:06:38 +00:00
|
|
|
|
2022-10-17 18:35:46 +00:00
|
|
|
struct vbdev_error_inject_opts {
|
|
|
|
uint32_t io_type;
|
|
|
|
uint32_t error_type;
|
|
|
|
uint32_t error_num;
|
2022-10-28 02:01:10 +00:00
|
|
|
uint64_t corrupt_offset;
|
|
|
|
uint8_t corrupt_value;
|
2022-10-17 18:35:46 +00:00
|
|
|
};
|
|
|
|
|
2018-03-29 23:11:53 +00:00
|
|
|
/**
|
|
|
|
* Inject error to the base bdev. Users can specify which IO type error is injected,
|
|
|
|
* what type of error is injected, and how many errors are injected.
|
|
|
|
*
|
|
|
|
* \param name Name of the base bdev into which error is injected.
|
2022-10-17 18:35:46 +00:00
|
|
|
* \param opts Options for error injection.
|
2018-03-29 23:11:53 +00:00
|
|
|
*/
|
2022-10-17 18:35:46 +00:00
|
|
|
int vbdev_error_inject_error(char *name, const struct vbdev_error_inject_opts *opts);
|
2017-03-17 06:10:32 +00:00
|
|
|
|
2018-10-29 02:45:42 +00:00
|
|
|
#endif /* SPDK_VBDEV_ERROR_H */
|