scsi_debug: inject recovered errors
Hi Doug,
this patch allows to inject recovered errors with scsi_debug, to see whether sd handles them correctly.
Attached patch is a port to scsi_debug as in 2.4.20. (I used 2.4.19 for testing.)
It has been for verifying that the fix for recovered error sense (without valid bit) actually works.
Regards,
Signature · 4 lines
Kurt Garloff <[email protected]> [Eindhoven, NL] Physics: Plasma simulations <[email protected]> [TU Eindhoven, NL] Linux: SCSI, Security <[email protected]> [SuSE Nuernberg, DE] (See mail header or public key servers for PGP2 and GPG public keys.)
drivers/scsi/scsi_debug.c +16 -0
@@ -80,6 +80,8 @@static int scsi_debug_every_nth =DEF_EVERY_NTH ;static int scsi_debug_cmnd_count =0 ;static int scsi_debug_delay =DEF_DELAY ; +static int scsi_debug_inj_rec_err =0 ; +#define NR_HOSTS_PRESENT (((scsi_debug_num_devs - 1) / 7) + 1)#define N_HEAD 8
@@ -324,6 +326,12 @@ num = cmd[4 ]; } errsts =resp_read (SCpnt, upper_blk, block, num, devip); +if (scsi_debug_inj_rec_err && !(SCpnt->pid % scsi_debug_inj_rec_err)) { + SCpnt->result = (COMMAND_COMPLETE <<8 ) | + (CHECK_CONDITION <<1 ); +mk_sense_buffer (devip,RECOVERED_ERROR ,0x5d ,0 ,14 ); + }else + SCpnt->result =0 ;break ;case REPORT_LUNS : errsts =resp_report_luns (cmd, buff, bufflen, devip);
@@ -361,6 +369,12 @@case MODE_SENSE :case MODE_SENSE_10 : errsts =resp_mode_sense (cmd, target, buff, bufflen, devip); +if (scsi_debug_inj_rec_err && !(SCpnt->pid % scsi_debug_inj_rec_err)) { + SCpnt->result = (COMMAND_COMPLETE <<8 ) | + (CHECK_CONDITION <<1 ); +mk_sense_buffer (devip,RECOVERED_ERROR ,0x5d ,0 ,14 ); + }else + SCpnt->result =0 ;break ;default :#if 0
@@ -1160,6 +1174,8 @@MODULE_PARM_DESC (scsi_debug_every_nth,"timeout every nth command(def=100)" );MODULE_PARM (scsi_debug_delay,"i" );MODULE_PARM_DESC (scsi_debug_delay,"# of jiffies to delay response(def=1)" ); +MODULE_PARM (scsi_debug_inj_rec_err,"i" ); +MODULE_PARM_DESC (scsi_debug_inj_rec_err,"inject recovered errors every N read/write command" );#ifdef MODULE_LICENSE MODULE_LICENSE ("GPL" );#endif