mirror_zfs/cmd/zed
Brian Behlendorf d441e85dd7
Add support for autoexpand property
While the autoexpand property may seem like a small feature it
depends on a significant amount of system infrastructure.  Enough
of that infrastructure is now in place that with a few modifications
for Linux it can be supported.

Auto-expand works as follows; when a block device is modified
(re-sized, closed after being open r/w, etc) a change uevent is
generated for udev.  The ZED, which is monitoring udev events,
passes the change event along to zfs_deliver_dle() if the disk
or partition contains a zfs_member as identified by blkid.

From here the device is matched against all imported pool vdevs
using the vdev_guid which was read from the label by blkid.  If
a match is found the ZED reopens the pool vdev.  This re-opening
is important because it allows the vdev to be briefly closed so
the disk partition table can be re-read.  Otherwise, it wouldn't
be possible to report the maximum possible expansion size.

Finally, if the property autoexpand=on a vdev expansion will be
attempted.  After performing some sanity checks on the disk to
verify that it is safe to expand,  the primary partition (-part1)
will be expanded and the partition table updated.  The partition
is then re-opened (again) to detect the updated size which allows
the new capacity to be used.

In order to make all of the above possible the following changes
were required:

* Updated the zpool_expand_001_pos and zpool_expand_003_pos tests.
  These tests now create a pool which is layered on a loopback,
  scsi_debug, and file vdev.  This allows for testing of non-
  partitioned block device (loopback), a partition block device
  (scsi_debug), and a file which does not receive udev change
  events.  This provided for better test coverage, and by removing
  the layering on ZFS volumes there issues surrounding layering
  one pool on another are avoided.

* zpool_find_vdev_by_physpath() updated to accept a vdev guid.
  This allows for matching by guid rather than path which is a
  more reliable way for the ZED to reference a vdev.

* Fixed zfs_zevent_wait() signal handling which could result
  in the ZED spinning when a signal was not handled.

* Removed vdev_disk_rrpart() functionality which can be abandoned
  in favor of kernel provided blkdev_reread_part() function.

* Added a rwlock which is held as a writer while a disk is being
  reopened.  This is important to prevent errors from occurring
  for any configuration related IOs which bypass the SCL_ZIO lock.
  The zpool_reopen_007_pos.ksh test case was added to verify IO
  error are never observed when reopening.  This is not expected
  to impact IO performance.

Additional fixes which aren't critical but were discovered and
resolved in the course of developing this functionality.

* Added PHYS_PATH="/dev/zvol/dataset" to the vdev configuration for
  ZFS volumes.  This is as good as a unique physical path, while the
  volumes are not used in the test cases anymore for other reasons
  this improvement was included.

Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Signed-off-by: Sara Hartse <sara.hartse@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #120
Closes #2437
Closes #5771
Closes #7366
Closes #7582
Closes #7629
2018-07-23 15:40:15 -07:00
..
agents Add support for autoexpand property 2018-07-23 15:40:15 -07:00
zed.d Add canonical mount options zfs-mount-generator 2018-05-11 12:44:14 -07:00
.gitignore Initial implementation of zed (ZFS Event Daemon) 2014-04-02 13:10:03 -07:00
Makefile.am Tunable directory for zfs runtime scripts 2018-06-07 09:59:59 -07:00
zed_conf.c Add scrub after resilver zed script 2018-02-23 11:38:05 -08:00
zed_conf.h Add scrub after resilver zed script 2018-02-23 11:38:05 -08:00
zed_disk_event.c Fix typo in comment, handeling->handling 2018-06-18 21:51:06 -07:00
zed_disk_event.h Bring over illumos ZFS FMA logic -- phase 1 2016-09-01 11:39:45 -07:00
zed_event.c Add scrub after resilver zed script 2018-02-23 11:38:05 -08:00
zed_event.h Update ZED copyright boilerplate 2015-05-11 15:07:00 -07:00
zed_exec.c Fix spelling 2017-01-03 11:31:18 -06:00
zed_exec.h Update ZED copyright boilerplate 2015-05-11 15:07:00 -07:00
zed_file.c Update ZED copyright boilerplate 2015-05-11 15:07:00 -07:00
zed_file.h Update ZED copyright boilerplate 2015-05-11 15:07:00 -07:00
zed_log.c Add missing includes to zed_log.c 2017-04-12 08:57:25 -07:00
zed_log.h Update ZED copyright boilerplate 2015-05-11 15:07:00 -07:00
zed_strings.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
zed_strings.h Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
zed.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
zed.h Update ZED copyright boilerplate 2015-05-11 15:07:00 -07:00