This is a simple tool that is designed to determine whether any data gets corrupted during I/O to a file.
It generates random data blocks, calculates blake3 hashes for them, writes blocks to a target file, afterwards reads the data back and compares the hashes. This procedure repeats forever until stopped manually, or until corruption gets detected.
The tool was used successfully in many production cases to prove that corruption was happening.
- On Windows the WinAPI
FILE_FLAG_NO_BUFFERINGflag is used, to disallow any caching on the OS level, and additionallyFILE_FLAG_WRITE_THROUGHduring the writing stage. - On Linux:
O_SYNCandO_DSYNCflags during writing.
USAGE:
cofi [OPTIONS] <blocksize> <filesize> <path>
ARGS:
<blocksize>
Block size of I/O operations. K, M, G and T suffixes are supported.
<filesize>
Size of the file(s) to create. K, M, G and T suffixes are supported.
<path>
Path to the file(s) to create.
OPTIONS:
-t, --threads <threads>
The number of concurrent workers. Each worker works with a separate file.
[default: 1]
-s, --sleep <sleep>
The amount of time a worker should wait before verifying new file. Can be useful for cases where storage system has hot and cold tiers.
[default: 0]
--use-cache
Use system caching for all I/O operations instead of unbuffered access.
-h, --help
Print help information
-V, --version
Print version information
cofi 1M 100G d:\testfile.dat -t 4
- Install Rust https://www.rust-lang.org/
- Run
cargo build --releasein the project folder.