Deleted Added
full compact
libzfs_status.c (168404) libzfs_status.c (168498)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#pragma ident "%Z%%M% %I% %E% SMI"
27
28/*
29 * This file contains the functions which analyze the status of a pool. This
30 * include both the status of an active pool, as well as the status exported

--- 7 unchanged lines hidden (view full) ---

38 * Only a subset of the possible faults can be detected using 'zpool status',
39 * and not all possible errors correspond to a FMA message ID. The explanation
40 * is left up to the caller, depending on whether it is a live pool or an
41 * import.
42 */
43
44#include <libzfs.h>
45#include <string.h>
23 * Use is subject to license terms.
24 */
25
26#pragma ident "%Z%%M% %I% %E% SMI"
27
28/*
29 * This file contains the functions which analyze the status of a pool. This
30 * include both the status of an active pool, as well as the status exported

--- 7 unchanged lines hidden (view full) ---

38 * Only a subset of the possible faults can be detected using 'zpool status',
39 * and not all possible errors correspond to a FMA message ID. The explanation
40 * is left up to the caller, depending on whether it is a live pool or an
41 * import.
42 */
43
44#include <libzfs.h>
45#include <string.h>
46#include <unistd.h>
46#include "libzfs_impl.h"
47
48/*
49 * Message ID table. This must be kep in sync with the ZPOOL_STATUS_* defines
50 * in libzfs.h. Note that there are some status results which go past the end
51 * of this table, and hence have no associated message ID.
52 */
47#include "libzfs_impl.h"
48
49/*
50 * Message ID table. This must be kep in sync with the ZPOOL_STATUS_* defines
51 * in libzfs.h. Note that there are some status results which go past the end
52 * of this table, and hence have no associated message ID.
53 */
53static char *msgid_table[] = {
54static char *zfs_msgid_table[] = {
54 "ZFS-8000-14",
55 "ZFS-8000-2Q",
56 "ZFS-8000-3C",
57 "ZFS-8000-4J",
58 "ZFS-8000-5E",
59 "ZFS-8000-6X",
60 "ZFS-8000-72",
61 "ZFS-8000-8A",
62 "ZFS-8000-9P",
55 "ZFS-8000-14",
56 "ZFS-8000-2Q",
57 "ZFS-8000-3C",
58 "ZFS-8000-4J",
59 "ZFS-8000-5E",
60 "ZFS-8000-6X",
61 "ZFS-8000-72",
62 "ZFS-8000-8A",
63 "ZFS-8000-9P",
63 "ZFS-8000-A5"
64 "ZFS-8000-A5",
65 "ZFS-8000-EY"
64};
65
66/*
67 * If the pool is active, a certain class of static errors is overridden by the
68 * faults as analayzed by FMA. These faults have separate knowledge articles,
69 * and the article referred to by 'zpool status' must match that indicated by
70 * the syslog error message. We override missing data as well as corrupt pool.
71 */
66};
67
68/*
69 * If the pool is active, a certain class of static errors is overridden by the
70 * faults as analayzed by FMA. These faults have separate knowledge articles,
71 * and the article referred to by 'zpool status' must match that indicated by
72 * the syslog error message. We override missing data as well as corrupt pool.
73 */
72static char *msgid_table_active[] = {
74static char *zfs_msgid_table_active[] = {
73 "ZFS-8000-14",
74 "ZFS-8000-D3", /* overridden */
75 "ZFS-8000-D3", /* overridden */
76 "ZFS-8000-4J",
77 "ZFS-8000-5E",
78 "ZFS-8000-6X",
79 "ZFS-8000-CS", /* overridden */
80 "ZFS-8000-8A",
81 "ZFS-8000-9P",
82 "ZFS-8000-CS", /* overridden */
83};
84
75 "ZFS-8000-14",
76 "ZFS-8000-D3", /* overridden */
77 "ZFS-8000-D3", /* overridden */
78 "ZFS-8000-4J",
79 "ZFS-8000-5E",
80 "ZFS-8000-6X",
81 "ZFS-8000-CS", /* overridden */
82 "ZFS-8000-8A",
83 "ZFS-8000-9P",
84 "ZFS-8000-CS", /* overridden */
85};
86
85#define NMSGID (sizeof (msgid_table) / sizeof (msgid_table[0]))
87#define NMSGID (sizeof (zfs_msgid_table) / sizeof (zfs_msgid_table[0]))
86
87/* ARGSUSED */
88static int
89vdev_missing(uint64_t state, uint64_t aux, uint64_t errs)
90{
91 return (state == VDEV_STATE_CANT_OPEN &&
92 aux == VDEV_AUX_OPEN_FAILED);
93}

