mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: ZhaoLong Wang <wangzhaolong1@huawei.com>, <richard@nod.at>,
	<miquel.raynal@bootlin.com>, <vigneshr@ti.com>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<yi.zhang@huawei.com>
Subject: Re: [PATCH V2 3/5] ubi: Add six fault injection type for testing
Date: Mon, 31 Jul 2023 20:21:03 +0800	[thread overview]
Message-ID: <187349d2-89b4-6b7d-3c68-e21dd9aeb168@huawei.com> (raw)
In-Reply-To: <20230718085119.3885747-4-wangzhaolong1@huawei.com>

在 2023/7/18 16:51, ZhaoLong Wang 写道:
> This commit adds six fault injection type for testing to cover the
> abnormal path of the UBI driver.
> 
> Inject the following faults when the UBI reads the LEB:
>   +----------------------------+-----------------------------------+
>   |    Interface name          |       emulate behavior            |
>   +----------------------------+-----------------------------------+
>   |  emulate_eccerr            | ECC error                         |
>   +----------------------------+-----------------------------------+
>   |  emulate_read_failure      | read failure                      |
>   |----------------------------+-----------------------------------+
>   |  emulate_io_ff             | read content as all FF            |
>   |----------------------------+-----------------------------------+
>   |  emulate_io_ff_bitflips    | content FF with MTD err reported  |
>   +----------------------------+-----------------------------------+
>   |  emulate_bad_hdr           | bad leb header                    |
>   |----------------------------+-----------------------------------+
>   |  emulate_bad_hdr_ebadmsg   | bad header with ECC err           |
>   +----------------------------+-----------------------------------+
> 
> Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
> ---
>   drivers/mtd/ubi/debug.c |  30 +++++++++
>   drivers/mtd/ubi/debug.h | 132 ++++++++++++++++++++++++++++++++++++++--
>   drivers/mtd/ubi/io.c    |  75 ++++++++++++++++++++++-
>   drivers/mtd/ubi/ubi.h   |  31 ++++++----
>   4 files changed, 248 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
> index 7826bc8166e8..016a861c5029 100644
> --- a/drivers/mtd/ubi/debug.c
> +++ b/drivers/mtd/ubi/debug.c
> @@ -13,10 +13,16 @@
>   #include <linux/fault-inject.h>
>   
>   #ifdef CONFIG_MTD_UBI_FAULT_INJECTION
> +static DECLARE_FAULT_ATTR(fault_eccerr_attr);
>   static DECLARE_FAULT_ATTR(fault_bitflips_attr);
> +static DECLARE_FAULT_ATTR(fault_read_failure_attr);
>   static DECLARE_FAULT_ATTR(fault_write_failure_attr);
>   static DECLARE_FAULT_ATTR(fault_erase_failure_attr);
>   static DECLARE_FAULT_ATTR(fault_power_cut_attr);
> +static DECLARE_FAULT_ATTR(fault_io_ff_attr);
> +static DECLARE_FAULT_ATTR(fault_io_ff_bitflips_attr);
> +static DECLARE_FAULT_ATTR(fault_bad_hdr_attr);
> +static DECLARE_FAULT_ATTR(fault_bad_hdr_ebadmsg_attr);
>   
>   #define FAIL_ACTION(name, fault_attr)			\
>   bool should_fail_##name(void)				\
> @@ -24,10 +30,16 @@ bool should_fail_##name(void)				\
>   	return should_fail(&fault_attr, 1);		\
>   }
>   
> +FAIL_ACTION(eccerr,		fault_eccerr_attr)
>   FAIL_ACTION(bitflips,		fault_bitflips_attr)
> +FAIL_ACTION(read_failure,	fault_read_failure_attr)
>   FAIL_ACTION(write_failure,	fault_write_failure_attr)
>   FAIL_ACTION(erase_failure,	fault_erase_failure_attr)
>   FAIL_ACTION(power_cut,		fault_power_cut_attr)
> +FAIL_ACTION(io_ff,		fault_io_ff_attr)
> +FAIL_ACTION(io_ff_bitflips,	fault_io_ff_bitflips_attr)
> +FAIL_ACTION(bad_hdr,		fault_bad_hdr_attr)
> +FAIL_ACTION(bad_hdr_ebadmsg,	fault_bad_hdr_ebadmsg_attr)
>   #endif
>   
>   /**
> @@ -244,6 +256,12 @@ static void dfs_create_fault_entry(struct dentry *parent)
>   		return;
>   	}
>   
> +	fault_create_debugfs_attr("emulate_eccerr", dir,
> +				  &fault_eccerr_attr);
> +
> +	fault_create_debugfs_attr("emulate_read_failure", dir,
> +				  &fault_read_failure_attr);
> +
>   	fault_create_debugfs_attr("emulate_bitflips", dir,
>   				  &fault_bitflips_attr);
>   
> @@ -255,6 +273,18 @@ static void dfs_create_fault_entry(struct dentry *parent)
>   
>   	fault_create_debugfs_attr("emulate_power_cut", dir,
>   				  &fault_power_cut_attr);
> +
> +	fault_create_debugfs_attr("emulate_io_ff", dir,
> +				  &fault_io_ff_attr);
> +
> +	fault_create_debugfs_attr("emulate_io_ff_bitflips", dir,
> +				  &fault_io_ff_bitflips_attr);
> +
> +	fault_create_debugfs_attr("emulate_bad_hdr", dir,
> +				  &fault_bad_hdr_attr);
> +
> +	fault_create_debugfs_attr("emulate_bad_hdr_ebadmsg", dir,
> +				  &fault_bad_hdr_ebadmsg_attr);
>   }
>   #endif
>   
> diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
> index 6bc698b38e35..29fbd971964a 100644
> --- a/drivers/mtd/ubi/debug.h
> +++ b/drivers/mtd/ubi/debug.h
> @@ -85,20 +85,47 @@ static inline int ubi_dbg_erase_failure(const struct ubi_device *ubi)
>    * precisely control the type and process of fault injection.
>    */
>   /* Emulate a power cut when writing EC/VID header */
> -#define MASK_POWER_CUT_EC	(1 << 1)
> -#define MASK_POWER_CUT_VID	(1 << 2)
> +#define MASK_POWER_CUT_EC		(1 << 0)
> +#define MASK_POWER_CUT_VID		(1 << 1)
>   
>   #ifdef CONFIG_MTD_UBI_FAULT_INJECTION
> +/* Emulate a power cut when writing data*/
> +#define MASK_POWER_CUT_DATA		(1 << 2)
>   /* Emulate bit-flips */
> -#define MASK_BITFLIPS		(1 << 3)
> -/* Emulates -EIO during write/erase */
> -#define MASK_WRITE_FAILURE	(1 << 4)
> -#define MASK_ERASE_FAILURE	(1 << 5)
> +#define MASK_BITFLIPS			(1 << 3)
> +/* Emulate ecc error */
> +#define MASK_ECCERR			(1 << 4)
> +/* Emulates -EIO during data read */
> +#define MASK_READ_FAILURE		(1 << 5)
> +#define MASK_READ_FAILURE_EC		(1 << 6)
> +#define MASK_READ_FAILURE_VID		(1 << 7)
> +/* Emulates -EIO during data write */
> +#define MASK_WRITE_FAILURE		(1 << 8)
> +/* Emulates -EIO during erase a PEB*/
> +#define MASK_ERASE_FAILURE		(1 << 9)
> +/* Return UBI_IO_FF when reading EC/VID header */
> +#define MASK_IO_FF_EC			(1 << 10)
> +#define MASK_IO_FF_VID			(1 << 11)
> +/* Return UBI_IO_FF_BITFLIPS when reading EC/VID header */
> +#define MASK_IO_FF_BITFLIPS_EC		(1 << 12)
> +#define MASK_IO_FF_BITFLIPS_VID		(1 << 13)
> +/* Return UBI_IO_BAD_HDR when reading EC/VID header */
> +#define MASK_BAD_HDR_EC			(1 << 14)
> +#define MASK_BAD_HDR_VID		(1 << 15)
> +/* Return UBI_IO_BAD_HDR_EBADMSG when reading EC/VID header */
> +#define MASK_BAD_HDR_EBADMSG_EC		(1 << 16)
> +#define MASK_BAD_HDR_EBADMSG_VID	(1 << 17)
>   

