7072 zfs fails to expand if lun added when os is in shutdown state

illumos/illumos-gate@c39a2aae1e
c39a2aae1e

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>
This commit is contained in:
Andriy Gapon 2016-07-20 09:47:35 +00:00
parent 6155b9e07c
commit 76fbf360a4
3 changed files with 18 additions and 34 deletions

View File

@ -381,7 +381,13 @@ metaslab_class_expandable_space(metaslab_class_t *mc)
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);

View File

@ -2731,6 +2731,7 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t *vs)
{
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);
@ -2741,7 +2742,15 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t *vs)
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;
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) {
vs->vs_esize = P2ALIGN(vd->vdev_max_asize - vd->vdev_asize,
1ULL << tvd->vdev_ms_shift);
}
if (vd->vdev_aux == NULL && vd == vd->vdev_top && !vd->vdev_ishole) {
vs->vs_fragmentation = vd->vdev_mg->mg_fragmentation;
}

View File

@ -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;
}
/*