Print this page
NEX-3508 CLONE - Port NEX-2946 Add UNMAP/TRIM functionality to ZFS and illumos
Reviewed by: Josef Sipek <josef.sipek@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Conflicts:
usr/src/uts/common/io/scsi/targets/sd.c
usr/src/uts/common/sys/scsi/targets/sddef.h
@@ -22,11 +22,11 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
#include <sys/spa.h>
#include <sys/vdev_impl.h>
@@ -35,58 +35,30 @@
/*
* Virtual device vector for the pool's root vdev.
*/
-static uint64_t
-vdev_root_core_tvds(vdev_t *vd)
-{
- uint64_t tvds = 0;
-
- for (uint64_t c = 0; c < vd->vdev_children; c++) {
- vdev_t *cvd = vd->vdev_child[c];
-
- if (!cvd->vdev_ishole && !cvd->vdev_islog &&
- cvd->vdev_ops != &vdev_indirect_ops) {
- tvds++;
- }
- }
-
- return (tvds);
-}
-
/*
* We should be able to tolerate one failure with absolutely no damage
* to our metadata. Two failures will take out space maps, a bunch of
* indirect block trees, meta dnodes, dnodes, etc. Probably not a happy
* place to live. When we get smarter, we can liberalize this policy.
* e.g. If we haven't lost two consecutive top-level vdevs, then we are
* probably fine. Adding bean counters during alloc/free can make this
* future guesswork more accurate.
*/
-static boolean_t
-too_many_errors(vdev_t *vd, uint64_t numerrors)
+static int
+too_many_errors(vdev_t *vd, int numerrors)
{
- uint64_t tvds;
-
- if (numerrors == 0)
- return (B_FALSE);
-
- tvds = vdev_root_core_tvds(vd);
- ASSERT3U(numerrors, <=, tvds);
-
- if (numerrors == tvds)
- return (B_TRUE);
-
- return (numerrors > spa_missing_tvds_allowed(vd->vdev_spa));
+ ASSERT3U(numerrors, <=, vd->vdev_children);
+ return (numerrors > 0);
}
static int
vdev_root_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize,
uint64_t *ashift)
{
- spa_t *spa = vd->vdev_spa;
int lasterror = 0;
int numerrors = 0;
if (vd->vdev_children == 0) {
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
@@ -102,13 +74,10 @@
lasterror = cvd->vdev_open_error;
numerrors++;
}
}
- if (spa_load_state(spa) != SPA_LOAD_NONE)
- spa_set_missing_tvds(spa, numerrors);
-
if (too_many_errors(vd, numerrors)) {
vd->vdev_stat.vs_aux = VDEV_AUX_NO_REPLICAS;
return (lasterror);
}
@@ -130,11 +99,11 @@
vdev_root_state_change(vdev_t *vd, int faulted, int degraded)
{
if (too_many_errors(vd, faulted)) {
vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
VDEV_AUX_NO_REPLICAS);
- } else if (degraded || faulted) {
+ } else if (degraded) {
vdev_set_state(vd, B_FALSE, VDEV_STATE_DEGRADED, VDEV_AUX_NONE);
} else {
vdev_set_state(vd, B_FALSE, VDEV_STATE_HEALTHY, VDEV_AUX_NONE);
}
}