Print this page
4932 vdev incorrectly expanding on last mirror child -> top-level vdev
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

@@ -785,10 +785,21 @@
         if (mvd->vdev_top == mvd) {
                 uint64_t guid_delta = mvd->vdev_guid - cvd->vdev_guid;
                 cvd->vdev_orig_guid = cvd->vdev_guid;
                 cvd->vdev_guid += guid_delta;
                 cvd->vdev_guid_sum += guid_delta;
+
+                /*
+                 * If pool not set for autoexpand, we need to also preserve
+                 * mvd's asize to prevent automatic expansion of cvd.
+                 * Otherwise if we are adjusting the mirror by attaching and
+                 * detaching children of non-uniform sizes, the mirror could
+                 * autoexpand, unexpectedly requiring larger devices to
+                 * re-establish the mirror.
+                 */
+                if (!cvd->vdev_spa->spa_autoexpand)
+                        cvd->vdev_asize = mvd->vdev_asize;
         }
         cvd->vdev_id = mvd->vdev_id;
         vdev_add_child(pvd, cvd);
         vdev_top_update(cvd->vdev_top, cvd->vdev_top);