--- 79 unchanged lines hidden (view full) ---

173static zpool_status_t
174check_status(nvlist_t *config, boolean_t isimport)
175{
176 nvlist_t *nvroot;
177 vdev_stat_t *vs;
178 uint_t vsc;
179 uint64_t nerr;
180 uint64_t version;
88
89/* ARGSUSED */
90static int
91vdev_missing(uint64_t state, uint64_t aux, uint64_t errs)
92{
93 return (state == VDEV_STATE_CANT_OPEN &&
94 aux == VDEV_AUX_OPEN_FAILED);
95}

--- 79 unchanged lines hidden (view full) ---

175static zpool_status_t
176check_status(nvlist_t *config, boolean_t isimport)
177{
178 nvlist_t *nvroot;
179 vdev_stat_t *vs;
180 uint_t vsc;
181 uint64_t nerr;
182 uint64_t version;
183 uint64_t stateval;
184 uint64_t hostid = 0;
181
182 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
183 &version) == 0);
184 verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
185 &nvroot) == 0);
186 verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_STATS,
187 (uint64_t **)&vs, &vsc) == 0);
185
186 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
187 &version) == 0);
188 verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
189 &nvroot) == 0);
190 verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_STATS,
191 (uint64_t **)&vs, &vsc) == 0);
192 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE,
193 &stateval) == 0);
194 (void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID, &hostid);
188
189 /*
195
196 /*
197 * Pool last accessed by another system.
198 */
199 if (hostid != 0 && (unsigned long)hostid != gethostid() &&
200 stateval == POOL_STATE_ACTIVE)
201 return (ZPOOL_STATUS_HOSTID_MISMATCH);
202
203 /*
190 * Newer on-disk version.
191 */
192 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
193 vs->vs_aux == VDEV_AUX_VERSION_NEWER)
194 return (ZPOOL_STATUS_VERSION_NEWER);
195
196 /*
197 * Check that the config is complete.

--- 67 unchanged lines hidden (view full) ---

265zpool_status_t
266zpool_get_status(zpool_handle_t *zhp, char **msgid)
267{
268 zpool_status_t ret = check_status(zhp->zpool_config, B_FALSE);
269
270 if (ret >= NMSGID)
271 *msgid = NULL;
272 else
204 * Newer on-disk version.
205 */
206 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
207 vs->vs_aux == VDEV_AUX_VERSION_NEWER)
208 return (ZPOOL_STATUS_VERSION_NEWER);
209
210 /*
211 * Check that the config is complete.

--- 67 unchanged lines hidden (view full) ---

279zpool_status_t
280zpool_get_status(zpool_handle_t *zhp, char **msgid)
281{
282 zpool_status_t ret = check_status(zhp->zpool_config, B_FALSE);
283
284 if (ret >= NMSGID)
285 *msgid = NULL;
286 else
273 *msgid = msgid_table_active[ret];
287 *msgid = zfs_msgid_table_active[ret];
274
275 return (ret);
276}
277
278zpool_status_t
279zpool_import_status(nvlist_t *config, char **msgid)
280{
281 zpool_status_t ret = check_status(config, B_TRUE);
282
283 if (ret >= NMSGID)
284 *msgid = NULL;
285 else
288
289 return (ret);
290}
291
292zpool_status_t
293zpool_import_status(nvlist_t *config, char **msgid)
294{
295 zpool_status_t ret = check_status(config, B_TRUE);
296
297 if (ret >= NMSGID)
298 *msgid = NULL;
299 else
286 *msgid = msgid_table[ret];
300 *msgid = zfs_msgid_table[ret];
287
288 return (ret);
289}
301
302 return (ret);
303}