Page MenuHomeFreeBSD

D14581.id39934.diff
No OneTemporary

D14581.id39934.diff

Index: sys/cam/ata/ata_da.c
===================================================================
--- sys/cam/ata/ata_da.c
+++ sys/cam/ata/ata_da.c
@@ -238,7 +238,7 @@
int write_cache;
int unmappedio;
int rotating;
-#ifdef ADA_TEST_FAILURE
+#ifdef CAM_TEST_FAILURE
int force_read_error;
int force_write_error;
int periodic_read_error;
@@ -1475,7 +1475,7 @@
"max_seq_zones", CTLFLAG_RD, &softc->max_seq_zones,
"Maximum Number of Open Sequential Write Required Zones");
-#ifdef ADA_TEST_FAILURE
+#ifdef CAM_TEST_FAILURE
/*
* Add a 'door bell' sysctl which allows one to set it from userland
* and cause something bad to happen. For the moment, we only allow
@@ -1493,6 +1493,10 @@
OID_AUTO, "periodic_read_error", CTLFLAG_RW | CTLFLAG_MPSAFE,
&softc->periodic_read_error, 0,
"Force a read error every N reads (don't set too low).");
+ 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
#ifdef CAM_IO_STATS
@@ -2293,7 +2297,7 @@
data_ptr = bp;
}
-#ifdef ADA_TEST_FAILURE
+#ifdef CAM_TEST_FAILURE
int fail = 0;
/*
Index: sys/cam/cam_periph.h
===================================================================
--- sys/cam/cam_periph.h
+++ sys/cam/cam_periph.h
@@ -37,6 +37,7 @@
#include <cam/cam_sim.h>
#ifdef _KERNEL
+#include <sys/sysctl.h>
#include <sys/taskqueue.h>
#include <cam/cam_xpt.h>
@@ -198,6 +199,7 @@
u_int duration_ms);
int cam_periph_error(union ccb *ccb, cam_flags camflags,
u_int32_t sense_flags);
+int cam_periph_invalidate_sysctl(SYSCTL_HANDLER_ARGS);
static __inline struct mtx *
cam_periph_mtx(struct cam_periph *periph)
Index: sys/cam/cam_periph.c
===================================================================
--- sys/cam/cam_periph.c
+++ sys/cam/cam_periph.c
@@ -2066,3 +2066,25 @@
free(sbmsg, M_CAMPERIPH);
}
+/*
+ * Sysctl to force an invalidation of the drive right now. Can be
+ * called with CTLFLAG_MPSAFE since we take periph lock.
+ */
+int
+cam_periph_invalidate_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ struct cam_periph *periph;
+ int error, value;
+
+ periph = arg1;
+ value = 0;
+ error = sysctl_handle_int(oidp, &value, 0, req);
+ if (error != 0 || req->newptr == NULL || value != 1)
+ return (error);
+
+ cam_periph_lock(periph);
+ cam_periph_invalidate(periph);
+ cam_periph_unlock(periph);
+
+ return (0);
+}
Index: sys/cam/nvme/nvme_da.c
===================================================================
--- sys/cam/nvme/nvme_da.c
+++ sys/cam/nvme/nvme_da.c
@@ -113,6 +113,12 @@
struct sysctl_ctx_list sysctl_ctx;
struct sysctl_oid *sysctl_tree;
struct trim_request trim_req;
+#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;
@@ -645,6 +651,13 @@
"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);
@@ -854,7 +867,7 @@
/* FALLTHROUGH */
case BIO_READ:
{
-#ifdef NDA_TEST_FAILURE
+#ifdef CAM_TEST_FAILURE
int fail = 0;
/*
Index: sys/cam/scsi/scsi_da.c
===================================================================
--- sys/cam/scsi/scsi_da.c
+++ sys/cam/scsi/scsi_da.c
@@ -2192,6 +2192,13 @@
0,
"Rotating media");
+#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
+
/*
* Add some addressing info.
*/
Index: sys/conf/options
===================================================================
--- sys/conf/options
+++ sys/conf/options
@@ -335,12 +335,12 @@
CAM_DEBUG_FLAGS opt_cam.h
CAM_BOOT_DELAY opt_cam.h
CAM_IOSCHED_DYNAMIC opt_cam.h
+CAM_TEST_FAILURE opt_cam.h
SCSI_DELAY opt_scsi.h
SCSI_NO_SENSE_STRINGS opt_scsi.h
SCSI_NO_OP_STRINGS opt_scsi.h
# Options used only in cam/ata/ata_da.c
-ADA_TEST_FAILURE opt_ada.h
ATA_STATIC_ID opt_ada.h
# Options used only in cam/scsi/scsi_cd.c

File Metadata

Mime Type
text/plain
Expires
Mon, Aug 3, 1:31 AM (8 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35879556
Default Alt Text
D14581.id39934.diff (4 KB)

Event Timeline