mirror_zfs/cmd
Brian Behlendorf 8128bd89fb Fix hot spares
The issue with hot spares in ZoL is because it opens all leaf
vdevs exclusively (O_EXCL).  On Linux, exclusive opens cause
subsequent exclusive opens to fail with EBUSY.

This could be resolved by not opening any of the devices
exclusively, which is what Illumos does, but the additional
protection offered by exclusive opens is desirable.  It cleanly
prevents you from accidentally adding an in-use non-ZFS device
to your pool.

To fix this we very slightly relaxed the usage of O_EXCL in
the following ways.

1) Functions which open the device but only read had the
   O_EXCL flag removed and were updated to use O_RDONLY.

2) A common holder was added to the vdev disk code.  This
   allow the ZFS code to internally open the device multiple
   times but non-ZFS callers may not.

3) An exception was added to make_disks() for hot spare when
   creating partition tables.  For hot spare devices which
   are already opened exclusively we skip creating the partition
   table because this must already have been done when the disk
   was originally added as a hot spare.

Additional minor changes include fixing check_in_use() to use
a partition instead of a slice suffix.  And is_spare() was moved
above make_disks() to avoid adding a forward reference.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #250
2013-03-01 13:31:02 -08:00
..
fsck_zfs Add /sbin/fsck.zfs helper 2013-01-09 16:54:58 -08:00
mount_zfs Report realpath() canonicalization error 2013-01-09 16:54:58 -08:00
vdev_id vdev_id: improve keyword parsing flexibility 2013-01-25 13:44:32 -08:00
zdb Illumos #3397, #3398 2013-01-11 16:42:50 -08:00
zfs Illumos #1884, #3028, #3048, #3049, #3060, #3061, #3093 2013-01-11 09:17:19 -08:00
zhack Illumos #2619 and #2747 2013-01-08 10:35:35 -08:00
zinject Remove autotools products 2012-08-27 11:47:44 -07:00
zpios Remove autotools products 2012-08-27 11:47:44 -07:00
zpool Fix hot spares 2013-03-01 13:31:02 -08:00
zstreamdump Add zstreamdump .gitignore 2012-09-06 14:23:11 -07:00
ztest Illumos #3145, #3212 2013-01-08 10:35:44 -08:00
zvol_id Remove autotools products 2012-08-27 11:47:44 -07:00
Makefile.am Retire zpool_id infrastructure 2013-01-29 12:23:17 -08:00