Index: head/sys/cam/ata/ata_da.c =================================================================== --- head/sys/cam/ata/ata_da.c +++ head/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: head/sys/cam/cam_periph.h =================================================================== --- head/sys/cam/cam_periph.h +++ head/sys/cam/cam_periph.h @@ -37,6 +37,7 @@ #include #ifdef _KERNEL +#include #include #include @@ -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: head/sys/cam/cam_periph.c =================================================================== --- head/sys/cam/cam_periph.c +++ head/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: head/sys/cam/nvme/nvme_da.c =================================================================== --- head/sys/cam/nvme/nvme_da.c +++ head/sys/cam/nvme/nvme_da.c @@ -112,6 +112,12 @@ 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 @@ "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 @@ /* FALLTHROUGH */ case BIO_READ: { -#ifdef NDA_TEST_FAILURE +#ifdef CAM_TEST_FAILURE int fail = 0; /* Index: head/sys/cam/scsi/scsi_da.c =================================================================== --- head/sys/cam/scsi/scsi_da.c +++ head/sys/cam/scsi/scsi_da.c @@ -2203,6 +2203,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: head/sys/conf/NOTES =================================================================== --- head/sys/conf/NOTES +++ head/sys/conf/NOTES @@ -1356,6 +1356,7 @@ options SCSI_NO_OP_STRINGS options SCSI_DELAY=5000 # Be pessimistic about Joe SCSI device options CAM_IOSCHED_DYNAMIC +options CAM_TEST_FAILURE # Options for the CAM CDROM driver: # CHANGER_MIN_BUSY_SECONDS: Guaranteed minimum time quantum for a changer LUN Index: head/sys/conf/options =================================================================== --- head/sys/conf/options +++ head/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