What do programs see when ZFS cannot deliver intact data?

Say my program is trying to read bytes in a file in the ZFS file system. ZFS can find a copy of the necessary block, but cannot find any copy with a valid checksum (all of them are damaged or only existing disks have damaged copies). What does my program see in terms of the return value from the read and the byte that it was trying to read? And is there a way to influence the behavior (in Solaris or any other ZFS OS), that is, a power failure or increased success with potentially corrupted data?

+4
source share
3 answers

EIO is truly the only answer with current ZFS implementations.

The open "ZFS" error requires some way to read corrupted data: http://bugs.opensolaris.org/bugdatabase/printableBug.do?bug_id=6186106

I believe this is already possible using the undocumented but open source zdb utility. See http://www.cuddletech.com/blog/pivot/entry.php?id=980 for an explanation of how to dump the contents of a file using the zdb -R and "r" options.

+5
source

Solaris 10:

# Create a test pool [ root@tesalia z]# cd /tmp [ root@tesalia tmp]# mkfile 100M zz [ root@tesalia tmp]# zpool create prueba /tmp/zz # Fill the pool [ root@tesalia /]# dd if=/dev/zero of=/prueba/dummy_file dd: writing to `/prueba/dummy_file': No space left on device 129537+0 records in 129536+0 records out 66322432 bytes (66 MB) copied, 1.6093 s, 41.2 MB/s # Umount the pool [ root@tesalia /]# zpool export prueba # Corrupt the pool on purpose [ root@tesalia /]# dd if=/dev/urandom of=/tmp/zz seek=100000 count=1 conv=notrunc 1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.0715209 s, 7.2 kB/s # Mount the pool again zpool import -d /tmp prueba # Try to read the corrupted data [ root@tesalia tmp]# md5sum /prueba/dummy_file md5sum: /prueba/dummy_file: I/O error # Read the manual [ root@tesalia tmp]# man -s2 read [...] RETURN VALUES Upon successful completion, read() and readv() return a non-negative integer indicating the number of bytes actually read. Otherwise, the functions return -1 and set errno to indicate the error. ERRORS The read(), readv(), and pread() functions will fail if: [...] EIO A physical I/O error has occurred, [...] 

You must export / import the test pool, because if not, direct overwriting (pool damage) will be skipped, since the file will be saved in the OS memory.

And no, currently ZFS will refuse to provide you with corrupted data. As it should be.

+2
source

How would it return anything other than an EIO error from read() , regardless of the file system disaster recovery utility?

The utility for saving low-level data should use the API for OS and FS, different from open / read / write / close to access the file. The semantics that it needs are fundamentally different from reading normal files, so this will require a specialized API.

+1
source

All Articles