bdev/error: Use bdev_open_ext() to inject error instead of bdev_get_by_name()
Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: Iba05ed816c2ecb4346dd6a77e9579c6af6d2b06f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12071 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
d77d3179f0
commit
cf1e19c707
@ -94,22 +94,32 @@ static struct spdk_bdev_module error_if = {
|
|||||||
|
|
||||||
SPDK_BDEV_MODULE_REGISTER(error, &error_if)
|
SPDK_BDEV_MODULE_REGISTER(error, &error_if)
|
||||||
|
|
||||||
|
static void
|
||||||
|
dummy_bdev_event_cb(enum spdk_bdev_event_type type, struct spdk_bdev *bdev, void *ctx)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vbdev_error_inject_error(char *name, uint32_t io_type, uint32_t error_type, uint32_t error_num)
|
vbdev_error_inject_error(char *name, uint32_t io_type, uint32_t error_type, uint32_t error_num)
|
||||||
{
|
{
|
||||||
|
struct spdk_bdev_desc *desc;
|
||||||
struct spdk_bdev *bdev;
|
struct spdk_bdev *bdev;
|
||||||
struct spdk_bdev_part *part;
|
struct spdk_bdev_part *part;
|
||||||
struct error_disk *error_disk = NULL;
|
struct error_disk *error_disk = NULL;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_vbdev_error_mutex);
|
pthread_mutex_lock(&g_vbdev_error_mutex);
|
||||||
bdev = spdk_bdev_get_by_name(name);
|
|
||||||
if (!bdev) {
|
rc = spdk_bdev_open_ext(name, false, dummy_bdev_event_cb, NULL, &desc);
|
||||||
SPDK_ERRLOG("Could not find ErrorInjection bdev %s\n", name);
|
if (rc != 0) {
|
||||||
|
SPDK_ERRLOG("Could not open ErrorInjection bdev %s\n", name);
|
||||||
pthread_mutex_unlock(&g_vbdev_error_mutex);
|
pthread_mutex_unlock(&g_vbdev_error_mutex);
|
||||||
return -ENODEV;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bdev = spdk_bdev_desc_get_bdev(desc);
|
||||||
|
|
||||||
TAILQ_FOREACH(part, &g_error_disks, tailq) {
|
TAILQ_FOREACH(part, &g_error_disks, tailq) {
|
||||||
if (bdev == spdk_bdev_part_get_bdev(part)) {
|
if (bdev == spdk_bdev_part_get_bdev(part)) {
|
||||||
error_disk = (struct error_disk *)part;
|
error_disk = (struct error_disk *)part;
|
||||||
@ -119,8 +129,8 @@ vbdev_error_inject_error(char *name, uint32_t io_type, uint32_t error_type, uint
|
|||||||
|
|
||||||
if (error_disk == NULL) {
|
if (error_disk == NULL) {
|
||||||
SPDK_ERRLOG("Could not find ErrorInjection bdev %s\n", name);
|
SPDK_ERRLOG("Could not find ErrorInjection bdev %s\n", name);
|
||||||
pthread_mutex_unlock(&g_vbdev_error_mutex);
|
rc = -ENODEV;
|
||||||
return -ENODEV;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0xffffffff == io_type) {
|
if (0xffffffff == io_type) {
|
||||||
@ -136,8 +146,11 @@ vbdev_error_inject_error(char *name, uint32_t io_type, uint32_t error_type, uint
|
|||||||
error_disk->error_vector[io_type].error_type = error_type;
|
error_disk->error_vector[io_type].error_type = error_type;
|
||||||
error_disk->error_vector[io_type].error_num = error_num;
|
error_disk->error_vector[io_type].error_num = error_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
spdk_bdev_close(desc);
|
||||||
pthread_mutex_unlock(&g_vbdev_error_mutex);
|
pthread_mutex_unlock(&g_vbdev_error_mutex);
|
||||||
return 0;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user