├── io_delay.stp ├── io_error.stp ├── lib └── fij.stp └── scsi ├── License.txt ├── disk_rerr.stp ├── disk_rwerr.stp ├── lib └── scsi_fault_injection.stp ├── sector_rerr.stp ├── temporary_rerr.stp └── temporary_werr.stp /io_delay.stp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env stap 2 | 3 | /* 4 | * io_delay.stp Inject IO delay to the process 5 | * 6 | * stap io_delay.stp -I ./lib -DMAXSKIPPED=9999 -g -x pid type=3 delay_us=300 7 | */ 8 | 9 | global read_type = 1 10 | global write_type = 2 11 | global type = 3 12 | global start_us = 300 13 | global count = 0 14 | 15 | probe begin 16 | { 17 | fij_logger(0, "begin to delay IO"); 18 | 19 | fij_add_option("type", 3, "IO type to inject, read: 1, write: 2, (default: 3)") 20 | fij_add_option("delay_us", 300, "Delay time(us), (default 300)") 21 | fij_add_option("max_delay_us", 0, "Max delay time, if set, a random value in [delay_us, max_delay_us) will be chosen, (default 0)") 22 | } 23 | 24 | probe begin(2000) 25 | { 26 | type = fij_params["type"] 27 | start_us = fij_params["delay_us"] 28 | if (fij_params["max_delay_us"] > start_us) { 29 | count = fij_params["max_delay_us"] - start_us 30 | } 31 | } 32 | 33 | function delay() { 34 | udelay(randint(count) + start_us) 35 | } 36 | 37 | probe vfs.read.return 38 | { 39 | if ($return < 0) next 40 | 41 | if ((type & read_type == 0)) next 42 | 43 | if (fij_should_fail()) { 44 | delay() 45 | fij_done_fail() 46 | } 47 | } 48 | 49 | probe vfs.write.return 50 | { 51 | if ($return < 0) next 52 | 53 | if ((type & write_type == 0)) next 54 | 55 | if (fij_should_fail()) { 56 | delay() 57 | fij_done_fail() 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /io_error.stp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env stap 2 | 3 | /* 4 | * io_error.stp Inject IO error to the process 5 | * 6 | * stap io_error.stp -g -x pid [] [percent] [proc_name] 7 | * [] means to inject delay for read, write or read and write, default "rw". 8 | * [percent] is the injection probability, must be in [0, 100], default 1. 9 | * [proc_name] is the process name to be injected, if set, target pid will be ignored. 10 | */ 11 | 12 | global type = "rw" 13 | global percent = 1 14 | global proc_name = "" 15 | 16 | 17 | // include the common errors for the read and write. 18 | global write_error_codes 19 | global read_error_codes 20 | 21 | function init_errors() 22 | { 23 | write_error_codes[0] = 1 // EPERM 24 | write_error_codes[1] = 4 // EINTR 25 | write_error_codes[2] = 5 // EIO 26 | write_error_codes[3] = 9 // EBADF 27 | write_error_codes[4] = 22 // EINVAL 28 | write_error_codes[5] = 27 // EFBIG 29 | write_error_codes[6] = 28 // ENOSPC 30 | write_error_codes[7] = 122 // EDQUOT 31 | 32 | read_error_codes[0] = 4 // EINTR 33 | read_error_codes[1] = 5 // EIO 34 | read_error_codes[2] = 9 // EBADF 35 | read_error_codes[3] = 22 // EINVAL 36 | } 37 | 38 | probe begin 39 | { 40 | printf("begin to inject error to IO\n"); 41 | init_errors(); 42 | 43 | %( $# == 1 %? 44 | type = @1 45 | %) 46 | 47 | %( $# == 2 %? 48 | type = @1 49 | percent = $2 50 | %) 51 | 52 | %( $# == 3 %? 53 | type = @1 54 | percent = $2 55 | proc_name = @3 56 | %) 57 | } 58 | 59 | 60 | function is_target_skipped() { 61 | if (proc_name != "") { 62 | if (proc_name != pid2execname(pid())) { 63 | return 1 64 | } 65 | } else { 66 | if (target() != pid()) { 67 | return 1 68 | } 69 | } 70 | 71 | return 0 72 | } 73 | 74 | probe vfs.read.return 75 | { 76 | if (is_target_skipped() == 1) next 77 | 78 | // already error, return 79 | if ($return < 0) next 80 | 81 | if (type != "r" && type != "rw") next 82 | 83 | if (randint(100) >= percent) next 84 | 85 | $return = -read_error_codes[randint(4)] 86 | } 87 | 88 | probe vfs.write.return 89 | { 90 | if (is_target_skipped() == 1) next 91 | 92 | // already error, return 93 | if ($return < 0) next 94 | 95 | if (type != "w" && type != "rw") next 96 | 97 | if (randint(100) >= percent) next 98 | 99 | $return = -write_error_codes[randint(8)] 100 | } 101 | 102 | -------------------------------------------------------------------------------- /lib/fij.stp: -------------------------------------------------------------------------------- 1 | // Introduction 2 | // ------------ 3 | // 4 | // This tapset provides a framework to facilitate fault injections for 5 | // testing the kernel. The framework can be used by systemtap scripts to 6 | // actually inject faults. The framework processes the command line 7 | // arguments and controls the fault injection process. 8 | // 9 | // Following are the generic parameters used to set up the fault injection. 10 | // a) failtimes - maximum number of times the process can be failed 11 | // b) interval - number of successful hits between potential failures 12 | // c) probability - probability of potential failure 13 | // d) taskfilter - fail all processes or filter processes on pid 14 | // e) space - number of successful hits before the first failure 15 | // f) verbosity - control amount of output generated by the script 16 | // g) totaltime - duration of fault injection session 17 | // h) debug - print debug information for the script 18 | // i) pid - process IDs of processes to inject failures into. This can 19 | // also be specified using the -x option. 20 | // 21 | // These parameters are registered in the tapset using the fij_add_option() 22 | // function which also sets the script specific default values and provides help 23 | // text. The generic parameters are appended to the params[] array and can be 24 | // accessed using params["variable_name"]. If you doesn't specify any of the 25 | // parameters in command line, its default value is used. 26 | // Using fij_load_param(), your script can also assign script-specific default 27 | // values to generic parameters. 28 | // 29 | // You can define mandatory parameters, which are specific to the script depending 30 | // upon the kernel subsystem under test. These variables must necessarily be 31 | // specified on the command line during command execution. 32 | // E.g: device numbers, inode numbers etc which cannot be given default values. 33 | // 34 | // Such parameters can be registered using the fij_add_necessary_option() function. 35 | // On calling this function, the variable is appended to a mandatoryparams[] array. 36 | // If these parameters are not specified on the command line, an error is reported 37 | // and script is aborted. The variable can be accessed at params["variable_name"]. 38 | // 39 | // The framework controls the fault injection using fij_should_fail() and 40 | // fij_done_fail() functions. Your script should probe the relevant kernel 41 | // routine subjected to fault injection. The user-defined probe handler invokes 42 | // fij_should_fail(), which returns 1 if it's time to inject a failure, or 0 43 | // otherwise. Faults can be injected by your script in various ways like faking the 44 | // error return by changing the return value, by modifying data structures etc. 45 | // fij_done_fail() must be called immediately after fault injection to alert the 46 | // tapset of this. fij_done_fail() must not be called in case no fault was 47 | // injected. 48 | // 49 | // fij_logger() - This is a wrapper for the SystemTap log() function with an added 50 | // verbosity parameter. The message will be displayed only if the value of global 51 | // fij_verbosity is equal to or more than the parameter provided to the 52 | // function. 53 | // 54 | // 55 | // How to use the tapset 56 | // --------------------- 57 | // 58 | // 1) begin probe that adds user defined parameters and default values. 59 | // 2) Probes for fault injection. Call fij_should_fail() before injecting the 60 | // fault and fij_done_fail() after fault is injected. 61 | // 62 | // 63 | // Description of code flow 64 | // ------------------------ 65 | // 66 | // 1) begin(less than -1000) in the user script [OPTIONAL] - Preinitialization. 67 | // As of now, this is not necessary. 68 | // 69 | // 2) begin(-1000) in the tapset - This function initialises counters and 70 | // registers all generic parameters with global defaults. 71 | // 72 | // 3) begin in the user script - User defined default parameters are supplied 73 | // here. Also any script specific parameters are registered at this stage. 74 | // 75 | // 4) begin(1000) in the tapset - Command line arguments are parsed and 76 | // parameters assigned appropriate values. 77 | // 78 | // 5) begin(more than 1000) in the user script [OPTIONAL] - This can be used 79 | // to copy values of arguments from params[] array to local/global variables 80 | // for easy referencing. 81 | // 82 | // 6) Script starts executing. It is interrupted every 10 milliseconds to 83 | // check if script has run for the stipulated length of time. 84 | // 85 | // 7) When function/statement probes are hit, the script must invoke 86 | // fij_should_fail() function to check if the conditions for failure have been 87 | // satisfied. 88 | // 89 | // 8) Fail the function using suitable methods (changing return values, 90 | // setting fake values to variables...) 91 | // 92 | // 9) Call fij_done_fail() function to inform tapset that fault has been injected. 93 | // 94 | // 10) Script will exit either when script calls exit() function or when a 95 | // timeout is hit. At this point, stats of the experiment are printed. 96 | 97 | global fij_params //Array of all parameters. (except fij_pids_to_fail) 98 | global fij_paramshelp //Array of help information for all parameters 99 | global fij_mandatoryparams 100 | //Array of mandatory parameters 101 | 102 | global fij_pids_to_fail //Array of pids subject to fault injection 103 | global fij_failcount //Number of times failed so far 104 | global fij_probehits //Number of times the probe has been hit 105 | global fij_intervalcount 106 | //Number of successful probe hits 107 | global fij_aborted //Boolean value to check whether the fault injection 108 | //procedure needs to continue or not 109 | //Needed for help option 110 | 111 | global fij_failtimes 112 | global fij_verbosity 113 | global fij_debug 114 | global fij_taskfilter 115 | global fij_interval 116 | global fij_probability 117 | global fij_space 118 | global fij_totaltime 119 | 120 | global fij_elapsedtime 121 | 122 | 123 | function fij_add_process_to_fail(procid:long) 124 | { 125 | fij_logger(1, sprintf("Adding process %d to the fail list", procid)) 126 | fij_pids_to_fail[procid] = 1 127 | } 128 | 129 | /* 130 | * Add an option to the parameters list 131 | * This option can be provided on the command line as opt = value 132 | */ 133 | function fij_add_option(opt:string, defval, help:string) 134 | { 135 | fij_params[opt] = defval 136 | fij_paramshelp[opt] = help 137 | } 138 | 139 | /* 140 | * Add an option to the necessary parameters list 141 | * This option MUST be provided on the command line 142 | */ 143 | function fij_add_necessary_option(opt:string, help:string) 144 | { 145 | fij_mandatoryparams[opt] = 1 146 | fij_paramshelp[opt] = help 147 | } 148 | 149 | function fij_print_help() 150 | { 151 | fij_logger(0, "Usage : stap script.stp [ option1=value1 [ option2=value2 [ ...]]]") 152 | fij_logger(0, "Options : ") 153 | fij_logger(0, "\tpid\r\t\t\t\t : PID of a process to be failed. Use this option repeatedly to add multiple processes to fail") 154 | 155 | foreach (option in fij_params) { 156 | fij_logger(0, sprintf("\t%s\r\t\t\t\t : %s", option, 157 | fij_paramshelp[option])) 158 | } 159 | 160 | needed_options_counter = 0 161 | foreach (option in fij_mandatoryparams) { 162 | if (needed_options_counter == 0) { 163 | fij_logger(0, "Necessary options : ") 164 | needed_options_counter++ 165 | } 166 | fij_logger(0, sprintf("\t%s\r\t\t\t\t : %s", option, 167 | fij_paramshelp[option])) 168 | } 169 | 170 | fij_logger(0, "For help : stap script.stp help") 171 | fij_aborted = 1 172 | } 173 | 174 | function fij_process_argument(arg:string) 175 | { 176 | if (isinstr(arg, "=") == 1) { 177 | parameter=tokenize(arg, "=") 178 | value_in_str = tokenize("", "=") 179 | value = strtol(value_in_str, 10) 180 | if (parameter in fij_params) { 181 | fij_params[parameter] = value 182 | fij_logger(1, sprintf("Parameter %s is assigned value %d", 183 | parameter, fij_params[parameter])) 184 | } else if (parameter in fij_mandatoryparams) { 185 | fij_add_option(parameter, value, 186 | fij_paramshelp[parameter]) 187 | delete fij_mandatoryparams[parameter] 188 | } else if (parameter == "pid") { 189 | fij_add_process_to_fail(value) 190 | } else 191 | fij_logger(0, sprintf("WARNING : Argument %s is not found in parameter list. Ignoring..", parameter)) 192 | } 193 | else 194 | fij_logger(0, sprintf("WARNING : Invalid command line argument : %s", 195 | arg)) 196 | } 197 | 198 | function fij_show_params() 199 | { 200 | fij_logger(1, "Status of parameters :") 201 | foreach (option in fij_params) 202 | fij_logger(1, sprintf("Option %s has value %d", option, 203 | fij_params[option])) 204 | } 205 | 206 | /* 207 | * Parse command line arguments 208 | */ 209 | function fij_parse_command_line_args() 210 | { 211 | for (i = 1; i <= argc ; i++) { 212 | if (argv[i] == "help") { 213 | fij_print_help() 214 | return 0 215 | } else 216 | fij_process_argument(argv[i]) 217 | } 218 | 219 | foreach (parameter in fij_mandatoryparams) { 220 | fij_logger(0, sprintf("ERROR: Necessary command line parameter %s not specified", parameter)) 221 | fij_aborted = 1 222 | } 223 | } 224 | 225 | /* 226 | * Load script specific default parameters 227 | * This function is called by the script using this tapset to set custom 228 | * default values 229 | */ 230 | function fij_load_param(arg_times:long, arg_interval:long, arg_probability:long, 231 | arg_taskfilter:long, arg_space:long, arg_verbose:long, 232 | arg_totaltime:long) 233 | { 234 | fij_add_option("failtimes", arg_times, 235 | "Number of times to fail (0 = no limit)") 236 | fij_add_option("interval", arg_interval, "Number of successful hits between potential failures (0 to fail everytime)") 237 | fij_add_option("probability", arg_probability, 238 | "Probability of failure (1<=probability<=100) (0 to disable)") 239 | fij_add_option("taskfilter", arg_taskfilter, "0=>Fail all processes, 1=>Fail processes based on pid command line argument or -x option.") 240 | fij_add_option("space", arg_space, "Number of successful hits before the first failure (0 to disable)") 241 | fij_add_option("verbosity", arg_verbose, "0=>Success or Failure messages, 1=>Print parameter status, 2=>All probe hits, backtrace and register states") 242 | fij_add_option("totaltime", arg_totaltime, "Duration of fault injection session in milliseconds (0 = infinite)") 243 | } 244 | 245 | /* 246 | * Modified log function with an additional verbosity parameter 247 | * The message is printed only if the current fij_verbosity parameter 248 | * is greater than the minimum verbosity specified. Minverbosity value of 100 249 | * is reserved only for debugging the script. 250 | */ 251 | function fij_logger(minverbosity:long, msg:string) 252 | { 253 | if (fij_verbosity >= minverbosity) 254 | log(msg) 255 | else if (minverbosity == 100 && fij_debug == 1) 256 | log(msg) 257 | } 258 | 259 | /* 260 | * Checks whether the specified constraints for failure have been met 261 | * Returns 1 if process must be failed, else returns 0 262 | */ 263 | function fij_should_fail:long() 264 | { 265 | fij_probehits++ 266 | 267 | fij_logger(2, "Probe hit") 268 | 269 | if (fij_taskfilter != 0) { 270 | if(!(pid() in fij_pids_to_fail)) { 271 | fij_logger(100, sprintf("Skipping because wrong process %d - %s probed", 272 | pid(), execname())) 273 | return 0 274 | } else 275 | fij_logger(100, sprintf("Continuing with probing process %d - %s %d", 276 | pid(), execname(), target())) 277 | } 278 | 279 | if (fij_failcount == 0) { 280 | if (fij_space != 0) { 281 | if (fij_intervalcount < fij_space) { 282 | fij_logger(100, sprintf("Skipping on space : %d", 283 | fij_intervalcount)) 284 | fij_intervalcount++ 285 | return 0 286 | } else { 287 | fij_intervalcount = 0 288 | fij_logger(100, sprintf("Done skipping on space")) 289 | fij_space = 0 290 | } 291 | } 292 | } 293 | 294 | if (fij_failtimes != 0 && fij_failcount >= fij_failtimes) { 295 | fij_logger(100, sprintf("Failed %d times already. Skipping..", 296 | fij_failcount)) 297 | return 0 298 | } 299 | 300 | if (fij_interval != 0) { 301 | if (fij_intervalcount != 0) { 302 | fij_logger(100, sprintf("Skipping on interval : %d", 303 | fij_intervalcount)) 304 | fij_intervalcount++ 305 | fij_intervalcount %= fij_interval 306 | return 0 307 | } else 308 | fij_intervalcount++ 309 | } 310 | 311 | if (fij_probability != 0) { 312 | if (randint(100) > fij_probability) { 313 | fij_logger(100, sprintf("Skipping on probability")) 314 | return 0 315 | } else 316 | fij_logger(100, sprintf("Continuing on probability")) 317 | } 318 | 319 | return 1 320 | } 321 | 322 | /* 323 | * Post injection cleanup 324 | * This function MUST be called after the process has been failed 325 | */ 326 | function fij_done_fail() 327 | { 328 | fij_failcount++ 329 | fij_logger(0, sprintf("Failed process %d - %s", pid(), execname())) 330 | 331 | if (fij_params["verbosity"] >= 2 && fij_verbosity != 100) { 332 | print_backtrace() 333 | print_regs() 334 | } 335 | } 336 | 337 | function fij_display_stats() 338 | { 339 | fij_logger(0, sprintf("Probe was hit %d times.", fij_probehits)) 340 | fij_logger(0, sprintf("Function was failed %d times.", fij_failcount)) 341 | } 342 | 343 | /* 344 | * The first begin function 345 | * Initialises counters and adds generic parameters to the parameters list 346 | * In case the script requires a begin function to be executed prior to this, 347 | * parameter of less than -1000 must be specified to begin() 348 | */ 349 | probe begin(-1000) 350 | { 351 | fij_failcount = 0 352 | fij_probehits = 0 353 | fij_intervalcount = 0 354 | fij_aborted = 0 355 | 356 | fij_load_param(0, 0, 0, 0, 0, 0, 0) //Loading default values 357 | fij_add_option("debug", 0, "Display debug information. Requires verbosity=100") 358 | 359 | fij_mandatoryparams["initialize"] = 1; //Needed to register mandatory 360 | //params as an array 361 | delete fij_mandatoryparams["initialize"] 362 | } 363 | 364 | function check_taskfilter() { 365 | // If there is any pid to be failed, we should enable taskfilter by default. 366 | foreach (pid in fij_pids_to_fail limit 1) { 367 | fij_params["taskfilter"] = 1 368 | } 369 | } 370 | 371 | /* 372 | * The last begin function 373 | * Does parsing of command line arguments 374 | * In case the script requires a begin function to be executed after all 375 | * initialization, parameter of greater than 1000 must be specified to begin() 376 | * Eg: when you need to copy one of the fij_params[] options into a local variable 377 | * after parsing command line args 378 | */ 379 | probe begin(1000) 380 | { 381 | if (target()!=0) 382 | fij_add_process_to_fail(target()) 383 | 384 | fij_parse_command_line_args() 385 | 386 | check_taskfilter() 387 | 388 | fij_failtimes = fij_params["failtimes"] 389 | fij_interval = fij_params["interval"] 390 | fij_probability = fij_params["probability"] 391 | fij_taskfilter = fij_params["taskfilter"] 392 | fij_space = fij_params["space"] 393 | fij_verbosity = fij_params["verbosity"] 394 | fij_totaltime = fij_params["totaltime"] 395 | fij_debug = fij_params["debug"] 396 | 397 | if (fij_aborted) 398 | exit() 399 | else 400 | fij_show_params() 401 | } 402 | 403 | probe end 404 | { 405 | if (!fij_aborted) 406 | fij_display_stats() 407 | } 408 | 409 | //Check every 10 ms if the stipulated execution time has expired 410 | probe timer.ms(10) 411 | { 412 | fij_elapsedtime += 10 413 | if (fij_totaltime > 0 && fij_elapsedtime >= fij_totaltime) 414 | exit() 415 | } 416 | -------------------------------------------------------------------------------- /scsi/License.txt: -------------------------------------------------------------------------------- 1 | SCSI fault injection library using SystemTap isCopyright (C) 2007 NEC Corporation, 2 | Copyright(c) Information-technology Promotion Agency, Japan. 3 | 4 | The program is distributed under the following license. 5 | 6 | 7 | 8 | GNU GENERAL PUBLIC LICENSE 9 | Version 2, June 1991 10 | 11 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 12 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 13 | Everyone is permitted to copy and distribute verbatim copies 14 | of this license document, but changing it is not allowed. 15 | 16 | Preamble 17 | 18 | The licenses for most software are designed to take away your 19 | freedom to share and change it. By contrast, the GNU General Public 20 | License is intended to guarantee your freedom to share and change free 21 | software--to make sure the software is free for all its users. This 22 | General Public License applies to most of the Free Software 23 | Foundation's software and to any other program whose authors commit to 24 | using it. (Some other Free Software Foundation software is covered by 25 | the GNU Library General Public License instead.) You can apply it to 26 | your programs, too. 27 | 28 | When we speak of free software, we are referring to freedom, not 29 | price. Our General Public Licenses are designed to make sure that you 30 | have the freedom to distribute copies of free software (and charge for 31 | this service if you wish), that you receive source code or can get it 32 | if you want it, that you can change the software or use pieces of it 33 | in new free programs; and that you know you can do these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | anyone to deny you these rights or to ask you to surrender the rights. 37 | These restrictions translate to certain responsibilities for you if you 38 | distribute copies of the software, or if you modify it. 39 | 40 | For example, if you distribute copies of such a program, whether 41 | gratis or for a fee, you must give the recipients all the rights that 42 | you have. You must make sure that they, too, receive or can get the 43 | source code. And you must show them these terms so they know their 44 | rights. 45 | 46 | We protect your rights with two steps: (1) copyright the software, and 47 | (2) offer you this license which gives you legal permission to copy, 48 | distribute and/or modify the software. 49 | 50 | Also, for each author's protection and ours, we want to make certain 51 | that everyone understands that there is no warranty for this free 52 | software. If the software is modified by someone else and passed on, we 53 | want its recipients to know that what they have is not the original, so 54 | that any problems introduced by others will not reflect on the original 55 | authors' reputations. 56 | 57 | Finally, any free program is threatened constantly by software 58 | patents. We wish to avoid the danger that redistributors of a free 59 | program will individually obtain patent licenses, in effect making the 60 | program proprietary. To prevent this, we have made it clear that any 61 | patent must be licensed for everyone's free use or not licensed at all. 62 | 63 | The precise terms and conditions for copying, distribution and 64 | modification follow. 65 | 66 | GNU GENERAL PUBLIC LICENSE 67 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 68 | 69 | 0. This License applies to any program or other work which contains 70 | a notice placed by the copyright holder saying it may be distributed 71 | under the terms of this General Public License. The "Program", below, 72 | refers to any such program or work, and a "work based on the Program" 73 | means either the Program or any derivative work under copyright law: 74 | that is to say, a work containing the Program or a portion of it, 75 | either verbatim or with modifications and/or translated into another 76 | language. (Hereinafter, translation is included without limitation in 77 | the term "modification".) Each licensee is addressed as "you". 78 | 79 | Activities other than copying, distribution and modification are not 80 | covered by this License; they are outside its scope. The act of 81 | running the Program is not restricted, and the output from the Program 82 | is covered only if its contents constitute a work based on the 83 | Program (independent of having been made by running the Program). 84 | Whether that is true depends on what the Program does. 85 | 86 | 1. You may copy and distribute verbatim copies of the Program's 87 | source code as you receive it, in any medium, provided that you 88 | conspicuously and appropriately publish on each copy an appropriate 89 | copyright notice and disclaimer of warranty; keep intact all the 90 | notices that refer to this License and to the absence of any warranty; 91 | and give any other recipients of the Program a copy of this License 92 | along with the Program. 93 | 94 | You may charge a fee for the physical act of transferring a copy, and 95 | you may at your option offer warranty protection in exchange for a fee. 96 | 97 | 2. You may modify your copy or copies of the Program or any portion 98 | of it, thus forming a work based on the Program, and copy and 99 | distribute such modifications or work under the terms of Section 1 100 | above, provided that you also meet all of these conditions: 101 | 102 | a) You must cause the modified files to carry prominent notices 103 | stating that you changed the files and the date of any change. 104 | 105 | b) You must cause any work that you distribute or publish, that in 106 | whole or in part contains or is derived from the Program or any 107 | part thereof, to be licensed as a whole at no charge to all third 108 | parties under the terms of this License. 109 | 110 | c) If the modified program normally reads commands interactively 111 | when run, you must cause it, when started running for such 112 | interactive use in the most ordinary way, to print or display an 113 | announcement including an appropriate copyright notice and a 114 | notice that there is no warranty (or else, saying that you provide 115 | a warranty) and that users may redistribute the program under 116 | these conditions, and telling the user how to view a copy of this 117 | License. (Exception: if the Program itself is interactive but 118 | does not normally print such an announcement, your work based on 119 | the Program is not required to print an announcement.) 120 | 121 | These requirements apply to the modified work as a whole. If 122 | identifiable sections of that work are not derived from the Program, 123 | and can be reasonably considered independent and separate works in 124 | themselves, then this License, and its terms, do not apply to those 125 | sections when you distribute them as separate works. But when you 126 | distribute the same sections as part of a whole which is a work based 127 | on the Program, the distribution of the whole must be on the terms of 128 | this License, whose permissions for other licensees extend to the 129 | entire whole, and thus to each and every part regardless of who wrote it. 130 | 131 | Thus, it is not the intent of this section to claim rights or contest 132 | your rights to work written entirely by you; rather, the intent is to 133 | exercise the right to control the distribution of derivative or 134 | collective works based on the Program. 135 | 136 | In addition, mere aggregation of another work not based on the Program 137 | with the Program (or with a work based on the Program) on a volume of 138 | a storage or distribution medium does not bring the other work under 139 | the scope of this License. 140 | 141 | 3. You may copy and distribute the Program (or a work based on it, 142 | under Section 2) in object code or executable form under the terms of 143 | Sections 1 and 2 above provided that you also do one of the following: 144 | 145 | a) Accompany it with the complete corresponding machine-readable 146 | source code, which must be distributed under the terms of Sections 147 | 1 and 2 above on a medium customarily used for software interchange; or, 148 | 149 | b) Accompany it with a written offer, valid for at least three 150 | years, to give any third party, for a charge no more than your 151 | cost of physically performing source distribution, a complete 152 | machine-readable copy of the corresponding source code, to be 153 | distributed under the terms of Sections 1 and 2 above on a medium 154 | customarily used for software interchange; or, 155 | 156 | c) Accompany it with the information you received as to the offer 157 | to distribute corresponding source code. (This alternative is 158 | allowed only for noncommercial distribution and only if you 159 | received the program in object code or executable form with such 160 | an offer, in accord with Subsection b above.) 161 | 162 | The source code for a work means the preferred form of the work for 163 | making modifications to it. For an executable work, complete source 164 | code means all the source code for all modules it contains, plus any 165 | associated interface definition files, plus the scripts used to 166 | control compilation and installation of the executable. However, as a 167 | special exception, the source code distributed need not include 168 | anything that is normally distributed (in either source or binary 169 | form) with the major components (compiler, kernel, and so on) of the 170 | operating system on which the executable runs, unless that component 171 | itself accompanies the executable. 172 | 173 | If distribution of executable or object code is made by offering 174 | access to copy from a designated place, then offering equivalent 175 | access to copy the source code from the same place counts as 176 | distribution of the source code, even though third parties are not 177 | compelled to copy the source along with the object code. 178 | 179 | 4. You may not copy, modify, sublicense, or distribute the Program 180 | except as expressly provided under this License. Any attempt 181 | otherwise to copy, modify, sublicense or distribute the Program is 182 | void, and will automatically terminate your rights under this License. 183 | However, parties who have received copies, or rights, from you under 184 | this License will not have their licenses terminated so long as such 185 | parties remain in full compliance. 186 | 187 | 5. You are not required to accept this License, since you have not 188 | signed it. However, nothing else grants you permission to modify or 189 | distribute the Program or its derivative works. These actions are 190 | prohibited by law if you do not accept this License. Therefore, by 191 | modifying or distributing the Program (or any work based on the 192 | Program), you indicate your acceptance of this License to do so, and 193 | all its terms and conditions for copying, distributing or modifying 194 | the Program or works based on it. 195 | 196 | 6. Each time you redistribute the Program (or any work based on the 197 | Program), the recipient automatically receives a license from the 198 | original licensor to copy, distribute or modify the Program subject to 199 | these terms and conditions. You may not impose any further 200 | restrictions on the recipients' exercise of the rights granted herein. 201 | You are not responsible for enforcing compliance by third parties to 202 | this License. 203 | 204 | 7. If, as a consequence of a court judgment or allegation of patent 205 | infringement or for any other reason (not limited to patent issues), 206 | conditions are imposed on you (whether by court order, agreement or 207 | otherwise) that contradict the conditions of this License, they do not 208 | excuse you from the conditions of this License. If you cannot 209 | distribute so as to satisfy simultaneously your obligations under this 210 | License and any other pertinent obligations, then as a consequence you 211 | may not distribute the Program at all. For example, if a patent 212 | license would not permit royalty-free redistribution of the Program by 213 | all those who receive copies directly or indirectly through you, then 214 | the only way you could satisfy both it and this License would be to 215 | refrain entirely from distribution of the Program. 216 | 217 | If any portion of this section is held invalid or unenforceable under 218 | any particular circumstance, the balance of the section is intended to 219 | apply and the section as a whole is intended to apply in other 220 | circumstances. 221 | 222 | It is not the purpose of this section to induce you to infringe any 223 | patents or other property right claims or to contest validity of any 224 | such claims; this section has the sole purpose of protecting the 225 | integrity of the free software distribution system, which is 226 | implemented by public license practices. Many people have made 227 | generous contributions to the wide range of software distributed 228 | through that system in reliance on consistent application of that 229 | system; it is up to the author/donor to decide if he or she is willing 230 | to distribute software through any other system and a licensee cannot 231 | impose that choice. 232 | 233 | This section is intended to make thoroughly clear what is believed to 234 | be a consequence of the rest of this License. 235 | 236 | 8. If the distribution and/or use of the Program is restricted in 237 | certain countries either by patents or by copyrighted interfaces, the 238 | original copyright holder who places the Program under this License 239 | may add an explicit geographical distribution limitation excluding 240 | those countries, so that distribution is permitted only in or among 241 | countries not thus excluded. In such case, this License incorporates 242 | the limitation as if written in the body of this License. 243 | 244 | 9. The Free Software Foundation may publish revised and/or new versions 245 | of the General Public License from time to time. Such new versions will 246 | be similar in spirit to the present version, but may differ in detail to 247 | address new problems or concerns. 248 | 249 | Each version is given a distinguishing version number. If the Program 250 | specifies a version number of this License which applies to it and "any 251 | later version", you have the option of following the terms and conditions 252 | either of that version or of any later version published by the Free 253 | Software Foundation. If the Program does not specify a version number of 254 | this License, you may choose any version ever published by the Free Software 255 | Foundation. 256 | 257 | 10. If you wish to incorporate parts of the Program into other free 258 | programs whose distribution conditions are different, write to the author 259 | to ask for permission. For software which is copyrighted by the Free 260 | Software Foundation, write to the Free Software Foundation; we sometimes 261 | make exceptions for this. Our decision will be guided by the two goals 262 | of preserving the free status of all derivatives of our free software and 263 | of promoting the sharing and reuse of software generally. 264 | 265 | NO WARRANTY 266 | 267 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 268 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 269 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 270 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 271 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 272 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 273 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 274 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 275 | REPAIR OR CORRECTION. 276 | 277 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 278 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 279 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 280 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 281 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 282 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 283 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 284 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 285 | POSSIBILITY OF SUCH DAMAGES. 286 | 287 | END OF TERMS AND CONDITIONS 288 | 289 | How to Apply These Terms to Your New Programs 290 | 291 | If you develop a new program, and you want it to be of the greatest 292 | possible use to the public, the best way to achieve this is to make it 293 | free software which everyone can redistribute and change under these terms. 294 | 295 | To do so, attach the following notices to the program. It is safest 296 | to attach them to the start of each source file to most effectively 297 | convey the exclusion of warranty; and each file should have at least 298 | the "copyright" line and a pointer to where the full notice is found. 299 | 300 | 301 | Copyright (C) 302 | 303 | This program is free software; you can redistribute it and/or modify 304 | it under the terms of the GNU General Public License as published by 305 | the Free Software Foundation; either version 2 of the License, or 306 | (at your option) any later version. 307 | 308 | This program is distributed in the hope that it will be useful, 309 | but WITHOUT ANY WARRANTY; without even the implied warranty of 310 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 311 | GNU General Public License for more details. 312 | 313 | You should have received a copy of the GNU General Public License 314 | along with this program; if not, write to the Free Software 315 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 316 | 317 | 318 | Also add information on how to contact you by electronic and paper mail. 319 | 320 | If the program is interactive, make it output a short notice like this 321 | when it starts in an interactive mode: 322 | 323 | Gnomovision version 69, Copyright (C) year name of author 324 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 325 | This is free software, and you are welcome to redistribute it 326 | under certain conditions; type `show c' for details. 327 | 328 | The hypothetical commands `show w' and `show c' should show the appropriate 329 | parts of the General Public License. Of course, the commands you use may 330 | be called something other than `show w' and `show c'; they could even be 331 | mouse-clicks or menu items--whatever suits your program. 332 | 333 | You should also get your employer (if you work as a programmer) or your 334 | school, if any, to sign a "copyright disclaimer" for the program, if 335 | necessary. Here is a sample; alter the names: 336 | 337 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 338 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 339 | 340 | , 1 April 1989 341 | Ty Coon, President of Vice 342 | 343 | This General Public License does not permit incorporating your program into 344 | proprietary programs. If your program is a subroutine library, you may 345 | consider it more useful to permit linking proprietary applications with the 346 | library. If this is what you want to do, use the GNU Library General 347 | Public License instead of this License. 348 | -------------------------------------------------------------------------------- /scsi/disk_rerr.stp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env stap 2 | 3 | # SCSI fault injection library using SystemTap 4 | # Copyright (C) 2007 NEC Corporation 5 | # Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2007. 6 | # Result of Open Source Software Development Activities of 7 | # Information-technology Promotion Agency, Japan. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | # 23 | 24 | probe begin 25 | { 26 | dev_major = $1 27 | dev_minor_min = $2 28 | dev_minor_max = $3 29 | inode_lba_flag = $4 30 | inode_lba_val = $5 31 | error_type = 1 32 | access_type = 2 33 | timeout_flag = 0 34 | } 35 | 36 | probe end 37 | { 38 | printf("\nDONE\n") 39 | } 40 | 41 | -------------------------------------------------------------------------------- /scsi/disk_rwerr.stp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env stap 2 | 3 | # SCSI fault injection library using SystemTap 4 | # Copyright (C) 2007 NEC Corporation 5 | # Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2007. 6 | # Result of Open Source Software Development Activities of 7 | # Information-technology Promotion Agency, Japan. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | # 23 | 24 | probe begin 25 | { 26 | dev_major = $1 27 | dev_minor_min = $2 28 | dev_minor_max = $3 29 | inode_lba_flag = $4 30 | inode_lba_val = $5 31 | error_type = 1 32 | access_type = 3 33 | } 34 | 35 | probe end 36 | { 37 | printf("\nDONE\n") 38 | } 39 | 40 | -------------------------------------------------------------------------------- /scsi/lib/scsi_fault_injection.stp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env stap 2 | 3 | # SCSI fault injection library using SystemTap 4 | # Copyright (C) 2007 NEC Corporation 5 | # Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2007. 6 | # Result of Open Source Software Development Activities of 7 | # Information-technology Promotion Agency, Japan. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | # 23 | 24 | %{ 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | %} 35 | 36 | global target_access 37 | global target_scmd 38 | global target_rq 39 | global target_bio 40 | global target_r1bio 41 | global target_block 42 | global fix_write 43 | global temp_failure 44 | 45 | global error_type 46 | global access_type 47 | global dev_major 48 | global dev_minor_min 49 | global dev_minor_max 50 | global inode_lba_flag 51 | global inode_lba_val 52 | global timeout_flag 53 | global retry_allowed 54 | global target_minor 55 | 56 | 57 | probe begin 58 | { 59 | target_block = -1 60 | target_minor = -1 61 | printf("\nBEGIN\n") 62 | } 63 | 64 | 65 | function set_sense_buf:long (cmd:long, result:long, sensekey:long, asc:long, ascq:long ) 66 | %{ 67 | struct scsi_cmnd * scmd = (struct scsi_cmnd *)(long)STAP_ARG_cmd; 68 | 69 | scmd->result = (int)(long)STAP_ARG_result; 70 | scmd->sense_buffer[0] = 0x70; /* current, fixed format */ 71 | scmd->sense_buffer[2] = (unsigned char)(long)STAP_ARG_sensekey; 72 | scmd->sense_buffer[7] = 0x13; /* length */ 73 | scmd->sense_buffer[12] = (unsigned char)(long)STAP_ARG_asc; 74 | scmd->sense_buffer[13] = (unsigned char)(long)STAP_ARG_ascq; 75 | %} 76 | 77 | function get_inode:long (page:long) 78 | %{ 79 | struct page * thispage = (struct page *)(long)STAP_ARG_page; 80 | unsigned long tempval = (unsigned long)thispage->flags; 81 | struct address_space *mapping = thispage->mapping; 82 | 83 | if (unlikely(PageSwapCache(thispage))) 84 | mapping = NULL; 85 | #ifdef CONFIG_SLUB 86 | else if (unlikely(PageSlab(thispage))) 87 | mapping = NULL; 88 | #endif 89 | else if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON)) 90 | mapping = NULL; 91 | 92 | if((mapping != NULL) && (mapping->host != NULL)) 93 | { 94 | STAP_RETVALUE = (unsigned long)(mapping->host->i_ino); 95 | } else { 96 | STAP_RETVALUE = 0; 97 | } 98 | %} 99 | 100 | 101 | probe kernel.function("scsi_decide_disposition@drivers/scsi/scsi_error.c") 102 | { 103 | scmd_direction = $scmd->sc_data_direction 104 | 105 | if((((temp_failure == 1) || (error_type == 1)) && (target_scmd == $scmd)) && ((scmd_direction == access_type) || (access_type == 3) || ((scmd_direction == 2) && (access_type== 4))) && ($scmd->request->rq_disk != 0)) 106 | { 107 | major = $scmd->request->rq_disk->major 108 | minor = $scmd->request->rq_disk->first_minor 109 | block = $scmd->request->__sector 110 | req_len = $scmd->request->__data_len 111 | 112 | if(major == dev_major && minor == target_minor && ((block == target_block) || ((block <= target_block) && (target_block < block + (req_len >> 9))))) 113 | { 114 | if((scmd_direction == 2) && (fix_write == 2)) 115 | { 116 | #fix_write = 0 117 | } else 118 | { 119 | printf("scsi_decide_disposition : major=%d minor=%d scmd=%d \n",major, minor, $scmd) 120 | /* create fake status and sense data */ 121 | temp_failure++ 122 | set_sense_buf($scmd, 0x02, 0x03, 0x11, 0x04) 123 | } 124 | } 125 | } 126 | } 127 | 128 | probe kernel.function("scsi_next_command@drivers/scsi/scsi_lib.c") 129 | { 130 | if((target_access != 0) && (target_scmd == $cmd)) 131 | { 132 | printf("scsi_next_command : cmd = %d \n", $cmd) 133 | target_access = 0 134 | target_scmd = 0 135 | target_rq = 0 136 | restore_state = 0 137 | } 138 | } 139 | 140 | probe kernel.function("scsi_dispatch_cmd@drivers/scsi/scsi.c") 141 | { 142 | struct_bio= $cmd->request->bio 143 | block = $cmd->request->__sector 144 | req_len = $cmd->request->__data_len 145 | 146 | if($cmd->request->rq_disk != 0) 147 | { 148 | major = $cmd->request->rq_disk->major 149 | minor = $cmd->request->rq_disk->first_minor 150 | } 151 | 152 | if(target_block == -1) 153 | { 154 | if(struct_bio != 0) 155 | { 156 | page = $cmd->request->bio->bi_io_vec->bv_page 157 | if(page != 0) 158 | { 159 | inode = get_inode(page) 160 | } 161 | } 162 | } 163 | 164 | if(((inode_lba_flag ==1)&&(inode == inode_lba_val)) || ((inode_lba_flag ==0 ) && ((block <= inode_lba_val) && (inode_lba_val < block + (req_len >> 9)))) || (block == target_block) || ((block <= target_block) && (target_block < block + (req_len >> 9)))) 165 | { 166 | printf("\nSCSI_DISPATCH_CMD: command= %d \n", $cmd->cmnd[0]) 167 | printf("SCSI_DISPATCH_CMD: major= %d minor= %d \n", major, minor) 168 | printf("SCSI_DISPATCH_CMD: flag(0:LBA, 1:inode)= %d \n", inode_lba_flag) 169 | printf("SCSI_DISPATCH_CMD: start sector= %d \n", $cmd->request->__sector) 170 | printf("SCSI_DISPATCH_CMD: req bufflen= %d \n", $cmd->request->__data_len) 171 | printf("SCSI_DISPATCH_CMD: inode= %d \n", inode) 172 | printf("SCSI_DISPATCH_CMD: scmd = %d \n", $cmd) 173 | printf("SCSI_DISPATCH_CMD: [7]=%d [8]=%d \n", $cmd->cmnd[7],$cmd->cmnd[8]) 174 | 175 | if((target_minor== -1) && (major == dev_major) && ((dev_minor_min & 0xfff0) <= minor) && (minor <= (dev_minor_max & 0xfff0))) 176 | { 177 | tmp_minor = minor 178 | } 179 | 180 | if((major == dev_major && ((minor == tmp_minor) || (minor == target_minor))) && (fix_write != 2)) 181 | { 182 | /* inject errors on the designated device */ 183 | printf("SCSI_DISPATCH_CMD: cmd-retries = %d entire-retry =%d \n", $cmd->retries, entire_retries) 184 | cmd_direction = $cmd->sc_data_direction 185 | if((cmd_direction == 1) && (access_type == 4)) 186 | { 187 | fix_write = 2 188 | printf("SCSI_DISPATCH_CMD: fix_write =%d \n", fix_write) 189 | } 190 | 191 | if((temp_failure == 0) || (error_type == 1) ||((timeout_flag == 1) && (entire_retries <= retry_allowed))) 192 | { 193 | if((cmd_direction == access_type) || ((cmd_direction == 2) && (access_type == 4)) || (access_type == 3)) 194 | { 195 | if(target_minor == -1) 196 | { 197 | target_minor = tmp_minor 198 | } 199 | 200 | if(target_block == -1) 201 | { 202 | target_block = block 203 | } 204 | 205 | if(target_access == 0) 206 | { 207 | retry_allowed = $cmd->allowed 208 | target_access++ 209 | target_scmd = $cmd 210 | target_rq = $cmd->request 211 | } 212 | 213 | temp_failure++ 214 | 215 | if(($cmd->cmnd[0] == 0x28) || ($cmd->cmnd[0] == 0x2a)) 216 | { 217 | /* read_10 or write_10 */ 218 | $cmd->cmnd[7]=0 219 | $cmd->cmnd[8]=0 220 | }else if(($cmd->cmnd[0] == 0x08) || ($cmd->cmnd[0] == 0x0a)) 221 | { 222 | /* read_16 or write_16 */ 223 | $cmd->cmnd[10]=0 224 | $cmd->cmnd[11]=0 225 | $cmd->cmnd[12]=0 226 | $cmd->cmnd[13]=0 227 | }else if(($cmd->cmnd[0] == 0x08) || ($cmd->cmnd[0] == 0x0a)) 228 | { 229 | /* read_6 or write_6 */ 230 | $cmd->cmnd[4]=0 231 | } 232 | 233 | if(target_scmd == $cmd) 234 | { 235 | entire_retries++ 236 | } 237 | 238 | if((target_access_t == 0) && (timeout_flag == 1)) 239 | { 240 | target_access_t++ 241 | global_scmd = $cmd 242 | restore_state = $cmd->device->host->shost_state 243 | $cmd->device->host->shost_state = 4 244 | } 245 | } 246 | } 247 | 248 | printf("\nSCSI_DISPATCH_CMD: cmd= %d, allowed = %d retries= %d \n", $cmd, $cmd->allowed, $cmd->retries) 249 | printf("SCSI_DISPATCH_CMD:scsi_cmnd= %d (host,channel,id,lun)= (%d, %d, %d, %d) \n", $cmd, $cmd->device->host->host_no, $cmd->device->channel, $cmd->device->id, $cmd->device->lun) 250 | printf("SCSI_DISPATCH_CMD:execname=%s, pexecname=%s\n", execname(), pexecname()) 251 | } 252 | } 253 | } 254 | 255 | -------------------------------------------------------------------------------- /scsi/sector_rerr.stp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env stap 2 | 3 | # SCSI fault injection library using SystemTap 4 | # Copyright (C) 2007 NEC Corporation 5 | # Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2007. 6 | # Result of Open Source Software Development Activities of 7 | # Information-technology Promotion Agency, Japan. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | # 23 | 24 | probe begin 25 | { 26 | dev_major = $1 27 | dev_minor_min = $2 28 | dev_minor_max = $3 29 | inode_lba_flag = $4 30 | inode_lba_val = $5 31 | error_type = 1 32 | access_type = 4 33 | } 34 | 35 | probe end 36 | { 37 | printf("\nDONE\n") 38 | } 39 | 40 | -------------------------------------------------------------------------------- /scsi/temporary_rerr.stp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env stap 2 | 3 | # SCSI fault injection library using SystemTap 4 | # Copyright (C) 2007 NEC Corporation 5 | # Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2007. 6 | # Result of Open Source Software Development Activities of 7 | # Information-technology Promotion Agency, Japan. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | # 23 | 24 | probe begin 25 | { 26 | dev_major = $1 27 | dev_minor_min = $2 28 | dev_minor_max = $3 29 | inode_lba_flag = $4 30 | inode_lba_val = $5 31 | error_type = 0 32 | access_type = 2 33 | } 34 | 35 | probe end 36 | { 37 | printf("\nDONE\n") 38 | } 39 | -------------------------------------------------------------------------------- /scsi/temporary_werr.stp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env stap 2 | 3 | # SCSI fault injection library using SystemTap 4 | # Copyright (C) 2007 NEC Corporation 5 | # Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2007. 6 | # Result of Open Source Software Development Activities of 7 | # Information-technology Promotion Agency, Japan. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | # 23 | 24 | probe begin 25 | { 26 | dev_major = $1 27 | dev_minor_min = $2 28 | dev_minor_max = $3 29 | inode_lba_flag = $4 30 | inode_lba_val = $5 31 | error_type = 0 32 | access_type = 1 33 | } 34 | 35 | probe end 36 | { 37 | printf("\nDONE\n") 38 | } 39 | 40 | --------------------------------------------------------------------------------