Skip to content

Commit e30948f

Browse files
ZhaoLong Wangrichardweinberger
authored andcommitted
ubi: Split io_failures into write_failure and erase_failure
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: ZhaoLong Wang <wangzhaolong1@huawei.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 6931fb4 commit e30948f

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

drivers/mtd/ubi/debug.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
#ifdef CONFIG_MTD_UBI_FAULT_INJECTION
1616
static DECLARE_FAULT_ATTR(fault_bitflips_attr);
17-
static DECLARE_FAULT_ATTR(fault_io_failures_attr);
17+
static DECLARE_FAULT_ATTR(fault_write_failure_attr);
18+
static DECLARE_FAULT_ATTR(fault_erase_failure_attr);
1819
static DECLARE_FAULT_ATTR(fault_power_cut_attr);
1920

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

2627
FAIL_ACTION(bitflips, fault_bitflips_attr)
27-
FAIL_ACTION(io_failures, fault_io_failures_attr)
28+
FAIL_ACTION(write_failure, fault_write_failure_attr)
29+
FAIL_ACTION(erase_failure, fault_erase_failure_attr)
2830
FAIL_ACTION(power_cut, fault_power_cut_attr)
2931
#endif
3032

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

248-
fault_create_debugfs_attr("emulate_io_failures", dir,
249-
&fault_io_failures_attr);
250+
fault_create_debugfs_attr("emulate_write_failure", dir,
251+
&fault_write_failure_attr);
252+
253+
fault_create_debugfs_attr("emulate_erase_failure", dir,
254+
&fault_erase_failure_attr);
250255

251256
fault_create_debugfs_attr("emulate_power_cut", dir,
252257
&fault_power_cut_attr);

drivers/mtd/ubi/debug.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ static inline int ubi_dbg_erase_failure(const struct ubi_device *ubi)
9292
/* Emulate bit-flips */
9393
#define MASK_BITFLIPS (1 << 2)
9494
/* Emulates -EIO during write/erase */
95-
#define MASK_IO_FAILURE (1 << 3)
95+
#define MASK_WRITE_FAILURE (1 << 3)
96+
#define MASK_ERASE_FAILURE (1 << 4)
9697

9798
extern bool should_fail_bitflips(void);
98-
extern bool should_fail_io_failures(void);
99+
extern bool should_fail_write_failure(void);
100+
extern bool should_fail_erase_failure(void);
99101
extern bool should_fail_power_cut(void);
100102

101103
static inline bool ubi_dbg_fail_bitflip(const struct ubi_device *ubi)
@@ -107,15 +109,15 @@ static inline bool ubi_dbg_fail_bitflip(const struct ubi_device *ubi)
107109

108110
static inline bool ubi_dbg_fail_write(const struct ubi_device *ubi)
109111
{
110-
if (ubi->dbg.emulate_failures & MASK_IO_FAILURE)
111-
return should_fail_io_failures();
112+
if (ubi->dbg.emulate_failures & MASK_WRITE_FAILURE)
113+
return should_fail_write_failure();
112114
return false;
113115
}
114116

115117
static inline bool ubi_dbg_fail_erase(const struct ubi_device *ubi)
116118
{
117-
if (ubi->dbg.emulate_failures & MASK_IO_FAILURE)
118-
return should_fail_io_failures();
119+
if (ubi->dbg.emulate_failures & MASK_ERASE_FAILURE)
120+
return should_fail_erase_failure();
119121
return false;
120122
}
121123

0 commit comments

Comments
 (0)