Now, you add many types of fault injections, it's better to make 
dfs_file_read display human-readable context for 'd->emulate_failures', 
for example:
value:17409
POWER_CUT_EC,MASK_IO_FF_EC,MASK_BAD_HDR_EC

value:0
None

  parent reply	other threads:[~2023-07-31 12:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18  8:51 [PATCH V2 0/5] ubi: Enhanced fault injection capability for the UBI driver ZhaoLong Wang
2023-07-18  8:51 ` [PATCH V2 1/5] ubi: Use the fault injection framework to enhance the fault injection capability ZhaoLong Wang
2023-07-31 11:15   ` Zhihao Cheng
2023-07-18  8:51 ` [PATCH V2 2/5] ubi: Split io_failures into write_failure and erase_failure ZhaoLong Wang
2023-07-31 11:24   ` Zhihao Cheng
2023-07-18  8:51 ` [PATCH V2 3/5] ubi: Add six fault injection type for testing ZhaoLong Wang
2023-07-31 11:57   ` Zhihao Cheng
2023-07-31 12:09   ` Zhihao Cheng
2023-07-31 12:21   ` Zhihao Cheng [this message]
2023-07-18  8:51 ` [PATCH V2 4/5] ubi: Reserve sufficient buffer length for the input mask ZhaoLong Wang
2023-07-31 12:13   ` Zhihao Cheng
2023-07-18  8:51 ` [PATCH V2 5/5] mtd: Add several functions to the fail_function list ZhaoLong Wang
2023-07-31 12:16   ` Zhihao Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=187349d2-89b4-6b7d-3c68-e21dd9aeb168@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    --cc=wangzhaolong1@huawei.com \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®