14 Commits

Author SHA1 Message Date
Michel Machado
e3fe7a006d f3probe: fix allocation error of safe device
probe_device_max_blocks() was returning an int that once multiplied
by block_size was out range.
This patch just enforces probe_device_max_blocks() to return
an uint64_t, and does the needed adjustments in the code.
2015-11-13 14:40:43 -05:00
Michel Machado
5d76cd84b6 f3probe: deal with permanent cache
This patch addresses issue discussed here:
https://github.com/AltraMayor/f3/issues/15

Given the structure of the solution implemented in this patch,
it's also expected to address the following issue:
https://github.com/AltraMayor/f3/issues/16
2015-11-12 09:55:39 -05:00
Michel Machado
751b5a609f add f3brew (experimental)
f3brew, f3 block read write, tests block devices
writing and reading blocks directly to devices.

This is a not-functional version of f3brew.
The main contribution of this patch is to reorganize libprobe.{h,c},
so f3brew, and any future application, can reuse the library.
2014-10-10 09:54:39 -04:00
Michel Machado
efdb48c79b f3probe: balance the number of writes and resets
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.
2014-10-09 17:54:30 -04:00
Michel Machado
46a7f24638 f3probe: add option --time-ops
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
2014-09-25 14:33:02 -04:00
Michel Machado
312c9170e7 f3probe: add option --min-memory
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.
2014-09-21 17:11:37 -04:00
Michel Machado
35a351ff39 f3probe: add option --manual-reset
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.
2014-09-21 17:09:01 -04:00
Michel Machado
73a657deec f3probe: protect block device
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.
2014-09-21 13:02:03 -04:00
Michel Machado
294fd81798 f3probe: add block size to the drive model
Using the correct block size of the block device can improve
communication speed with the device.
2014-09-21 11:56:38 -04:00
Michel Machado
ea938f2ff2 f3probe: rewrite file device
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.
2014-09-21 11:56:38 -04:00
Michel Machado
d940ecd19a f3probe: improve probe_device()
- It works with drives of any size.
- It precisely identifies the real size of drives.
- It identify the geometry of the drive.
2014-09-21 11:56:38 -04:00
Michel Machado
b1fbd48675 f3probe: implement probe_device() 2014-09-21 11:47:20 -04:00
Michel Machado
7f9f5972d0 f3probe: add unit test 2014-09-21 11:47:20 -04:00
Michel Machado
28808f31b5 f3probe: move (missing) action to libprobe.c 2014-09-21 11:47:19 -04:00