summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/zpool/zpool_main.c30
-rw-r--r--usr/src/cmd/ztest/ztest.c11
-rw-r--r--usr/src/lib/libzfs/common/libzfs.h7
-rw-r--r--usr/src/lib/libzfs/common/libzfs_pool.c9
-rw-r--r--usr/src/uts/common/fs/zfs/sys/vdev.h9
-rw-r--r--usr/src/uts/common/fs/zfs/sys/vdev_impl.h8
-rw-r--r--usr/src/uts/common/fs/zfs/vdev.c71
-rw-r--r--usr/src/uts/common/fs/zfs/vdev_label.c17
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_ioctl.c8
-rw-r--r--usr/src/uts/common/sys/fs/zfs.h6
10 files changed, 101 insertions, 75 deletions
diff --git a/usr/src/cmd/zpool/zpool_main.c b/usr/src/cmd/zpool/zpool_main.c
index 171187093e..95857402cb 100644
--- a/usr/src/cmd/zpool/zpool_main.c
+++ b/usr/src/cmd/zpool/zpool_main.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -175,9 +174,9 @@ get_usage(zpool_help_t idx) {
return (gettext("\tlist [-H] [-o field[,field]*] "
"[pool] ...\n"));
case HELP_OFFLINE:
- return (gettext("\toffline <pool> <device>\n"));
+ return (gettext("\toffline [-t] <pool> <device> ...\n"));
case HELP_ONLINE:
- return (gettext("\tonline <pool> <device>\n"));
+ return (gettext("\tonline <pool> <device> ...\n"));
case HELP_REPLACE:
return (gettext("\treplace [-f] <pool> <device> "
"[new_device]\n"));
@@ -863,6 +862,11 @@ show_import(nvlist_t *config)
(void) printf(gettext("status: The pool data is corrupted.\n"));
break;
+ case ZPOOL_STATUS_OFFLINE_DEV:
+ (void) printf(gettext("status: One or more devices "
+ "are offlined.\n"));
+ break;
+
default:
/*
* No other status can be seen when importing pools.
@@ -1966,10 +1970,7 @@ zpool_do_detach(int argc, char **argv)
}
/*
- * zpool online [-t] <pool> <device>
- *
- * -t Only bring the device on-line temporarily. The online
- * state will not be persistent across reboots.
+ * zpool online <pool> <device> ...
*/
/* ARGSUSED */
int
@@ -2020,7 +2021,7 @@ zpool_do_online(int argc, char **argv)
}
/*
- * zpool offline [-ft] <pool> <device>
+ * zpool offline [-ft] <pool> <device> ...
*
* -f Force the device into the offline state, even if doing
* so would appear to compromise pool availability.
@@ -2028,7 +2029,6 @@ zpool_do_online(int argc, char **argv)
*
* -t Only take the device off-line temporarily. The offline
* state will not be persistent across reboots.
- * (not supported yet)
*/
/* ARGSUSED */
int
@@ -2037,13 +2037,15 @@ zpool_do_offline(int argc, char **argv)
int c, i;
char *poolname;
zpool_handle_t *zhp;
- int ret = 0;
+ int ret = 0, istmp = FALSE;
/* check options */
while ((c = getopt(argc, argv, "ft")) != -1) {
switch (c) {
- case 'f':
case 't':
+ istmp = TRUE;
+ break;
+ case 'f':
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);
@@ -2070,7 +2072,7 @@ zpool_do_offline(int argc, char **argv)
return (1);
for (i = 1; i < argc; i++)
- if (zpool_vdev_offline(zhp, argv[i]) == 0)
+ if (zpool_vdev_offline(zhp, argv[i], istmp) == 0)
(void) printf(gettext("Bringing device %s offline\n"),
argv[i]);
else
diff --git a/usr/src/cmd/ztest/ztest.c b/usr/src/cmd/ztest/ztest.c
index d3c5d39e7b..07cda80045 100644
--- a/usr/src/cmd/ztest/ztest.c
+++ b/usr/src/cmd/ztest/ztest.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -2427,7 +2426,7 @@ ztest_fault_inject(ztest_args_t *za)
*/
if (zopt_maxfaults == 1 && path1[0] != '\0') {
if (ztest_random(10) < 6)
- (void) vdev_offline(spa, path1);
+ (void) vdev_offline(spa, path1, B_TRUE);
else
(void) vdev_online(spa, path1);
return;
@@ -2460,7 +2459,7 @@ ztest_fault_inject(ztest_args_t *za)
*/
if (zopt_maxfaults >= 4 && path1[0] != '\0') {
if (ztest_random(10) < 6)
- (void) vdev_offline(spa, path1);
+ (void) vdev_offline(spa, path1, B_TRUE);
else
(void) vdev_online(spa, path1);
}
diff --git a/usr/src/lib/libzfs/common/libzfs.h b/usr/src/lib/libzfs/common/libzfs.h
index f6e6225d67..c7459797ea 100644
--- a/usr/src/lib/libzfs/common/libzfs.h
+++ b/usr/src/lib/libzfs/common/libzfs.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -85,7 +84,7 @@ extern int zpool_add(zpool_handle_t *, nvlist_t *);
extern int zpool_scrub(zpool_handle_t *, pool_scrub_type_t);
extern int zpool_vdev_online(zpool_handle_t *, const char *);
-extern int zpool_vdev_offline(zpool_handle_t *, const char *);
+extern int zpool_vdev_offline(zpool_handle_t *, const char *, int);
extern int zpool_vdev_attach(zpool_handle_t *, const char *, const char *,
nvlist_t *, int);
extern int zpool_vdev_detach(zpool_handle_t *, const char *);
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c
index 5f243acfc5..949b02adfd 100644
--- a/usr/src/lib/libzfs/common/libzfs_pool.c
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -861,7 +860,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path)
* Take the specified vdev offline
*/
int
-zpool_vdev_offline(zpool_handle_t *zhp, const char *path)
+zpool_vdev_offline(zpool_handle_t *zhp, const char *path, int istmp)
{
zfs_cmd_t zc = { 0 };
char msg[1024];
@@ -870,6 +869,8 @@ zpool_vdev_offline(zpool_handle_t *zhp, const char *path)
(void) snprintf(zc.zc_prop_value, sizeof (zc.zc_prop_value),
"%s%s", path[0] == '/' ? "" : "/dev/dsk/", path);
+ zc.zc_cookie = istmp;
+
if (ioctl(zfs_fd, ZFS_IOC_VDEV_OFFLINE, &zc) == 0)
return (0);
diff --git a/usr/src/uts/common/fs/zfs/sys/vdev.h b/usr/src/uts/common/fs/zfs/sys/vdev.h
index 4113ff2ca6..86d2f1b1ab 100644
--- a/usr/src/uts/common/fs/zfs/sys/vdev.h
+++ b/usr/src/uts/common/fs/zfs/sys/vdev.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -94,7 +93,7 @@ extern void vdev_io_start(zio_t *zio);
extern void vdev_io_done(zio_t *zio);
extern int vdev_online(spa_t *spa, const char *path);
-extern int vdev_offline(spa_t *spa, const char *path);
+extern int vdev_offline(spa_t *spa, const char *path, int istmp);
extern int vdev_error_setup(spa_t *spa, const char *path, int mode, int mask,
uint64_t arg);
diff --git a/usr/src/uts/common/fs/zfs/sys/vdev_impl.h b/usr/src/uts/common/fs/zfs/sys/vdev_impl.h
index 9d3ea3f746..53a202a906 100644
--- a/usr/src/uts/common/fs/zfs/sys/vdev_impl.h
+++ b/usr/src/uts/common/fs/zfs/sys/vdev_impl.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -170,6 +169,7 @@ struct vdev {
uint8_t vdev_fault_mode; /* fault injection mode */
uint8_t vdev_cache_active; /* vdev_cache and vdev_queue */
uint8_t vdev_offline; /* device taken offline? */
+ uint8_t vdev_tmpoffline; /* device taken offline temporarily? */
uint8_t vdev_detached; /* device detached? */
vdev_queue_t vdev_queue; /* I/O deadline schedule queue */
vdev_cache_t vdev_cache; /* physical block cache */
diff --git a/usr/src/uts/common/fs/zfs/vdev.c b/usr/src/uts/common/fs/zfs/vdev.c
index ccdc153fb2..838e1bfc88 100644
--- a/usr/src/uts/common/fs/zfs/vdev.c
+++ b/usr/src/uts/common/fs/zfs/vdev.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -361,7 +360,7 @@ vdev_alloc(spa_t *spa, nvlist_t *nv, vdev_t *parent, uint_t id, int alloctype)
{
vdev_ops_t *ops;
char *type;
- uint64_t guid = 0;
+ uint64_t guid = 0, offline = 0;
vdev_t *vd;
ASSERT(spa_config_held(spa, RW_WRITER));
@@ -417,11 +416,17 @@ vdev_alloc(spa_t *spa, nvlist_t *nv, vdev_t *parent, uint_t id, int alloctype)
}
/*
- * If we're a leaf vdev, try to load the DTL object.
+ * If we're a leaf vdev, try to load the DTL object
+ * and the offline state.
*/
+ vd->vdev_offline = B_FALSE;
if (vd->vdev_ops->vdev_op_leaf && alloctype == VDEV_ALLOC_LOAD) {
(void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_DTL,
&vd->vdev_dtl.smo_object);
+
+ if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_OFFLINE, &offline)
+ == 0)
+ vd->vdev_offline = offline;
}
/*
@@ -1341,18 +1346,19 @@ vdev_description(vdev_t *vd)
int
vdev_online(spa_t *spa, const char *path)
{
- vdev_t *vd;
+ vdev_t *rvd, *vd;
+ uint64_t txg;
- spa_config_enter(spa, RW_WRITER);
+ txg = spa_vdev_enter(spa);
- if ((vd = vdev_lookup_by_path(spa->spa_root_vdev, path)) == NULL) {
- spa_config_exit(spa);
- return (ENODEV);
- }
+ rvd = spa->spa_root_vdev;
+ if ((vd = vdev_lookup_by_path(rvd, path)) == NULL)
+ return (spa_vdev_exit(spa, NULL, txg, ENODEV));
dprintf("ONLINE: %s\n", vdev_description(vd));
vd->vdev_offline = B_FALSE;
+ vd->vdev_tmpoffline = B_FALSE;
/*
* Clear the error counts. The idea is that you expect to see all
@@ -1365,7 +1371,11 @@ vdev_online(spa_t *spa, const char *path)
vdev_reopen(vd->vdev_top, NULL);
- spa_config_exit(spa);
+ spa_config_set(spa, spa_config_generate(spa, rvd, txg, 0));
+
+ vdev_config_dirty(vd->vdev_top);
+
+ (void) spa_vdev_exit(spa, NULL, txg, 0);
VERIFY(spa_scrub(spa, POOL_SCRUB_RESILVER, B_TRUE) == 0);
@@ -1373,19 +1383,23 @@ vdev_online(spa_t *spa, const char *path)
}
int
-vdev_offline(spa_t *spa, const char *path)
+vdev_offline(spa_t *spa, const char *path, int istmp)
{
- vdev_t *vd;
+ vdev_t *rvd, *vd;
+ uint64_t txg;
- spa_config_enter(spa, RW_WRITER);
+ txg = spa_vdev_enter(spa);
- if ((vd = vdev_lookup_by_path(spa->spa_root_vdev, path)) == NULL) {
- spa_config_exit(spa);
- return (ENODEV);
- }
+ rvd = spa->spa_root_vdev;
+ if ((vd = vdev_lookup_by_path(rvd, path)) == NULL)
+ return (spa_vdev_exit(spa, NULL, txg, ENODEV));
dprintf("OFFLINE: %s\n", vdev_description(vd));
+ /* vdev is already offlined, do nothing */
+ if (vd->vdev_offline)
+ return (spa_vdev_exit(spa, NULL, txg, 0));
+
/*
* If this device's top-level vdev has a non-empty DTL,
* don't allow the device to be offlined.
@@ -1393,10 +1407,8 @@ vdev_offline(spa_t *spa, const char *path)
* XXX -- we should make this more precise by allowing the offline
* as long as the remaining devices don't have any DTL holes.
*/
- if (vd->vdev_top->vdev_dtl_map.sm_space != 0) {
- spa_config_exit(spa);
- return (EBUSY);
- }
+ if (vd->vdev_top->vdev_dtl_map.sm_space != 0)
+ return (spa_vdev_exit(spa, NULL, txg, EBUSY));
/*
* Set this device to offline state and reopen its top-level vdev.
@@ -1408,13 +1420,18 @@ vdev_offline(spa_t *spa, const char *path)
if (vdev_is_dead(vd->vdev_top)) {
vd->vdev_offline = B_FALSE;
vdev_reopen(vd->vdev_top, NULL);
- spa_config_exit(spa);
- return (EBUSY);
+ return (spa_vdev_exit(spa, NULL, txg, EBUSY));
}
- spa_config_exit(spa);
+ vd->vdev_tmpoffline = istmp;
+ if (istmp)
+ return (spa_vdev_exit(spa, NULL, txg, 0));
- return (0);
+ spa_config_set(spa, spa_config_generate(spa, rvd, txg, 0));
+
+ vdev_config_dirty(vd->vdev_top);
+
+ return (spa_vdev_exit(spa, NULL, txg, 0));
}
int
diff --git a/usr/src/uts/common/fs/zfs/vdev_label.c b/usr/src/uts/common/fs/zfs/vdev_label.c
index 2d9e476984..1282df0d9a 100644
--- a/usr/src/uts/common/fs/zfs/vdev_label.c
+++ b/usr/src/uts/common/fs/zfs/vdev_label.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -250,6 +249,16 @@ vdev_config_generate(vdev_t *vd, int getstats)
nvlist_free(child[c]);
kmem_free(child, vd->vdev_children * sizeof (nvlist_t *));
+
+ } else {
+ if (!vd->vdev_tmpoffline) {
+ if (vd->vdev_offline)
+ VERIFY(nvlist_add_uint64(nv, ZPOOL_CONFIG_OFFLINE,
+ B_TRUE) == 0);
+ else
+ (void) nvlist_remove(nv, ZPOOL_CONFIG_OFFLINE,
+ DATA_TYPE_UINT64);
+ }
}
return (nv);
diff --git a/usr/src/uts/common/fs/zfs/zfs_ioctl.c b/usr/src/uts/common/fs/zfs/zfs_ioctl.c
index c1bc64f57c..29b01e4331 100644
--- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c
+++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -571,12 +570,13 @@ zfs_ioc_vdev_offline(zfs_cmd_t *zc)
{
spa_t *spa;
char *path = zc->zc_prop_value;
+ int istmp = zc->zc_cookie;
int error;
error = spa_open(zc->zc_name, &spa, FTAG);
if (error != 0)
return (error);
- error = vdev_offline(spa, path);
+ error = vdev_offline(spa, path, istmp);
spa_close(spa, FTAG);
return (error);
}
diff --git a/usr/src/uts/common/sys/fs/zfs.h b/usr/src/uts/common/sys/fs/zfs.h
index da34bca12d..65425c829c 100644
--- a/usr/src/uts/common/sys/fs/zfs.h
+++ b/usr/src/uts/common/sys/fs/zfs.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -133,6 +132,7 @@ uint64_t zfs_prop_default_numeric(zfs_prop_t);
#define ZPOOL_CONFIG_DTL "DTL"
#define ZPOOL_CONFIG_STATS "stats"
#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
+#define ZPOOL_CONFIG_OFFLINE "offline"
#define VDEV_TYPE_ROOT "root"
#define VDEV_TYPE_MIRROR "mirror"