freebsd-dev/module
Olaf Faaland d410c6d9fd Reimplement vdev_random_leaf and rename it
Rename it as mmp_random_leaf() since it is defined in mmp.c.

The earlier implementation could end up spinning forever if a pool had a
vdev marked writeable, none of whose children were writeable.  It also
did not guarantee that if a writeable leaf vdev existed, it would be
found.

Reimplement to recursively walk the device tree to select the leaf.  It
searches the entire tree, so that a return value of (NULL) indicates
there were no usable leaves in the pool; all were either not writeable
or had pending mmp writes.

It still chooses the starting child randomly at each level of the tree,
so if the pool's devices are healthy, the mmp writes go to random leaves
with an even distribution.  This was verified by testing using
zfs_multihost_history enabled.

Reviewed by: Thomas Caputi <tcaputi@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #6631 
Closes #6665
2017-09-22 14:29:26 -07:00
..
avl OpenZFS 7028 - avl_destroy_nodes supports emptying, not just destroying, an avl tree 2017-08-30 12:08:38 -07:00
icp Retire legacy test infrastructure 2017-08-15 17:26:38 -07:00
nvpair OpenZFS 2976 - remove useless offsetof() macros 2017-08-30 15:53:38 -07:00
unicode
zcommon Native Encryption for ZFS on Linux 2017-08-14 10:36:48 -07:00
zfs Reimplement vdev_random_leaf and rename it 2017-09-22 14:29:26 -07:00
.gitignore Improve gitignore 2017-05-25 10:14:13 -07:00
Makefile.in Retire legacy test infrastructure 2017-08-15 17:26:38 -07:00