aboutsummaryrefslogtreecommitdiffstats
path: root/sys/cam/nvme/nvme_da.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-03-14 17:53:37 +0000
committerWarner Losh <imp@FreeBSD.org>2018-03-14 17:53:37 +0000
commitd38677d23c2545b2d98c93ef13a6c9af9c2d28cc (patch)
tree0e37c6b5f51155c6db22d299fd67a46218e4edd7 /sys/cam/nvme/nvme_da.c
parent2a559cb8c8177e89e7bf74a54c8a34fbcf7b7139 (diff)
downloadsrc-d38677d23c2545b2d98c93ef13a6c9af9c2d28cc.tar.gz
src-d38677d23c2545b2d98c93ef13a6c9af9c2d28cc.zip
Create a sysctl kern.cam.{,a,n}da.X.invalidate
kern.cam.{,a,n}da.X.invalidate=1 forces *daX to detach by calling cam_periph_invalidate on the underlying periph. This is for testing purposes only. Include only with options CAM_TEST_FAILURE and rename the former [AN]DA_TEST_FAILURE, and fix nda to compile with it set. We're using it at work to harden geom and the buffer cache to be resilient in the face of drive failure. Today, it far too often results in a panic. While much work was done on SIM initiated removal for the USB thumnb drive removal work, little has been done for periph initiated removal. This simulates what *daerror() does for some errors nicely: we get the same panics with it that we do with failing drives. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D14581
Notes
Notes: svn path=/head/; revision=330935
Diffstat (limited to 'sys/cam/nvme/nvme_da.c')
-rw-r--r--sys/cam/nvme/nvme_da.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index a041e9fe948a..d83f505f5fb1 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -112,6 +112,12 @@ struct nda_softc {
struct task sysctl_task;
struct sysctl_ctx_list sysctl_ctx;
struct sysctl_oid *sysctl_tree;
+#ifdef CAM_TEST_FAILURE
+ int force_read_error;
+ int force_write_error;
+ int periodic_read_error;
+ int periodic_read_count;
+#endif
#ifdef CAM_IO_STATS
struct sysctl_ctx_list sysctl_stats_ctx;
struct sysctl_oid *sysctl_stats_tree;
@@ -666,6 +672,13 @@ ndasysctlinit(void *context, int pending)
"Device pack invalidations.");
#endif
+#ifdef CAM_TEST_FAILURE
+ SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO, "invalidate", CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE,
+ periph, 0, cam_periph_invalidate_sysctl, "I",
+ "Write 1 to invalidate the drive immediately");
+#endif
+
cam_iosched_sysctl_init(softc->cam_iosched, &softc->sysctl_ctx,
softc->sysctl_tree);
@@ -876,7 +889,7 @@ ndastart(struct cam_periph *periph, union ccb *start_ccb)
/* FALLTHROUGH */
case BIO_READ:
{
-#ifdef NDA_TEST_FAILURE
+#ifdef CAM_TEST_FAILURE
int fail = 0;
/*