diff options
author | Eric Schrock <Eric.Schrock@Sun.COM> | 2009-10-21 16:03:06 -0700 |
---|---|---|
committer | Eric Schrock <Eric.Schrock@Sun.COM> | 2009-10-21 16:03:06 -0700 |
commit | 096d22d43da2758693a6df66ce7d9ab54c9d464c (patch) | |
tree | b8425c2c1973621ead490969138ea2a8ebc6513f /usr/src/lib | |
parent | 807e8f10a5bd74064a2c6ed98b73c845df2f834e (diff) | |
download | illumos-joyent-096d22d43da2758693a6df66ce7d9ab54c9d464c.tar.gz |
6893087 removing and inserting a faulted vdev clears faulted state
6893088 new ereports need to be generated when clearing a vdev
6893090 clearing a vdev should automatically detach spare
6893099 zpool_clear_label() would be useful
Diffstat (limited to 'usr/src/lib')
-rw-r--r-- | usr/src/lib/libzfs/common/libzfs.h | 3 | ||||
-rw-r--r-- | usr/src/lib/libzfs/common/libzfs_import.c | 30 | ||||
-rw-r--r-- | usr/src/lib/libzfs/common/mapfile-vers | 1 |
3 files changed, 33 insertions, 1 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs.h b/usr/src/lib/libzfs/common/libzfs.h index 3df4e5ccaa..d4200f270e 100644 --- a/usr/src/lib/libzfs/common/libzfs.h +++ b/usr/src/lib/libzfs/common/libzfs.h @@ -581,9 +581,10 @@ extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **, boolean_t *); /* - * ftyp special. Read the label from a given device. + * Label manipulation. */ extern int zpool_read_label(int, nvlist_t **); +extern int zpool_clear_label(int); /* is this zvol valid for use as a dump device? */ extern int zvol_check_dump_config(char *); diff --git a/usr/src/lib/libzfs/common/libzfs_import.c b/usr/src/lib/libzfs/common/libzfs_import.c index f5793390ea..8705361b6c 100644 --- a/usr/src/lib/libzfs/common/libzfs_import.c +++ b/usr/src/lib/libzfs/common/libzfs_import.c @@ -898,6 +898,36 @@ zpool_read_label(int fd, nvlist_t **config) } /* + * Given a file descriptor, clear (zero) the label information. This function + * is currently only used in the appliance stack as part of the ZFS sysevent + * module. + */ +int +zpool_clear_label(int fd) +{ + struct stat64 statbuf; + int l; + vdev_label_t *label; + uint64_t size; + + if (fstat64(fd, &statbuf) == -1) + return (0); + size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t); + + if ((label = calloc(sizeof (vdev_label_t), 1)) == NULL) + return (-1); + + for (l = 0; l < VDEV_LABELS; l++) { + if (pwrite64(fd, label, sizeof (vdev_label_t), + label_offset(size, l)) != sizeof (vdev_label_t)) + return (-1); + } + + free(label); + return (0); +} + +/* * Given a list of directories to search, find all pools stored on disk. This * includes partial pools which are not available to import. If no args are * given (argc is 0), then the default directory (/dev/dsk) is searched. diff --git a/usr/src/lib/libzfs/common/mapfile-vers b/usr/src/lib/libzfs/common/mapfile-vers index 17a07d40a9..72b2b3da69 100644 --- a/usr/src/lib/libzfs/common/mapfile-vers +++ b/usr/src/lib/libzfs/common/mapfile-vers @@ -151,6 +151,7 @@ SUNWprivate_1.1 { zfs_userquota_prop_prefixes; zpool_add; zpool_clear; + zpool_clear_label; zpool_close; zpool_create; zpool_destroy; |