]> git.proxmox.com Git - mirror_zfs.git/commitdiff
OpenZFS 7136 - ESC_VDEV_REMOVE_AUX ought to always include vdev information
authorGeorge Melikov <mail@gmelikov.ru>
Tue, 31 Jan 2017 18:19:36 +0000 (21:19 +0300)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 31 Jan 2017 18:19:36 +0000 (10:19 -0800)
Authored by: Alan Somers <asomers@gmail.com>
7115 6922 generates ESC_ZFS_VDEV_REMOVE_AUX a bit too often
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>
OpenZFS-issue: https://www.illumos.org/issues/7136
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/b72b6bb
Closes #5691

Porting notes:
- Functionally this patch behaves the same as the OpenZFS
  version but it was adapted because because ZoL doesn't
  have the same illumos sysevent_t infrastructure and functionality.

module/zfs/spa.c

index f82847c82fd5aa8e22ce80106e1353cd7b7f618e..a69b8cda81c9520e4036256476a8fe23236b6c34 100644 (file)
@@ -5476,6 +5476,9 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
                 * in this pool.
                 */
                if (vd == NULL || unspare) {
+                       if (vd == NULL)
+                               vd = spa_lookup_by_guid(spa, guid, B_TRUE);
+                       spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX);
                        spa_vdev_remove_aux(spa->spa_spares.sav_config,
                            ZPOOL_CONFIG_SPARES, spares, nspares, nv);
                        spa_load_spares(spa);
@@ -5483,7 +5486,6 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
                } else {
                        error = SET_ERROR(EBUSY);
                }
-               spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX);
        } else if (spa->spa_l2cache.sav_vdevs != NULL &&
            nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config,
            ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0 &&
@@ -5491,11 +5493,12 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
                /*
                 * Cache devices can always be removed.
                 */
+               vd = spa_lookup_by_guid(spa, guid, B_TRUE);
+               spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX);
                spa_vdev_remove_aux(spa->spa_l2cache.sav_config,
                    ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache, nv);
                spa_load_l2cache(spa);
                spa->spa_l2cache.sav_sync = B_TRUE;
-               spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX);
        } else if (vd != NULL && vd->vdev_islog) {
                ASSERT(!locked);
                ASSERT(vd == vd->vdev_top);
@@ -5532,9 +5535,9 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
                /*
                 * Clean up the vdev namespace.
                 */
+               spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV);
                spa_vdev_remove_from_namespace(spa, vd);
 
-               spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV);
        } else if (vd != NULL) {
                /*
                 * Normal vdevs cannot be removed (yet).