brintos

brintos / linux-shallow public Read only

0
0
Text · 6.4 KiB · 1d44278 Raw
179 lines · plain
1NVMe Fault Injection2====================3Linux's fault injection framework provides a systematic way to support4error injection via debugfs in the /sys/kernel/debug directory. When5enabled, the default NVME_SC_INVALID_OPCODE with no retry will be6injected into the nvme_try_complete_req. Users can change the default status7code and no retry flag via the debugfs. The list of Generic Command8Status can be found in include/linux/nvme.h9 10Following examples show how to inject an error into the nvme.11 12First, enable CONFIG_FAULT_INJECTION_DEBUG_FS kernel config,13recompile the kernel. After booting up the kernel, do the14following.15 16Example 1: Inject default status code with no retry17---------------------------------------------------18 19::20 21  mount /dev/nvme0n1 /mnt22  echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times23  echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability24  cp a.file /mnt25 26Expected Result::27 28  cp: cannot stat ‘/mnt/a.file’: Input/output error29 30Message from dmesg::31 32  FAULT_INJECTION: forcing a failure.33  name fault_inject, interval 1, probability 100, space 0, times 134  CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.15.0-rc8+ #235  Hardware name: innotek GmbH VirtualBox/VirtualBox,36  BIOS VirtualBox 12/01/200637  Call Trace:38    <IRQ>39    dump_stack+0x5c/0x7d40    should_fail+0x148/0x17041    nvme_should_fail+0x2f/0x50 [nvme_core]42    nvme_process_cq+0xe7/0x1d0 [nvme]43    nvme_irq+0x1e/0x40 [nvme]44    __handle_irq_event_percpu+0x3a/0x19045    handle_irq_event_percpu+0x30/0x7046    handle_irq_event+0x36/0x6047    handle_fasteoi_irq+0x78/0x12048    handle_irq+0xa7/0x13049    ? tick_irq_enter+0xa8/0xc050    do_IRQ+0x43/0xc051    common_interrupt+0xa2/0xa252    </IRQ>53  RIP: 0010:native_safe_halt+0x2/0x1054  RSP: 0018:ffffffff82003e90 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd55  RAX: ffffffff817a10c0 RBX: ffffffff82012480 RCX: 000000000000000056  RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000000000000057  RBP: 0000000000000000 R08: 000000008e38ce64 R09: 000000000000000058  R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff8201248059  R13: ffffffff82012480 R14: 0000000000000000 R15: 000000000000000060    ? __sched_text_end+0x4/0x461    default_idle+0x18/0xf062    do_idle+0x150/0x1d063    cpu_startup_entry+0x6f/0x8064    start_kernel+0x4c4/0x4e465    ? set_init_arg+0x55/0x5566    secondary_startup_64+0xa5/0xb067    print_req_error: I/O error, dev nvme0n1, sector 924068  EXT4-fs error (device nvme0n1): ext4_find_entry:1436:69  inode #2: comm cp: reading directory lblock 070 71Example 2: Inject default status code with retry72------------------------------------------------73 74::75 76  mount /dev/nvme0n1 /mnt77  echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times78  echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability79  echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/status80  echo 0 > /sys/kernel/debug/nvme0n1/fault_inject/dont_retry81 82  cp a.file /mnt83 84Expected Result::85 86  command success without error87 88Message from dmesg::89 90  FAULT_INJECTION: forcing a failure.91  name fault_inject, interval 1, probability 100, space 0, times 192  CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.15.0-rc8+ #493  Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/200694  Call Trace:95    <IRQ>96    dump_stack+0x5c/0x7d97    should_fail+0x148/0x17098    nvme_should_fail+0x30/0x60 [nvme_core]99    nvme_loop_queue_response+0x84/0x110 [nvme_loop]100    nvmet_req_complete+0x11/0x40 [nvmet]101    nvmet_bio_done+0x28/0x40 [nvmet]102    blk_update_request+0xb0/0x310103    blk_mq_end_request+0x18/0x60104    flush_smp_call_function_queue+0x3d/0xf0105    smp_call_function_single_interrupt+0x2c/0xc0106    call_function_single_interrupt+0xa2/0xb0107    </IRQ>108  RIP: 0010:native_safe_halt+0x2/0x10109  RSP: 0018:ffffc9000068bec0 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff04110  RAX: ffffffff817a10c0 RBX: ffff88011a3c9680 RCX: 0000000000000000111  RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000112  RBP: 0000000000000001 R08: 000000008e38c131 R09: 0000000000000000113  R10: 0000000000000000 R11: 0000000000000000 R12: ffff88011a3c9680114  R13: ffff88011a3c9680 R14: 0000000000000000 R15: 0000000000000000115    ? __sched_text_end+0x4/0x4116    default_idle+0x18/0xf0117    do_idle+0x150/0x1d0118    cpu_startup_entry+0x6f/0x80119    start_secondary+0x187/0x1e0120    secondary_startup_64+0xa5/0xb0121 122Example 3: Inject an error into the 10th admin command123------------------------------------------------------124 125::126 127  echo 100 > /sys/kernel/debug/nvme0/fault_inject/probability128  echo 10 > /sys/kernel/debug/nvme0/fault_inject/space129  echo 1 > /sys/kernel/debug/nvme0/fault_inject/times130  nvme reset /dev/nvme0131 132Expected Result::133 134  After NVMe controller reset, the reinitialization may or may not succeed.135  It depends on which admin command is actually forced to fail.136 137Message from dmesg::138 139  nvme nvme0: resetting controller140  FAULT_INJECTION: forcing a failure.141  name fault_inject, interval 1, probability 100, space 1, times 1142  CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.2.0-rc2+ #2143  Hardware name: MSI MS-7A45/B150M MORTAR ARCTIC (MS-7A45), BIOS 1.50 04/25/2017144  Call Trace:145   <IRQ>146   dump_stack+0x63/0x85147   should_fail+0x14a/0x170148   nvme_should_fail+0x38/0x80 [nvme_core]149   nvme_irq+0x129/0x280 [nvme]150   ? blk_mq_end_request+0xb3/0x120151   __handle_irq_event_percpu+0x84/0x1a0152   handle_irq_event_percpu+0x32/0x80153   handle_irq_event+0x3b/0x60154   handle_edge_irq+0x7f/0x1a0155   handle_irq+0x20/0x30156   do_IRQ+0x4e/0xe0157   common_interrupt+0xf/0xf158   </IRQ>159  RIP: 0010:cpuidle_enter_state+0xc5/0x460160  Code: ff e8 8f 5f 86 ff 80 7d c7 00 74 17 9c 58 0f 1f 44 00 00 f6 c4 02 0f 85 69 03 00 00 31 ff e8 62 aa 8c ff fb 66 0f 1f 44 00 00 <45> 85 ed 0f 88 37 03 00 00 4c 8b 45 d0 4c 2b 45 b8 48 ba cf f7 53161  RSP: 0018:ffffffff88c03dd0 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdc162  RAX: ffff9dac25a2ac80 RBX: ffffffff88d53760 RCX: 000000000000001f163  RDX: 0000000000000000 RSI: 000000002d958403 RDI: 0000000000000000164  RBP: ffffffff88c03e18 R08: fffffff75e35ffb7 R09: 00000a49a56c0b48165  R10: ffffffff88c03da0 R11: 0000000000001b0c R12: ffff9dac25a34d00166  R13: 0000000000000006 R14: 0000000000000006 R15: ffffffff88d53760167   cpuidle_enter+0x2e/0x40168   call_cpuidle+0x23/0x40169   do_idle+0x201/0x280170   cpu_startup_entry+0x1d/0x20171   rest_init+0xaa/0xb0172   arch_call_rest_init+0xe/0x1b173   start_kernel+0x51c/0x53b174   x86_64_start_reservations+0x24/0x26175   x86_64_start_kernel+0x74/0x77176   secondary_startup_64+0xa4/0xb0177  nvme nvme0: Could not set queue count (16385)178  nvme nvme0: IO queues not created179