1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (C) 2017 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 #include "spdk/uuid.h" 12 13 enum vbdev_error_type { 14 VBDEV_IO_NO_ERROR = 0, 15 VBDEV_IO_FAILURE, 16 VBDEV_IO_PENDING, 17 VBDEV_IO_CORRUPT_DATA, 18 VBDEV_IO_NOMEM, 19 }; 20 21 typedef void (*spdk_delete_error_complete)(void *cb_arg, int bdeverrno); 22 23 /** 24 * Create a vbdev on the base bdev to inject error into it. 25 * 26 * \param base_bdev_name Name of the base bdev. 27 * \param uuid Optional UUID to assign to the bdev. 28 * \return 0 on success or negative on failure. 29 */ 30 int vbdev_error_create(const char *base_bdev_name, const struct spdk_uuid *uuid); 31 32 /** 33 * Delete vbdev used to inject errors. 34 * 35 * \param error_vbdev_name Name of the error vbdev. 36 * \param cb_fn Function to call after deletion. 37 * \param cb_arg Arguments to pass to cb_fn. 38 */ 39 void vbdev_error_delete(const char *error_vbdev_name, spdk_delete_error_complete cb_fn, 40 void *cb_arg); 41 42 struct vbdev_error_inject_opts { 43 uint32_t io_type; 44 uint32_t error_type; 45 uint32_t error_num; 46 uint64_t error_qd; 47 uint64_t corrupt_offset; 48 uint8_t corrupt_value; 49 }; 50 51 /** 52 * Inject error to the base bdev. Users can specify which IO type error is injected, 53 * what type of error is injected, and how many errors are injected. 54 * 55 * \param name Name of the base bdev into which error is injected. 56 * \param opts Options for error injection. 57 */ 58 int vbdev_error_inject_error(char *name, const struct vbdev_error_inject_opts *opts); 59 60 #endif /* SPDK_VBDEV_ERROR_H */ 61