@@ -85,35 +85,30 @@ void ubi_debugfs_exit_dev(struct ubi_device *ubi);
8585 *
8686 * @chk_gen: if UBI general extra checks are enabled
8787 * @chk_io: if UBI I/O extra checks are enabled
88+ * @disable_bgt: disable the background task for testing purposes
89+ * @emulate_bitflips: emulate bit-flips for testing purposes
90+ * @emulate_io_failures: emulate write/erase failures for testing purposes
8891 * @dfs_dir_name: name of debugfs directory containing files of this UBI device
8992 * @dfs_dir: direntry object of the UBI device debugfs directory
9093 * @dfs_chk_gen: debugfs knob to enable UBI general extra checks
9194 * @dfs_chk_io: debugfs knob to enable UBI I/O extra checks
95+ * @dfs_disable_bgt: debugfs knob to disable the background task
96+ * @dfs_emulate_bitflips: debugfs knob to emulate bit-flips
97+ * @dfs_emulate_io_failures: debugfs knob to emulate write/erase failures
9298 */
9399struct ubi_debug_info {
94100 unsigned int chk_gen :1 ;
95101 unsigned int chk_io :1 ;
102+ unsigned int disable_bgt :1 ;
103+ unsigned int emulate_bitflips :1 ;
104+ unsigned int emulate_io_failures :1 ;
96105 char dfs_dir_name [UBI_DFS_DIR_LEN + 1 ];
97106 struct dentry * dfs_dir ;
98107 struct dentry * dfs_chk_gen ;
99108 struct dentry * dfs_chk_io ;
100- };
101-
102- extern unsigned int ubi_tst_flags ;
103-
104- /*
105- * Special testing flags.
106- *
107- * UBIFS_TST_DISABLE_BGT: disable the background thread
108- * UBI_TST_EMULATE_BITFLIPS: emulate bit-flips
109- * UBI_TST_EMULATE_WRITE_FAILURES: emulate write failures
110- * UBI_TST_EMULATE_ERASE_FAILURES: emulate erase failures
111- */
112- enum {
113- UBI_TST_DISABLE_BGT = 0x1 ,
114- UBI_TST_EMULATE_BITFLIPS = 0x2 ,
115- UBI_TST_EMULATE_WRITE_FAILURES = 0x4 ,
116- UBI_TST_EMULATE_ERASE_FAILURES = 0x8 ,
109+ struct dentry * dfs_disable_bgt ;
110+ struct dentry * dfs_emulate_bitflips ;
111+ struct dentry * dfs_emulate_io_failures ;
117112};
118113
119114/**
@@ -125,7 +120,7 @@ enum {
125120 */
126121static inline int ubi_dbg_is_bgt_disabled (const struct ubi_device * ubi )
127122{
128- return ubi_tst_flags & UBI_TST_DISABLE_BGT ;
123+ return ubi -> dbg -> disable_bgt ;
129124}
130125
131126/**
@@ -136,7 +131,7 @@ static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi)
136131 */
137132static inline int ubi_dbg_is_bitflip (const struct ubi_device * ubi )
138133{
139- if (ubi_tst_flags & UBI_TST_EMULATE_BITFLIPS )
134+ if (ubi -> dbg -> emulate_bitflips )
140135 return !(random32 () % 200 );
141136 return 0 ;
142137}
@@ -150,7 +145,7 @@ static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
150145 */
151146static inline int ubi_dbg_is_write_failure (const struct ubi_device * ubi )
152147{
153- if (ubi_tst_flags & UBI_TST_EMULATE_WRITE_FAILURES )
148+ if (ubi -> dbg -> emulate_io_failures )
154149 return !(random32 () % 500 );
155150 return 0 ;
156151}
@@ -164,7 +159,7 @@ static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
164159 */
165160static inline int ubi_dbg_is_erase_failure (const struct ubi_device * ubi )
166161{
167- if (ubi_tst_flags & UBI_TST_EMULATE_ERASE_FAILURES )
162+ if (ubi -> dbg -> emulate_io_failures )
168163 return !(random32 () % 400 );
169164 return 0 ;
170165}
0 commit comments