Noisefs: A predictable noise producing fs for testing things
Add a configurable, predictable noise-producing filesystem for testing stuff,
particularly cache coherency handling in NFS and FS-Cache.
It's based somewhat on ramfs, so you mount an empty fs and populate it:
mount -t noisefs none /mnt
The size of files can be set, e.g.:
echo hello >/mnt/a
echo hello >>/mnt/a
truncate -s 4096 /mnt/a
However, no data is actually stored, and the filesystem is not persistent.
Data can be read, but it's generated by a pattern generator, and is available
up to the EOF point.
The data pattern is generated in BE words of four bytes, consisting of the sum
of the filesystem key, inode number, inode data version number and the word
number within the file (file offset / 4). This should make it easy to check
quickly whether the data is correct.
(1) A file's i_version number can be given a timeout. This means that once
an i_version is viewed (by getattr), it is only good for that many more
seconds. After that it will be incremented and the timeout begun again:
setfattr -n iversion_timo -v 4 /mnt/a
The file's i_version number is also incremented any time there's a write
or a truncation operation performed on the file.
(2) A file can be made to inject an arbitrary error (EIO by default) when
i_version reaches or exceeds a certain number:
setfattr -n inject_error_at -v 4 /mnt/a
setfattr -n error_to_inject -v 28 /mnt/a
So the above would inject ENOSPC when i_version >= 4.
(3) A 32-bit filesystem ID key can be set during mounting:
mount -t noisefs none /mnt -o fs_key=1234
Note that when exporting this filesystem through NFS, an FSID should be
set as the mount does not have real device numbers of its own.
Signed-off-by: David Howells <firstname.lastname@example.org>
9 files changed