Earlier this week I came across this blog posting about data integrity testing on ZFS title: ZFS data integrity tested. It was a few months old from Robin Harris’ blog Storage Bits. I guess the most exciting part was validating Sun Microsystem’s claims to ZFS having the ability to correct data corruption even with error injection to both the disk and memory. ZFS continues to prove its worth on enterprise class systems and applications.
My only frustatrions with ZFS are that cluster support is currently not available, at least until Lustre 3.0 is out, whenever that will be. Another frustration is trying to write an application that will work directly with a zpool. For instance, there is no simple method to send a zpool a generic ioctl() such as DKIOCGGEOM to obtain the size of the volume. In most cases I don’t care about the number of cylinders, heads and sectors. In the end I calculate the total volume block and/or byte count. So those values could be generic and made up.
In the early stages of my discovering this, I posted a simple question on the OpenSolaris Forums:
“As I was navigating through the source code for the ZFS file system I saw that in zvol.c where the ioctls are defined, if a program sends a DKIOCGGEOM or DKIOCDVTOV, an ENOTSUP (Error Not Supported) is returned.
You can view this here: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/fs/zfs/zvol.c
My question is, what is an appropriate method to obtain the zpool’s volume size from a C coded application?”
After posting my question, I immediately went to view the open source to the general zpool/zfs binaries and observe how zpool reported the drive pool’s capacity back into user space. Unfortunately it utilized some cryptic method not as straight forward as sending a simple ioctl() to the desired volume. This was a bit frustrating as it was such an ugly approach to only receive the size of the volume.
I was grateful to have a response confirming my fear of choosing the ugly route; but it also made me realize the true value of open source. What if I simply patched a supported ioctl() definition to return the total accessible “block” count of a zpool? It would be similar to the Linux BLKGETSZ/BLKGETSZ64. This would be the most realistic and proper method; to add a new ioctl() and then modify all storage modules to accommodate it. For instance in the usr/src/uts/common/sys/dkio.h file we would need to define:
#define DKIOBLKGETSZ (DKIO|50) |
And then go back to the zvol.c file and add the extra ioctl() to handle this:
case DKIOBLKGETSZ: {
uint64_t vs = zv->zv_volsize;
if(ddi_copyout(&vs, (void *)arg, sizeof(uint64_t), flag))
error = EFAULT;
return (error);
} |
To give a level of consistency across all storage devices, we will need to add the ioctl() definition to the following modules:
usr/src/uts/common/io/cmlb.c
usr/src/uts/common/io/ramdisk.c
usr/src/uts/common/io/fd.c
usr/src/uts/common/io/lofi.c |
Although we do not necessarily have to support it and can instead interpret it as such:
case DKIOBLKGETSZ:
return ENOTSUP; |
Who knows, one of these days I may get around to patching this myself and if the OpenSolaris community doesn’t accept it I can always make it available on any one of my website. I will most definitely post about it.
Recent Comments