The f_random_corruption test enables a random subset of filesystem
features, picks one of the valid filesystem block and inode sizes, and a
random device size and creates a new filesystem with those parameters.
It is possible to disable the running of the test by setting the
environment variable F_RANDOM_CORRUPTION=skip. By default the test
script is run only one time, but setting the LOOP_COUNT variable allows
the test to run multiple times.
If the script is running as root the filesystem is mounted and populated
with file data to allow a more useful test filesystem to be generated.
In some cases the kernel may not support the requested filesystem
features and the filesystem cannot be mounted. This is not considered a
test failure.
The resulting filesystem is corrupted with both random data and by
shifting data from one part of the device to another and then repaired
by e2fsck. In some rare cases the random corruption is severe enough
that the filesystem is not recoverable (e.g. small filesystem with no
backup superblock has bad superblock corruption) but in most cases
"e2fsck -fy" should be able to fix all errors in some way.
After e2fsck has repaired the filesystem, it is optionally mounted (if
the environment variable MOUNT_AFTER_CORRUPTION=yes is set) and the test
files created in the filesystem are deleted. This verifies that the
fixes in the filesystem are sufficient for the kernel to use the
filesystem without error. Since there is some possibility of the kernel
oopsing if there is a filesystem bug, this part of the test is not
enabled by default.
Signed-off-by: Andreas Dilger <[email protected]>
Signed-off-by: Kalpak Shah <[email protected]>