Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Oct 2016 07:16:51 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r307268 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201610140716.u9E7Gpiw060632@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Oct 14 07:16:51 2016
New Revision: 307268
URL: https://svnweb.freebsd.org/changeset/base/307268

Log:
  MFC r305324: MFV r303077:
  7072 zfs fails to expand if lun added when os is in shutdown state
  
  illumos/illumos-gate@c39a2aae1e2c439d156021edfc20910dad7f9891
  https://github.com/illumos/illumos-gate/commit/c39a2aae1e2c439d156021edfc20910da
  d7f9891
  
  https://www.illumos.org/issues/7072
    upstream:
    38733 zfs fails to expand if lun added when os is in shutdown state
    DLPX-36910 spares and caches should not display expandable space
    DLPX-39262 vdev_disk_open spam zfs_dbgmsg buffer
  
  Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
  Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
  Reviewed by: Matthew Ahrens <mahrens@delphix.com>
  Reviewed by: Prakash Surya <prakash.surya@delphix.com>
  Reviewed by: Alex Reece <alex@delphix.com>
  Approved by: Dan McDonald <danmcd@omniti.com>
  Author: George Wilson <george.wilson@delphix.com>

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c	Fri Oct 14 07:16:11 2016	(r307267)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c	Fri Oct 14 07:16:51 2016	(r307268)
@@ -489,7 +489,13 @@ metaslab_class_expandable_space(metaslab
 			continue;
 		}
 
-		space += tvd->vdev_max_asize - tvd->vdev_asize;
+		/*
+		 * Calculate if we have enough space to add additional
+		 * metaslabs. We report the expandable space in terms
+		 * of the metaslab size since that's the unit of expansion.
+		 */
+		space += P2ALIGN(tvd->vdev_max_asize - tvd->vdev_asize,
+		    1ULL << tvd->vdev_ms_shift);
 	}
 	spa_config_exit(mc->mc_spa, SCL_VDEV, FTAG);
 	return (space);

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c	Fri Oct 14 07:16:11 2016	(r307267)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c	Fri Oct 14 07:16:51 2016	(r307268)
@@ -2808,6 +2808,7 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t *
 {
 	spa_t *spa = vd->vdev_spa;
 	vdev_t *rvd = spa->spa_root_vdev;
+	vdev_t *tvd = vd->vdev_top;
 
 	ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0);
 
@@ -2818,8 +2819,15 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t *
 	vs->vs_rsize = vdev_get_min_asize(vd);
 	if (vd->vdev_ops->vdev_op_leaf)
 		vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE;
-	if (vd->vdev_max_asize != 0)
-		vs->vs_esize = vd->vdev_max_asize - vd->vdev_asize;
+	/*
+	 * Report expandable space on top-level, non-auxillary devices only.
+	 * The expandable space is reported in terms of metaslab sized units
+	 * since that determines how much space the pool can expand.
+	 */
+	if (vd->vdev_aux == NULL && tvd != NULL && vd->vdev_max_asize != 0) {
+		vs->vs_esize = P2ALIGN(vd->vdev_max_asize - vd->vdev_asize,
+		    1ULL << tvd->vdev_ms_shift);
+	}
 	vs->vs_configured_ashift = vd->vdev_top != NULL
 	    ? vd->vdev_top->vdev_ashift : vd->vdev_ashift;
 	vs->vs_logical_ashift = vd->vdev_logical_ashift;

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c	Fri Oct 14 07:16:11 2016	(r307267)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c	Fri Oct 14 07:16:51 2016	(r307268)
@@ -241,34 +241,6 @@ vdev_disk_rele(vdev_t *vd)
 	}
 }
 
-static uint64_t
-vdev_disk_get_space(vdev_t *vd, uint64_t capacity, uint_t blksz)
-{
-	ASSERT(vd->vdev_wholedisk);
-
-	vdev_disk_t *dvd = vd->vdev_tsd;
-	dk_efi_t dk_ioc;
-	efi_gpt_t *efi;
-	uint64_t avail_space = 0;
-	int efisize = EFI_LABEL_SIZE * 2;
-
-	dk_ioc.dki_data = kmem_alloc(efisize, KM_SLEEP);
-	dk_ioc.dki_lba = 1;
-	dk_ioc.dki_length = efisize;
-	dk_ioc.dki_data_64 = (uint64_t)(uintptr_t)dk_ioc.dki_data;
-	efi = dk_ioc.dki_data;
-
-	if (ldi_ioctl(dvd->vd_lh, DKIOCGETEFI, (intptr_t)&dk_ioc,
-	    FKIOCTL, kcred, NULL) == 0) {
-		uint64_t efi_altern_lba = LE_64(efi->efi_gpt_AlternateLBA);
-
-		if (capacity > efi_altern_lba)
-			avail_space = (capacity - efi_altern_lba) * blksz;
-	}
-	kmem_free(dk_ioc.dki_data, efisize);
-	return (avail_space);
-}
-
 /*
  * We want to be loud in DEBUG kernels when DKIOCGMEDIAINFOEXT fails, or when
  * even a fallback to DKIOCGMEDIAINFO fails.
@@ -559,10 +531,7 @@ skip_open:
 			 * Adjust max_psize upward accordingly since we know
 			 * we own the whole disk now.
 			 */
-			*max_psize += vdev_disk_get_space(vd, capacity, blksz);
-			zfs_dbgmsg("capacity change: vdev %s, psize %llu, "
-			    "max_psize %llu", vd->vdev_path, *psize,
-			    *max_psize);
+			*max_psize = capacity * blksz;
 		}
 
 		/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610140716.u9E7Gpiw060632>