[Devel] [PATCH RHEL9 COMMIT] dm-ploop: Allow fault injection for all ploop functions
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Aug 15 21:25:07 MSK 2022
The commit is pushed to "branch-rh9-5.14.0-70.13.1.vz9.16.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-70.13.1.vz9.16.8
------>
commit 08ecc9705fad82a96de3d7740da50281fb169d50
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date: Mon Aug 15 12:33:40 2022 +0300
dm-ploop: Allow fault injection for all ploop functions
https://jira.sw.ru/browse/PSBM-136606
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Feature: dm-ploop: ploop target driver fault injection
---
drivers/md/dm-ploop-bat.c | 10 ++++++++++
drivers/md/dm-ploop-cmd.c | 21 +++++++++++++++++++--
drivers/md/dm-ploop-map.c | 11 +++++++++++
drivers/md/dm-ploop-target.c | 7 +++++++
4 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index 99f046dfec3b..48bf525aa981 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -8,6 +8,7 @@
#include <linux/init.h>
#include <linux/file.h>
#include <linux/uio.h>
+#include <linux/error-injection.h>
#include <linux/mm.h>
#include "dm-ploop.h"
@@ -30,6 +31,7 @@ struct md_page *ploop_md_page_find(struct ploop *ploop, u32 id)
return NULL;
}
+ALLOW_ERROR_INJECTION(ploop_md_page_find, NULL);
static void __md_page_insert(struct rb_root *root, struct md_page *new_md)
{
@@ -93,6 +95,7 @@ static struct md_page *ploop_alloc_md_page(u32 id)
kfree(md);
return NULL;
}
+ALLOW_ERROR_INJECTION(ploop_alloc_md_page, NULL);
void ploop_free_md_page(struct md_page *md)
{
@@ -175,6 +178,7 @@ static int ploop_setup_holes_bitmap(struct ploop *ploop, u32 bat_clusters)
return 0;
}
+ALLOW_ERROR_INJECTION(ploop_setup_holes_bitmap, ERRNO);
int ploop_setup_metadata(struct ploop *ploop, struct page *page)
{
@@ -228,6 +232,7 @@ int ploop_setup_metadata(struct ploop *ploop, struct page *page)
kunmap(page);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_setup_metadata, ERRNO);
static int ploop_delta_check_header(struct ploop *ploop,
struct rb_root *md_root,
@@ -261,6 +266,7 @@ static int ploop_delta_check_header(struct ploop *ploop,
kunmap(md0->page);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_delta_check_header, ERRNO);
static int ploop_convert_bat_entries(struct ploop *ploop, struct rb_root *md_root,
u32 nr_be, u32 nr_pages, loff_t file_size)
@@ -297,6 +303,7 @@ static int ploop_convert_bat_entries(struct ploop *ploop, struct rb_root *md_roo
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_convert_bat_entries, ERRNO);
int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
struct rb_root *md_root, u32 *delta_nr_be_ret)
@@ -375,6 +382,7 @@ int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
kvfree(bvec);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_read_delta_metadata, ERRNO);
static void ploop_set_not_hole(struct ploop *ploop, u32 dst_clu)
{
@@ -465,6 +473,7 @@ int ploop_check_delta_length(struct ploop *ploop, struct file *file, loff_t *fil
*file_size = loff;
return 0;
}
+ALLOW_ERROR_INJECTION(ploop_check_delta_length, ERRNO)
/*
* @fd refers to a new delta, which is placed right before top_delta.
@@ -506,3 +515,4 @@ int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_r
ploop_free_md_pages_tree(&md_root);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_add_delta, ERRNO);
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 2faa6d500983..aa4374d8b94b 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -7,6 +7,7 @@
#include <linux/init.h>
#include <linux/file.h>
+#include <linux/error-injection.h>
#include <linux/uio.h>
#include <linux/ctype.h>
#include <linux/umh.h>
@@ -119,6 +120,7 @@ static int ploop_inflight_bios_ref_switch(struct ploop *ploop, bool killable)
percpu_ref_reinit(&ploop->inflight_bios_ref[index]);
return 0;
}
+ALLOW_ERROR_INJECTION(ploop_inflight_bios_ref_switch, ERRNO);
static void ploop_resume_submitting_pios(struct ploop *ploop)
{
@@ -147,6 +149,7 @@ static int ploop_suspend_submitting_pios(struct ploop *ploop)
ploop_resume_submitting_pios(ploop);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_suspend_submitting_pios, ERRNO);
/* Find existing BAT clu pointing to dst_clu */
static u32 ploop_find_bat_entry(struct ploop *ploop, u32 dst_clu, bool *is_locked)
@@ -226,6 +229,7 @@ static int ploop_read_cluster_sync(struct ploop *ploop, struct pio *pio,
return 0;
}
+ALLOW_ERROR_INJECTION(ploop_read_cluster_sync, ERRNO);
static int ploop_write_cluster_sync(struct ploop *ploop, struct pio *pio,
u32 dst_clu)
@@ -252,6 +256,7 @@ static int ploop_write_cluster_sync(struct ploop *ploop, struct pio *pio,
return vfs_fsync(file, 0);
}
+ALLOW_ERROR_INJECTION(ploop_write_cluster_sync, ERRNO);
static int ploop_write_zero_cluster_sync(struct ploop *ploop,
struct pio *pio, u32 clu)
@@ -359,6 +364,7 @@ static int ploop_grow_relocate_cluster(struct ploop *ploop,
out:
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_grow_relocate_cluster, ERRNO);
static int ploop_grow_update_header(struct ploop *ploop,
struct ploop_cmd *cmd)
@@ -412,13 +418,14 @@ static int ploop_grow_update_header(struct ploop *ploop,
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_grow_update_header, ERRNO);
static void ploop_add_md_pages(struct ploop *ploop, struct rb_root *from)
{
struct rb_node *node;
- struct md_page *md;
+ struct md_page *md;
- while ((node = from->rb_node) != NULL) {
+ while ((node = from->rb_node) != NULL) {
md = rb_entry(node, struct md_page, node);
rb_erase(node, from);
ploop_md_page_insert(ploop, md);
@@ -465,6 +472,7 @@ static int ploop_process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_process_resize_cmd, ERRNO);
struct pio *ploop_alloc_pio_with_pages(struct ploop *ploop)
{
@@ -496,6 +504,7 @@ struct pio *ploop_alloc_pio_with_pages(struct ploop *ploop)
kfree(pio);
return NULL;
}
+ALLOW_ERROR_INJECTION(ploop_alloc_pio_with_pages, NULL);
void ploop_free_pio_with_pages(struct ploop *ploop, struct pio *pio)
{
@@ -600,6 +609,8 @@ static int ploop_resize(struct ploop *ploop, sector_t new_sectors)
ploop_free_md_pages_tree(&cmd.resize.md_pages_root);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_resize, ERRNO);
+
static void service_pio_endio(struct pio *pio, void *data, blk_status_t status)
{
struct ploop *ploop = pio->ploop;
@@ -666,6 +677,7 @@ static int ploop_process_merge_latest_snapshot(struct ploop *ploop)
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_process_merge_latest_snapshot, ERRNO);
static int ploop_merge_latest_snapshot(struct ploop *ploop)
{
@@ -701,6 +713,7 @@ static int ploop_merge_latest_snapshot(struct ploop *ploop)
out:
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_merge_latest_snapshot, ERRNO);
static void notify_delta_merged(struct ploop *ploop, u8 level,
struct rb_root *md_root,
@@ -804,6 +817,7 @@ static int ploop_process_update_delta_index(struct ploop *ploop, u8 level,
write_unlock_irq(&ploop->bat_rwlock);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_process_update_delta_index, ERRNO);
static int ploop_delta_clusters_merged(struct ploop *ploop, u8 level,
bool forward)
@@ -849,6 +863,7 @@ static int ploop_delta_clusters_merged(struct ploop *ploop, u8 level,
ploop_free_md_pages_tree(&md_root);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_delta_clusters_merged, ERRNO);
static int ploop_notify_merged(struct ploop *ploop, u8 level, bool forward)
{
@@ -915,6 +930,7 @@ static int ploop_get_delta_name_cmd(struct ploop *ploop, u8 level,
out:
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_get_delta_name_cmd, ERRNO_NULL);
static int ploop_update_delta_index(struct ploop *ploop, unsigned int level,
const char *map)
@@ -947,6 +963,7 @@ static int ploop_update_delta_index(struct ploop *ploop, unsigned int level,
out:
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_update_delta_index, ERRNO);
static int process_flip_upper_deltas(struct ploop *ploop)
{
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index f302e778e002..e8288e522e28 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -13,6 +13,7 @@
#include <linux/blk-cgroup.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
+#include <linux/error-injection.h>
#include <linux/uio.h>
#include <linux/blk-mq.h>
#include <uapi/linux/falloc.h>
@@ -111,6 +112,7 @@ static int ploop_rq_valid(struct ploop *ploop, struct request *rq)
return 0;
}
+ALLOW_ERROR_INJECTION(ploop_rq_valid, ERRNO);
static void ploop_init_prq(struct ploop_rq *prq, struct request *rq)
{
@@ -290,6 +292,7 @@ static struct pio *ploop_split_and_chain_pio(struct ploop *ploop,
ploop_pio_advance(pio, len);
return split;
}
+ALLOW_ERROR_INJECTION(ploop_split_and_chain_pio, NULL);
static int ploop_split_pio_to_list(struct ploop *ploop, struct pio *pio,
struct list_head *ret_list)
@@ -327,6 +330,7 @@ static int ploop_split_pio_to_list(struct ploop *ploop, struct pio *pio,
}
return -ENOMEM;
}
+ALLOW_ERROR_INJECTION(ploop_split_pio_to_list, ERRNO);
static void ploop_dispatch_pio(struct ploop *ploop, struct pio *pio,
bool *is_data, bool *is_flush)
@@ -425,6 +429,7 @@ struct pio *ploop_find_pio(struct hlist_head head[], u32 clu)
return NULL;
}
+ALLOW_ERROR_INJECTION(ploop_find_pio, NULL);
static struct pio *ploop_find_inflight_bio(struct ploop *ploop, u32 clu)
{
@@ -987,6 +992,7 @@ static int ploop_find_dst_clu_bit(struct ploop *ploop, u32 *ret_dst_clu)
*ret_dst_clu = dst_clu;
return 0;
}
+ALLOW_ERROR_INJECTION(ploop_find_dst_clu_bit, ERRNO);
static int ploop_truncate_prealloc_safe(struct ploop *ploop,
struct ploop_delta *delta,
@@ -1020,6 +1026,7 @@ static int ploop_truncate_prealloc_safe(struct ploop *ploop,
delta->file_preallocated_area_start = len;
return 0;
}
+ALLOW_ERROR_INJECTION(ploop_truncate_prealloc_safe, ERRNO);
static int ploop_allocate_cluster(struct ploop *ploop, u32 *dst_clu)
{
@@ -1076,6 +1083,7 @@ static int ploop_allocate_cluster(struct ploop *ploop, u32 *dst_clu)
ploop_hole_clear_bit(*dst_clu, ploop);
return 0;
}
+ALLOW_ERROR_INJECTION(ploop_allocate_cluster, ERRNO);
/*
* This finds a free dst_clu on origin device, and reflects this
@@ -1305,6 +1313,7 @@ static void ploop_initiate_cluster_cow(struct ploop *ploop, unsigned int level,
pio->bi_status = BLK_STS_RESOURCE;
ploop_pio_endio(pio);
}
+ALLOW_ERROR_INJECTION(ploop_submit_cluster_cow, ERRNO);
static void ploop_submit_cluster_write(struct ploop_cow *cow)
{
@@ -1598,6 +1607,7 @@ static struct bio_vec *ploop_create_bvec_from_rq(struct request *rq)
out:
return bvec;
}
+ALLOW_ERROR_INJECTION(ploop_create_bvec_from_rq, NULL);
static void ploop_prepare_one_embedded_pio(struct ploop *ploop,
struct pio *pio,
@@ -1938,3 +1948,4 @@ int ploop_prepare_reloc_index_wb(struct ploop *ploop,
out_error:
return err;
}
+ALLOW_ERROR_INJECTION(ploop_prepare_reloc_index_wb, ERRNO);
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index e670ea320bf8..4b50487b7fb5 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -18,6 +18,7 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/uio.h>
+#include <linux/error-injection.h>
#include "dm-ploop.h"
#define DM_MSG_PREFIX "ploop"
@@ -104,6 +105,7 @@ int ploop_rw_page_sync(unsigned rw, struct file *file,
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_rw_page_sync, ERRNO);
static void ploop_inflight_bios_ref_exit0(struct percpu_ref *ref)
{
@@ -197,6 +199,7 @@ static struct file *ploop_get_delta_file(int fd)
return file;
}
+ALLOW_ERROR_INJECTION(ploop_get_delta_file, ERRNO_NULL);
static int ploop_check_top_delta(struct ploop *ploop, struct file *file)
{
@@ -235,6 +238,7 @@ static int ploop_check_top_delta(struct ploop *ploop, struct file *file)
put_page(page);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_check_top_delta, ERRNO);
static int ploop_add_deltas_stack(struct ploop *ploop, char **argv, int argc)
{
@@ -294,6 +298,7 @@ static int ploop_add_deltas_stack(struct ploop *ploop, char **argv, int argc)
fput(file);
goto out;
}
+ALLOW_ERROR_INJECTION(ploop_add_deltas_stack, ERRNO);
#define EAT_ARG(argc, argv) \
do { \
@@ -429,6 +434,7 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ploop_destroy(ploop);
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_ctr, ERRNO);
static void ploop_dtr(struct dm_target *ti)
{
@@ -540,6 +546,7 @@ static int ploop_preresume(struct dm_target *ti)
}
return ret;
}
+ALLOW_ERROR_INJECTION(ploop_preresume, ERRNO);
/*----------------------------------------------------------------*/
More information about the Devel
mailing list