Existe muita infraestrutura útil de injeção de falhas no Linux. Um deles pode ser útil para seus esforços de teste.
A página 7 desta apresentação mostra um exemplo de falsificação de um problema de dispositivo de bloco com dmsetup
.
O próprio md (4) tem um modo chamado FAULTY
que você pode usar para simular leitura / gravação erros.
Faulty
The FAULTY md module is provided for testing purposes. A faulty array has exactly one component device and is normally assembled without a superblock, so the md array created provides direct access to all of the data in the component device.
The FAULTY module may be requested to simulate faults to allow testing of other md levels or of filesystems. Faults can be chosen to trigger on read requests or write requests, and can be transient (a subsequent read/write at the address will probably succeed) or persistent (subsequent read/write of the same address will fail). Further, read faults can be "fixable" meaning that they persist until a write request at the same address.
Fault types can be requested with a period. In this case, the fault will recur repeatedly after the given number of requests of the relevant type. For example if persistent read faults have a period of 100, then every 100th read request would generate a fault, and the faulty sector would be recorded so that subsequent reads on that sector would also fail.
There is a limit to the number of faulty sectors that are remembered. Faults generated after this limit is exhausted are treated as transient.
The list of faulty sectors can be flushed, and the active list of failure modes can be cleared.
As opções que o controlam estão listadas em mdadm (8) em -p, --layout=
.
When setting the failure mode for level faulty, the options are: write-transient, wt, read-transient, rt, write-persistent, wp, read-persistent, rp, write-all, read-fixable, rf, clear, flush, none.
Each failure mode can be followed by a number, which is used as a period between fault generation. Without a number, the fault is generated once on the first relevant request. With a number, the fault will be generated after that many requests, and will continue to be generated every time the period elapses.
Multiple failure modes can be current simultaneously by using the --grow option to set subsequent failure modes.
"clear" or "none" will remove any pending or periodic failure modes, and "flush" will clear any persistent faults.
Há exemplos dos arquivos da lista de correspondências linux-raid
na injeção de erros Isso deve ajudá-lo a começar com as opções de injeção de falhas md também. =)