From owner-svn-src-stable@freebsd.org Wed Apr 26 22:23:44 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5DBD7D515DB; Wed, 26 Apr 2017 22:23:44 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 10A4BC79; Wed, 26 Apr 2017 22:23:43 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3QMNhRF004449; Wed, 26 Apr 2017 22:23:43 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3QMNht7004448; Wed, 26 Apr 2017 22:23:43 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201704262223.v3QMNht7004448@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Wed, 26 Apr 2017 22:23:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317469 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Apr 2017 22:23:44 -0000 Author: smh Date: Wed Apr 26 22:23:42 2017 New Revision: 317469 URL: https://svnweb.freebsd.org/changeset/base/317469 Log: MFC r316460: Fix expandsz 16.0E vals and vdev_min_asize of RAIDZ children Sponsored by: Multiplay Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Wed Apr 26 22:17:54 2017 (r317468) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Wed Apr 26 22:23:42 2017 (r317469) @@ -228,7 +228,8 @@ vdev_get_min_asize(vdev_t *vd) * so each child must provide at least 1/Nth of its asize. */ if (pvd->vdev_ops == &vdev_raidz_ops) - return (pvd->vdev_min_asize / pvd->vdev_children); + return ((pvd->vdev_min_asize + pvd->vdev_children - 1) / + pvd->vdev_children); return (pvd->vdev_min_asize); } @@ -1376,7 +1377,7 @@ vdev_open(vdev_t *vd) vd->vdev_psize = psize; /* - * Make sure the allocatable size hasn't shrunk. + * Make sure the allocatable size hasn't shrunk too much. */ if (asize < vd->vdev_min_asize) { vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN, @@ -1416,12 +1417,21 @@ vdev_open(vdev_t *vd) } /* - * If all children are healthy and the asize has increased, - * then we've experienced dynamic LUN growth. If automatic - * expansion is enabled then use the additional space. - */ - if (vd->vdev_state == VDEV_STATE_HEALTHY && asize > vd->vdev_asize && - (vd->vdev_expanding || spa->spa_autoexpand)) + * If all children are healthy we update asize if either: + * The asize has increased, due to a device expansion caused by dynamic + * LUN growth or vdev replacement, and automatic expansion is enabled; + * making the additional space available. + * + * The asize has decreased, due to a device shrink usually caused by a + * vdev replace with a smaller device. This ensures that calculations + * based of max_asize and asize e.g. esize are always valid. It's safe + * to do this as we've already validated that asize is greater than + * vdev_min_asize. + */ + if (vd->vdev_state == VDEV_STATE_HEALTHY && + ((asize > vd->vdev_asize && + (vd->vdev_expanding || spa->spa_autoexpand)) || + (asize < vd->vdev_asize))) vd->vdev_asize = asize; vdev_set_min_asize(vd);