From 61e99a73bc34d602639c5a991abdc1e011a52d8d Mon Sep 17 00:00:00 2001 From: Andrew Barnes Date: Tue, 10 Jun 2014 16:29:12 +1000 Subject: Preserve asize when last mirror child promoted to top-level vdev If the smaller of 2 different sized child vdev's of a mirrored vdev is detached, and the pool has the autoexpand property set to off, as the remaining larger vdev is promoted to a top level vdev it fails to retain the asize of the original top level mirror vdev and therefore partially autoexpands. This partially autoexpanded state leaves the new vdev too large to re-mirror by adding the smaller vdev back in, and the pool fails to utilize the space until next imported. If the autoexpand property is set to on, the child vdev grows in size after it has been promoted to a top level vdev as expected. This commit causes the remaining child mirror to retain the asize of its old parent mirror vdev if the autoexpand property is set to off, this allows the smaller vdev to be re-added if required the vdev can then be told to expand if required by the usual using zpool online -e. Signed-off-by: Brian Behlendorf Signed-off-by: Andrew Barnes Signed-off-by: George Wilson Closes #1208 --- module/zfs/vdev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'module/zfs/vdev.c') diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 7751683d1..4c67792c9 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -793,6 +793,17 @@ vdev_remove_parent(vdev_t *cvd) 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); -- cgit v1.2.3