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