zfsonlinux/zfs — pull request #1587 by prakashsurya (2013-07-12 22:34:49+00:00)
Title: Add 'zimport' to aid udev driven pool import (WIP)

This change introduces a new userspace command 'zimport' whose intention
is to be used as a udev helper for dynamically import ZFS pools as
devices appear.

Although this is still a work in progress, the command currently
supports a stateful interface for adding and removing devices:

# To add the /dev/sda1 device to the /tmp/zimport.cache file
$ zimport -a /dev/sda1

# To remove the /dev/sda1 device to the /tmp/zimport.cache file
$ zimport -r /dev/sda1

Once the zimport cache file contains all of the vdevs for a given pool,
it will automatically attempt to import the pool. For example, to import
a pool consisting of two devices (sda1 and sdb1) run the following:

$ zimport -a /dev/sda1
$ zimport -a /dev/sdb1

It is also possible to use the '-c' option to specify a custom file name
to use as the cache file. For example, to use the '/var/run/zimport'
instead of the default one can do the following:

$ zimport -a /dev/sda1 -c /var/run/zimport

Work that still needs to be implemented includes the following:

* l2arc devices are not yet supported.

* A udev rules helper needs to be added to make use of the 'zimport'
command. This helper should run 'zimport -a %k' to add a device as
they appear and 'zimport -r %k' as they disappear.

* The cache file needs to be cleared and/or devices removed from the
cache file as pools are successfully imported.

* A configuration interface is needed to specify different policies
which define the conditions which need to be met for a pool to be
imported. For example:

- Which should pools should be imported?
- Do all vdevs need to be present to import? (e.g. raidz degraded)
- How much "slack" time between all devices online and import?

Currently, all vdevs must be present before the pool is imported.
Also, any pool detected will try to be imported.

* It would also be useful to be able to specify scripts or executables
to be run at specific points during the device recognition and import
phase.

Signed-off-by: Prakash Surya
Issue #330