1488570ebSJim Harris /* SPDX-License-Identifier: BSD-3-Clause 2a6dbe372Spaul luse * Copyright (C) 2017 Intel Corporation. 307fe6a43SSeth Howell * All rights reserved. 407fe6a43SSeth Howell */ 507fe6a43SSeth Howell 607fe6a43SSeth Howell #ifndef SPDK_VBDEV_ERROR_H 707fe6a43SSeth Howell #define SPDK_VBDEV_ERROR_H 807fe6a43SSeth Howell 907fe6a43SSeth Howell #include "spdk/stdinc.h" 1007fe6a43SSeth Howell #include "spdk/bdev.h" 1191ea8102SKrzysztof Karas #include "spdk/uuid.h" 1207fe6a43SSeth Howell 1307fe6a43SSeth Howell enum vbdev_error_type { 14*e55c9a81SNathan Claudel VBDEV_IO_NO_ERROR = 0, 15*e55c9a81SNathan Claudel VBDEV_IO_FAILURE, 1607fe6a43SSeth Howell VBDEV_IO_PENDING, 173d2a3ee4SShuhei Matsumoto VBDEV_IO_CORRUPT_DATA, 18408a2155SArtur Paszkiewicz VBDEV_IO_NOMEM, 1907fe6a43SSeth Howell }; 2007fe6a43SSeth Howell 2107fe6a43SSeth Howell typedef void (*spdk_delete_error_complete)(void *cb_arg, int bdeverrno); 2207fe6a43SSeth Howell 2307fe6a43SSeth Howell /** 2407fe6a43SSeth Howell * Create a vbdev on the base bdev to inject error into it. 2507fe6a43SSeth Howell * 2607fe6a43SSeth Howell * \param base_bdev_name Name of the base bdev. 2791ea8102SKrzysztof Karas * \param uuid Optional UUID to assign to the bdev. 2807fe6a43SSeth Howell * \return 0 on success or negative on failure. 2907fe6a43SSeth Howell */ 3091ea8102SKrzysztof Karas int vbdev_error_create(const char *base_bdev_name, const struct spdk_uuid *uuid); 3107fe6a43SSeth Howell 3207fe6a43SSeth Howell /** 3307fe6a43SSeth Howell * Delete vbdev used to inject errors. 3407fe6a43SSeth Howell * 354573e4ccSShuhei Matsumoto * \param error_vbdev_name Name of the error vbdev. 3607fe6a43SSeth Howell * \param cb_fn Function to call after deletion. 3707fe6a43SSeth Howell * \param cb_arg Arguments to pass to cb_fn. 3807fe6a43SSeth Howell */ 394573e4ccSShuhei Matsumoto void vbdev_error_delete(const char *error_vbdev_name, spdk_delete_error_complete cb_fn, 4007fe6a43SSeth Howell void *cb_arg); 4107fe6a43SSeth Howell 42ffee98ddSShuhei Matsumoto struct vbdev_error_inject_opts { 43ffee98ddSShuhei Matsumoto uint32_t io_type; 44ffee98ddSShuhei Matsumoto uint32_t error_type; 45ffee98ddSShuhei Matsumoto uint32_t error_num; 464dacace1SArtur Paszkiewicz uint64_t error_qd; 473d2a3ee4SShuhei Matsumoto uint64_t corrupt_offset; 483d2a3ee4SShuhei Matsumoto uint8_t corrupt_value; 49ffee98ddSShuhei Matsumoto }; 50ffee98ddSShuhei Matsumoto 5107fe6a43SSeth Howell /** 5207fe6a43SSeth Howell * Inject error to the base bdev. Users can specify which IO type error is injected, 5307fe6a43SSeth Howell * what type of error is injected, and how many errors are injected. 5407fe6a43SSeth Howell * 5507fe6a43SSeth Howell * \param name Name of the base bdev into which error is injected. 56ffee98ddSShuhei Matsumoto * \param opts Options for error injection. 5707fe6a43SSeth Howell */ 58ffee98ddSShuhei Matsumoto int vbdev_error_inject_error(char *name, const struct vbdev_error_inject_opts *opts); 5907fe6a43SSeth Howell 6007fe6a43SSeth Howell #endif /* SPDK_VBDEV_ERROR_H */ 61