Simulate a Faulty Block Device with Read Errors

Simulate a faulty block device with read errors?

It's not a loopback device you're looking for, but rather device-mapper.

Use dmsetup to create a device backed by the "error" target. It will show up in /dev/mapper/<name>.

Page 7 of the Device mapper presentation (PDF) has exactly what you're looking for:

dmsetup create bad_disk << EOF
0 8 linear /dev/sdb1 0
8 1 error
9 204791 linear /dev/sdb1 9
EOF

Or leave out the sdb1 parts to and put the "error" target as the device for blocks 0 - 8 (instead of sdb1) to make a pure error disk.

See also The Device Mapper appendix from "RHEL 5
Logical Volume Manager Administration".


There's also a flakey target - a combo of linear and error that sometimes succeeds. Also a delay to introduce intentional delays for testing.

Git test to download without saving

If you have enough RAM, a ramdisk would work.

If space is an issue, possibly you could have another process deleting stuff from the ramdisk as files / directories appear, if the CPU load of scanning for them (or waiting with a notify) doesn't interfere. A fresh GIT clone might be mostly one big file so that doesn't help.



If you were using Linux instead of Windows, there are a lot of cool tricks you could use

Some of these might have Windows equivalents but I don't know what they are. Some of these might not be viable on Linux either.

On Linux, you could write a program that listens with inotify for files to be created, then uses ftruncate to discard their written blocks. Like an SSD TRIM operation, but on a file in a filesystem, punching holes in it (making it sparse) so the filesystem doesn't need to store those blocks.

You'd do this on a tmpfs filesystem, like /tmp often is; it's the go-to low-overhead Linux ramdisk-like filesystem that doesn't use a block-device at all, really just the kernel's in-memory VFS caching infrastructure.

(Windows of course makes it inconvenient to open a file while another process has it open for writing.)

Or on Linux, you could use a device-mapper virtual device with some real storage (a ramdisk) and a larger region backed by a "discard" or "zero" device that just throws away writes. (Like Simulate a faulty block device with read errors? but with a "zero" instead of "error" device, or linear with /dev/zero). Some filesystem types might be able to mkfs and mount on such a filesystem, although reading back as all zeros might crash / panic a lot of filesystems, if any metadata ever gets evicted from RAM and read back.

Or if you use a filesystem like XFS or BTRFS that can put metadata on one device, file contents on another device, you could put the metadata on a ramdisk and the file data on /dev/zero (discard writes, reads as zero). (The intended use-case is for metadata on fast RAID10 of fast disks or SSDs, data on a slower RAID5 or RAID6, especially of lower-RPM spinning rust.)

A FUSE (FS in User-Space) filesystem could probably also do this, maybe even selectively filtering files by name to have their data discarded or kept, so GIT wouldn't break if it tried to read back its data. Or keeping the first 16kiB of every file, so headers / file types can be read back. FUSE is extra filesystem overhead, though.

Simulating bad sectors in Linux

This is way beyond my knowledge-base, but you may find this discussion useful. They are talking about using hdparm and the --make-bad-sector option. Buyer beware....

Another interesting discussion is this one, which talks about the difference between actually having a bad sector and manually creating one -- depending on what tools you are testing, these two may be registered and/or treated differently?

In any case, the most relevant things I found online were from the forums at hddguru, so chances are the folks over there might have some good input for you :)

Hope that helps with something...

How to programmatically simulate file corruption to test ReFS Health Check and Recovery features?

To create corruption, use the destructive write test within Hard Disk Sentinel Pro. Set it to work randomly rather than sequentially. I set it to write random patterns of bits. Just run it for one to three minutes, and you’ll see on the displayed map a whole bunch of spots all over the drive getting destroyed.

Here’s how I did some testing (I’m typing fast so I hope I don’t leave something out)

  1. Nearly fill an ReFS mirrored storage space with files.

  2. Enable file integrity for all the files:

    Get-ChildItem -Path ‘i:*’ -Recurse | Set-FileIntegrity -Enable $True -Enforce $False

We do another test later with Enforce $True, but do the false one first. You’ll see why later. Read up on Enable and Enforce.


  1. Remove one of the drives and attach it to a SATA port on a second computer.
  2. On that second computer, introduce file corruption with Hard Disk Sentinel
  3. Remove the corrupted drive and put it back in the first computer with the storage space. You will now have a mirrored storage space where one drive is okay and one has a bunch of corrupted files.

Try a mass copy of all the files from the storage space over to some other drive.

My tests show that almost nothing gets repaired and almost nothing shows up in the event log. Maybe one or two errors and that’s it. You might think perhaps not much was corrupted in the first place. Well now set Enforce $True and do the copy operation again. With Enforce on, the copy will stop at dozens of files with checksum errors---proving that ReFS in that case is looking at checksums.

Problem is that again almost nothing shows up in the log. Also, with Enforce on, I got a checksum error on the one file that had supposedly been fixed during the first test with Enforce off!

Check these threads:

Why Use ReFS?

ReFS test with corrupt data. Does it work

Has anyone run the Data Integrity Scan on an ReFS volume?

ReFS/Storage Spaces does log a problem from time to time and people see that so they just assume it works great. Also, folks can't find a good way to create test corruption so they don't bother testing. I tested on the Windows 10 Pro for Workstations SKU and the results are terrible.

Please run some tests yourself to confirm my findings.

I can't simulate a CPLEX model even when the code has no errors

Let me help you with the syntax.

In the .mod

Comment:

//int capacity [truck]=...; // capacity of a truck

since that's not defined in the .dat, and write:

float cost [arcs][truck]=...;

since that one is in the .dat.

The .dat should be changed into:

trucks= 2;

departurenode= {<A,0,10000,0>,<B,0,10000,0>,<C,0,10000,10>,<D,0,10000,10>};

arrivalnode= {<A,0,10000,0>,<B,0,10000,0>,<C,0,10000,10>,<D,0,10000,10>};

startingnode={<A,0,10000,0>,<B,0,10000,0>,<C,0,10000,10>,<D,0,10000,10>};

arcs= {<<A,0,10000,0>,<A,0,10000,0>,<C,0,10000,10>,5>, <<A,0,10000,0>,<A,0,10000,0>,<D,0,10000,10>,5>,
<<B,0,10000,0>,<B,0,10000,0>,<C,0,10000,10>,5>, <<B,0,10000,0>,<B,0,10000,0>,<D,0,10000,10>,5>,
<<C,0,10000,0>,<C,0,10000,0>,<A,0,10000,10>,5>, <<C,0,10000,0>,<C,0,10000,0>,<B,0,10000,10>,5>,
<<D,0,10000,0>,<D,0,10000,0>,<A,0,10000,10>,5>, <<D,0,10000,0>,<D,0,10000,0>,<B,0,10000,10>,5>};

cost= [[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1]];

and then you will be able to run and then improve.

How does read error in swap partition affect a running process?

"Poison" patch should handle your case: https://lwn.net/Articles/348886/

Dirty pages in the swap cache are handled in a delayed fashion. The
dirty flag is cleared for the page and the page swap cache entry is
maintained. On a later page fault the associated application will be
killed.



Related Topics



Leave a reply



Submit