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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/vdev.c
          +++ new/usr/src/uts/common/fs/zfs/vdev.c
↓ open down ↓ 779 lines elided ↑ open up ↑
 780  780           * If cvd will replace mvd as a top-level vdev, preserve mvd's guid.
 781  781           * Otherwise, we could have detached an offline device, and when we
 782  782           * go to import the pool we'll think we have two top-level vdevs,
 783  783           * instead of a different version of the same top-level vdev.
 784  784           */
 785  785          if (mvd->vdev_top == mvd) {
 786  786                  uint64_t guid_delta = mvd->vdev_guid - cvd->vdev_guid;
 787  787                  cvd->vdev_orig_guid = cvd->vdev_guid;
 788  788                  cvd->vdev_guid += guid_delta;
 789  789                  cvd->vdev_guid_sum += guid_delta;
      790 +
      791 +                /*
      792 +                 * If pool not set for autoexpand, we need to also preserve
      793 +                 * mvd's asize to prevent automatic expansion of cvd.
      794 +                 * Otherwise if we are adjusting the mirror by attaching and
      795 +                 * detaching children of non-uniform sizes, the mirror could
      796 +                 * autoexpand, unexpectedly requiring larger devices to
      797 +                 * re-establish the mirror.
      798 +                 */
      799 +                if (!cvd->vdev_spa->spa_autoexpand)
      800 +                        cvd->vdev_asize = mvd->vdev_asize;
 790  801          }
 791  802          cvd->vdev_id = mvd->vdev_id;
 792  803          vdev_add_child(pvd, cvd);
 793  804          vdev_top_update(cvd->vdev_top, cvd->vdev_top);
 794  805  
 795  806          if (cvd == cvd->vdev_top)
 796  807                  vdev_top_transfer(mvd, cvd);
 797  808  
 798  809          ASSERT(mvd->vdev_children == 0);
 799  810          vdev_free(mvd);
↓ open down ↓ 2503 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX