Skip to content

Commit

Permalink
nvme: Inject artificial failure on reset
Browse files Browse the repository at this point in the history
Add a sysctl to artificially fail the reset to test the failure to reset
hardware code path. While there are many ways that reset can fail, this
provides an adequate way that similates enough of the failures well
enough to shake out this failure path.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D28584
  • Loading branch information
bsdimp committed Oct 15, 2024
1 parent 82c96fe commit 9dbff03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sys/dev/nvme/nvme_ctrlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ nvme_ctrlr_start_config_hook(void *arg)

TSENTER();

if (nvme_ctrlr_hw_reset(ctrlr) != 0) {
if (nvme_ctrlr_hw_reset(ctrlr) != 0 || ctrlr->fail_on_reset != 0) {
nvme_ctrlr_fail(ctrlr, true);
config_intrhook_disestablish(&ctrlr->config_hook);
return;
Expand Down
1 change: 1 addition & 0 deletions sys/dev/nvme/nvme_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ struct nvme_controller {

uint32_t is_resetting;
uint32_t notification_sent;
u_int fail_on_reset;

bool is_failed;
bool is_failed_admin;
Expand Down
4 changes: 4 additions & 0 deletions sys/dev/nvme/nvme_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr)
CTLFLAG_RD, &ctrlr->cap_hi, 0,
"Hi 32-bits of capacities for the drive");

SYSCTL_ADD_UINT(ctrlr_ctx, ctrlr_list, OID_AUTO, "fail_on_reset",
CTLFLAG_RD, &ctrlr->fail_on_reset, 0,
"Pretend the next reset fails and fail the controller");

que_tree = SYSCTL_ADD_NODE(ctrlr_ctx, ctrlr_list, OID_AUTO, "adminq",
CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Admin Queue");

Expand Down

0 comments on commit 9dbff03

Please sign in to comment.