|
27 | 27 | #define TICKS_PER_SEC 50ULL
|
28 | 28 | #define TIMER_INTERVAL (NSEC_PER_SEC / TICKS_PER_SEC)
|
29 | 29 |
|
| 30 | +#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION |
30 | 31 | static DECLARE_FAULT_ATTR(null_timeout_attr);
|
| 32 | +#endif |
31 | 33 |
|
32 | 34 | static inline u64 mb_per_tick(int mbps)
|
33 | 35 | {
|
@@ -165,8 +167,10 @@ static int g_home_node = NUMA_NO_NODE;
|
165 | 167 | module_param_named(home_node, g_home_node, int, S_IRUGO);
|
166 | 168 | MODULE_PARM_DESC(home_node, "Home node for the device");
|
167 | 169 |
|
| 170 | +#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION |
168 | 171 | static char g_timeout_str[80];
|
169 | 172 | module_param_string(timeout, g_timeout_str, sizeof(g_timeout_str), S_IRUGO);
|
| 173 | +#endif |
170 | 174 |
|
171 | 175 | static int g_queue_mode = NULL_Q_MQ;
|
172 | 176 |
|
@@ -1372,8 +1376,10 @@ static int null_rq_prep_fn(struct request_queue *q, struct request *req)
|
1372 | 1376 |
|
1373 | 1377 | static bool should_timeout_request(struct request *rq)
|
1374 | 1378 | {
|
| 1379 | +#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION |
1375 | 1380 | if (g_timeout_str[0])
|
1376 | 1381 | return should_fail(&null_timeout_attr, 1);
|
| 1382 | +#endif |
1377 | 1383 |
|
1378 | 1384 | return false;
|
1379 | 1385 | }
|
@@ -1655,13 +1661,15 @@ static void null_validate_conf(struct nullb_device *dev)
|
1655 | 1661 |
|
1656 | 1662 | static bool null_setup_fault(void)
|
1657 | 1663 | {
|
| 1664 | +#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION |
1658 | 1665 | if (!g_timeout_str[0])
|
1659 | 1666 | return true;
|
1660 | 1667 |
|
1661 | 1668 | if (!setup_fault_attr(&null_timeout_attr, g_timeout_str))
|
1662 | 1669 | return false;
|
1663 | 1670 |
|
1664 | 1671 | null_timeout_attr.verbose = 0;
|
| 1672 | +#endif |
1665 | 1673 | return true;
|
1666 | 1674 | }
|
1667 | 1675 |
|
|
0 commit comments