Commit 47447a64 authored by ZhaoLong Wang's avatar ZhaoLong Wang Committed by Zheng Zengkai
Browse files

ubi: Split io_failures into write_failure and erase_failure

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I60L5U


CVE: NA

-----------------------------------------

The emulate_io_failures debugfs entry controls both write
failure and erase failure. This patch split io_failures
to write_failure and erase_failure.

Signed-off-by: default avatarZhaoLong Wang <wangzhaolong1@huawei.com>
Reviewed-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 17c381a8
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@

#ifdef CONFIG_MTD_UBI_FAULT_INJECTION
static DECLARE_FAULT_ATTR(fault_bitflips_attr);
static DECLARE_FAULT_ATTR(fault_io_failures_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);

#define FAIL_ACTION(name, fault_attr)			\
@@ -24,7 +25,8 @@ bool should_fail_##name(void) \
}

FAIL_ACTION(bitflips,		fault_bitflips_attr)
FAIL_ACTION(io_failures,	fault_io_failures_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)
#endif

@@ -247,8 +249,11 @@ static void dfs_create_fault_entry(struct dentry *parent)
	fault_create_debugfs_attr("emulate_bitflips", dir,
				  &fault_bitflips_attr);

	fault_create_debugfs_attr("emulate_io_failures", dir,
				  &fault_io_failures_attr);
	fault_create_debugfs_attr("emulate_write_failure", dir,
				  &fault_write_failure_attr);

	fault_create_debugfs_attr("emulate_erase_failure", dir,
				  &fault_erase_failure_attr);

	fault_create_debugfs_attr("emulate_power_cut", dir,
				  &fault_power_cut_attr);
@@ -278,7 +283,6 @@ int ubi_debugfs_init(void)
#ifdef CONFIG_MTD_UBI_FAULT_INJECTION
	dfs_create_fault_entry(dfs_rootdir);
#endif

	return 0;
}

+10 −8
Original line number Diff line number Diff line
@@ -15,10 +15,11 @@
/* Emulate bit-flips */
#define MASK_BITFLIPS		(1 << 0)
/* Emulates -EIO during write/erase */
#define MASK_IO_FAILURE		(1 << 1)
#define MASK_WRITE_FAILURE	(1 << 1)
#define MASK_ERASE_FAILURE	(1 << 2)
/* Emulate a power cut when writing EC/VID header */
#define MASK_POWER_CUT_EC	(1 << 2)
#define MASK_POWER_CUT_VID	(1 << 3)
#define MASK_POWER_CUT_EC	(1 << 3)
#define MASK_POWER_CUT_VID	(1 << 4)

void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
@@ -79,7 +80,8 @@ static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi)
#ifdef CONFIG_MTD_UBI_FAULT_INJECTION

extern bool should_fail_bitflips(void);
extern bool should_fail_io_failures(void);
extern bool should_fail_write_failure(void);
extern bool should_fail_erase_failure(void);
extern bool should_fail_power_cut(void);

/**
@@ -104,8 +106,8 @@ static inline bool ubi_dbg_is_bitflip(const struct ubi_device *ubi)
 */
static inline bool ubi_dbg_is_write_failure(const struct ubi_device *ubi)
{
	if (ubi->dbg.emulate_failures & MASK_IO_FAILURE)
		return should_fail_io_failures();
	if (ubi->dbg.emulate_failures & MASK_WRITE_FAILURE)
		return should_fail_write_failure();
	return false;
}

@@ -118,8 +120,8 @@ static inline bool ubi_dbg_is_write_failure(const struct ubi_device *ubi)
 */
static inline bool ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
{
	if (ubi->dbg.emulate_failures & MASK_IO_FAILURE)
		return should_fail_io_failures();
	if (ubi->dbg.emulate_failures & MASK_ERASE_FAILURE)
		return should_fail_erase_failure();
	return false;
}