Mercurial > illumos > illumos-gate
changeset 7313:99e2110471bb
6734585 zpool history should log when a spare device becomes active
6736002 zinject needs to init/destroy rw inject_lock
author | Eric Kustarz <Eric.Kustarz@Sun.COM> |
---|---|
date | Tue, 12 Aug 2008 14:14:36 -0700 |
parents | 3992f9a413c2 |
children | 2ded6fdd4e05 |
files | usr/src/uts/common/fs/zfs/spa.c usr/src/uts/common/fs/zfs/vdev.c usr/src/uts/common/fs/zfs/zio_inject.c |
diffstat | 3 files changed, 30 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/uts/common/fs/zfs/spa.c Tue Aug 12 13:43:23 2008 -0700 +++ b/usr/src/uts/common/fs/zfs/spa.c Tue Aug 12 14:14:36 2008 -0700 @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This file contains all the routines used when modifying on-disk SPA state. * This includes opening, importing, destroying, exporting a pool, and syncing a @@ -2784,11 +2782,14 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing) { uint64_t txg, open_txg; - int error; vdev_t *rvd = spa->spa_root_vdev; vdev_t *oldvd, *newvd, *newrootvd, *pvd, *tvd; vdev_ops_t *pvops; int is_log; + dmu_tx_t *tx; + char *oldvdpath, *newvdpath; + int newvd_isspare; + int error; txg = spa_vdev_enter(spa); @@ -2937,6 +2938,9 @@ if (newvd->vdev_isspare) spa_spare_activate(newvd); + oldvdpath = spa_strdup(vdev_description(oldvd)); + newvdpath = spa_strdup(vdev_description(newvd)); + newvd_isspare = newvd->vdev_isspare; /* * Mark newvd's DTL dirty in this txg. @@ -2945,6 +2949,21 @@ (void) spa_vdev_exit(spa, newrootvd, open_txg, 0); + tx = dmu_tx_create_dd(spa_get_dsl(spa)->dp_mos_dir); + if (dmu_tx_assign(tx, TXG_WAIT) == 0) { + spa_history_internal_log(LOG_POOL_VDEV_ATTACH, spa, tx, + CRED(), "%s vdev=%s %s vdev=%s", + replacing && newvd_isspare ? "spare in" : + replacing ? "replace" : "attach", newvdpath, + replacing ? "for" : "to", oldvdpath); + dmu_tx_commit(tx); + } else { + dmu_tx_abort(tx); + } + + spa_strfree(oldvdpath); + spa_strfree(newvdpath); + /* * Kick off a resilver to update newvd. */
--- a/usr/src/uts/common/fs/zfs/vdev.c Tue Aug 12 13:43:23 2008 -0700 +++ b/usr/src/uts/common/fs/zfs/vdev.c Tue Aug 12 14:14:36 2008 -0700 @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/zfs_context.h> #include <sys/fm/fs/zfs.h> #include <sys/spa.h> @@ -1542,6 +1540,12 @@ if (vd->vdev_path != NULL) return (vd->vdev_path); + if (vd->vdev_physpath != NULL) + return (vd->vdev_physpath); + + if (vd->vdev_devid != NULL) + return (vd->vdev_devid); + if (vd->vdev_parent == NULL) return (spa_name(vd->vdev_spa));
--- a/usr/src/uts/common/fs/zfs/zio_inject.c Tue Aug 12 13:43:23 2008 -0700 +++ b/usr/src/uts/common/fs/zfs/zio_inject.c Tue Aug 12 14:14:36 2008 -0700 @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * ZFS fault injection * @@ -365,6 +363,7 @@ void zio_inject_init(void) { + rw_init(&inject_lock, NULL, RW_DEFAULT, NULL); list_create(&inject_handlers, sizeof (inject_handler_t), offsetof(inject_handler_t, zi_link)); } @@ -373,4 +372,5 @@ zio_inject_fini(void) { list_destroy(&inject_handlers); + rw_destroy(&inject_lock); }