ZFS zpool device in use checking feature

Device in use checking for ZFS zpool and other filesystem utilities

ZFS zpool feature

As many of you have read and seen, ZFS is live in OpensSolaris. Congratulations to the whole ZFS team for this major accomplishment!

You may have noticed by now a feature that is built in to the ZFS zpool command. The feature is the ability to check for a device 'in use' status prior to executing the command. This is one of the things I love most about ZFS, the thought and care that went in to providing a whole, well thought out and robust user experience. The ZFS CLI's are so easy to use and intuitive. And with this 'in use' feature, more user friendly than any other filesystem on Solaris today.

I worked on UFS for a few years, so this innovation in ZFS is really wonderful. I had a small part in the delivery of this device in use detection feature for ZFS, so today's blog talks about this capability in ZFS and the work I did to add this capability to other Solaris filesystem utilities.

ZFS and libdiskmgt

ZFS uses a library to gather the device in use details, that is also open for viewing on OpenSolaris, called libdiskmgt. This library was originally written by Jerry Jelinek and extended with additional features by me for ZFS and the other filesystem utilities.

The intent of this library is for applications, like the ZFS zpool utility, to have a common place to go to get device data. Not just what is in use, but what devices are on a system and what are their attributes. libdiskmgt recognizes the following types of devices:
  • Drives
  • Controllers
  • Media(including removable media)
  • Slices
  • Partitions(x86)
  • Paths to devices
  • Device aliases
  • Buses
These are represented by a generic descriptor to the caller of libdiskmgt which allows opaque handling of these device types by the application. A model of how these device types are associated is shown below:

The details about the interfaces available for libdiskmgt are in libdiskmgt.h

Device in use checking for ZFS zpool

What constitutes a device in use for a specific application? Well, the answer is that depends on the application. For ZFS in use means that some things will be OK to use without a forced override, other things are not OK to use even with a forced override and yet other in use scenarios are OK for use in a zpool only if the user does specifically override. Today, the ZFS zpool utility uses the following rules for devices found to be in use.

The following in use devices can never be used in a ZFS zpool:
  • Mounted filesystems
  • Device with entry with /etc/vfstab
  • Device used as a dedicated dump device
  • Device in an active ZFS pool
All other in use scenarios as detected by libdiskmgt can be forced via -f with the zpool command.

libdiskmgt reports the following in use statistics:
  • Slices with mounted filesystems
  • Slices with unmounted, but potential filesystems found using the fstyp(1M) Solaris utility.
  • Slices that are a part of an SVM volume configuration. Or that contain an SVM metadb.
  • Slices that are part of a VxVM volume configuration.
  • Slices that are in a current ZFS pool, active or not.
  • Slices that are current live upgrade partitions.
  • Slices that are configured to be dump devices.
  • Slices that are configured to be swap devices.
  • Slices that are in an /etc/vfstab entry.

Other filesystem utilities that use device in use checking

As part of the work that was done in preparation for ZFS, other Solaris filesystem utilities were modified to know about devices in use. These changes were integrated in to the same OpenSolaris release as ZFS. The utilities modified were:
  • newfs
  • mkfs
  • swap
  • dumpadm
  • format

These utilities now check for devices being in use prior to issuing the command. These utilities will now fail if a device is found to be in use. As with the ZFS zpool utility, each of these utilities has its own rules with regard to what is considered in use. For example, it is perfectly legal to use a swap device as a dump device.

The difference between the changes to these utilities and the ZFS zpool utility, is that these utilities were not modified to have a -f, or forced override flag. They either succeed or fail and require the user to clean up any 'in use' details prior to retrying the command. The idea is that if one of these utilities fail due to finding a device in use, the user must be able to clean up the in use state in a supported way in Solaris. For example, if the command fails due to a device being configured as a swap device, the user is instructed to us swap(1M) to change the device state prior to proceeding. These changes are only the beginning. ZFS is leading the way in usability in Solaris. The plan is to continue to enhance libdiskmgt, and other utilities to prevent the user from stepping on themselves if possible.

Thanks for listening. Enjoy ZFS!

Post a Comment:
  • HTML Syntax: NOT allowed



« April 2014