One can write more blocks per pass in order to reduce
the total number of passes.
Trading resets for writes is effective when writing blocks is
cheaper than reseting the device being probed.
This patch dynamically balances the number of writes and
resets while probing.
The effectiveness of this balance is shown below:
A good 256MB drive produced the following measurements:
Probe time: 2.89 seconds
Probe read op: count=64, total time=0.13s, avg op time=2.06ms
Probe write op: count=48, total time=1.41s, avg op time=29.47ms
Probe reset op: count=8, total time=1.35s, avg op time=168.48ms
The results from previous commit (see git log):
Probe time: 47.57 seconds
Probe read op: count=2014, total time=1.72s, avg op time=0.85ms
Probe write op: count=2003, total time=45.32s, avg op time=22.62ms
Probe reset op: count=3, total time=0.53s, avg op time=175.66ms
Moreover, this patch spaces more uniformly
the blocks write_test_blocks() writes to improve
the effectiveness of each pass.
In order to reduce probing time, one needs to time
reads, writes, and resets to evaluate how to change
the probing algorithm.
This patch adds these measurements.
A good 256MB drive produced the following measurements:
Probe time: 47.57 seconds
Probe read op: count=2014, total time=1.72s, avg op time=0.85ms
Probe write op: count=2003, total time=45.32s, avg op time=22.62ms
Probe reset op: count=3, total time=0.53s, avg op time=175.66ms
Of all three operations called on the flash drive being probed
(i.e. reading blocks, writing blocks, and resetting the drive),
the most time-consuming operation is reliably resetting the drive.
This patch reduces the number of resets writing and reading
more blocks.
This option instructs f3probe to trade speed for less memory usage,
that is, f3probe minimizes use of memory.
Currently, this option only drops the use of the bitmap of
the safe device.
Nevertheless, this is not negligible memory.
For example, a 1TB drive whose block size is 512 Bytes requires
256MB of RAM for this bitmap:
1TB / 512Byte/Block = 2^31Block
2^31Block / 1Block/bit = 2^31bit
2^31bit / 8bit/Byte = 2^28Byte = 256MB
To put it in context, 256MB of RAM was all that
Raspberry Pi Model A had.
The current reset method isn't supported for all USB drives,
what leads to wrong conclusions about some fake drives.
The option --manual-reset allows users to unplug and plug back
the USB drive being tested to manually reset the drive.
This patch makes f3probe read and save in memory
the content of all written blocks before writting them
during the probe, and restore the original content of those blocks
after probing the device.
In order words, f3probe behaves likes the probed device were
read only.
All the necessary memory to protect the probed device is
preallocated, so an on-going probe does not fail due to
lack of memory.
Although this feature adds an important protection layer,
users should be conscious that things can go wrong, and
the data will be lost.
This patch also adds option --debug-keep-file to help debugging
the new code this patch adds, and option --destructive to disable
the protection.
search_wrap() was considering @high_bit to be in blocks,
but it was in bytes.
This patch also improves the unit test to catch the fixed bug, and
to use real geometries.
This patch makes file devices use the same geometry model that
probe_device() probes for.
This change helps one to test whatever probe_device() finds in
the field.