1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) Intel Corporation. 3 * All rights reserved. 4 */ 5 6 #ifndef SPDK_VBDEV_ERROR_H 7 #define SPDK_VBDEV_ERROR_H 8 9 #include "spdk/stdinc.h" 10 #include "spdk/bdev.h" 11 12 enum vbdev_error_type { 13 VBDEV_IO_FAILURE = 1, 14 VBDEV_IO_PENDING, 15 }; 16 17 typedef void (*spdk_delete_error_complete)(void *cb_arg, int bdeverrno); 18 19 /** 20 * Create a vbdev on the base bdev to inject error into it. 21 * 22 * \param base_bdev_name Name of the base bdev. 23 * \return 0 on success or negative on failure. 24 */ 25 int vbdev_error_create(const char *base_bdev_name); 26 27 /** 28 * Delete vbdev used to inject errors. 29 * 30 * \param error_vbdev_name Name of the error vbdev. 31 * \param cb_fn Function to call after deletion. 32 * \param cb_arg Arguments to pass to cb_fn. 33 */ 34 void vbdev_error_delete(const char *error_vbdev_name, spdk_delete_error_complete cb_fn, 35 void *cb_arg); 36 37 struct vbdev_error_inject_opts { 38 uint32_t io_type; 39 uint32_t error_type; 40 uint32_t error_num; 41 }; 42 43 /** 44 * Inject error to the base bdev. Users can specify which IO type error is injected, 45 * what type of error is injected, and how many errors are injected. 46 * 47 * \param name Name of the base bdev into which error is injected. 48 * \param opts Options for error injection. 49 */ 50 int vbdev_error_inject_error(char *name, const struct vbdev_error_inject_opts *opts); 51 52 #endif /* SPDK_VBDEV_ERROR_H */ 53