summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorCheng Sean Ye <Sean.Ye@Sun.COM>2009-02-09 21:39:23 -0800
committerCheng Sean Ye <Sean.Ye@Sun.COM>2009-02-09 21:39:23 -0800
commitc93c462eec9d46f84d567abf52eb29a27c2e134b (patch)
tree317adf43f33929e2e4b9452a05379c8925629eb7 /usr/src
parent47b4653e9ff2a8aebb64f9e357713fd04108674b (diff)
downloadillumos-gate-c93c462eec9d46f84d567abf52eb29a27c2e134b.tar.gz
6783755 chip: mc_nb_create: node range create failed
6769643 ndi_fmc_entry_error only fails one handle even if multiple handles from same driver map same address 6394503 fmdump should show contents of rotated logs without specifying them explicitly 6741189 need topo interface to export devinfo snapshot to topo snapshot consumers 6741191 libtopo should refresh the devinfo snapshot 6797068 In cpumem-retire, fmd_case_uuclose() is not called under x86
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/fm/fmdump/common/fmdump.c128
-rw-r--r--usr/src/cmd/fm/modules/common/cpumem-retire/cma_main.c6
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/libtopo.h3
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/mapfile-vers2
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/topo_mod.c26
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/topo_snap.c50
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/topo_tree.c18
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/chip/chip.c19
-rw-r--r--usr/src/uts/common/os/ndifm.c3
9 files changed, 196 insertions, 59 deletions
diff --git a/usr/src/cmd/fm/fmdump/common/fmdump.c b/usr/src/cmd/fm/fmdump/common/fmdump.c
index 8839858e52..ed680493c0 100644
--- a/usr/src/cmd/fm/fmdump/common/fmdump.c
+++ b/usr/src/cmd/fm/fmdump/common/fmdump.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <alloca.h>
#include <unistd.h>
#include <limits.h>
@@ -36,6 +34,7 @@
#include <time.h>
#include <ctype.h>
#include <regex.h>
+#include <dirent.h>
#include <fmdump.h>
@@ -445,6 +444,92 @@ log_filter_silent(fmd_log_t *lp, const fmd_log_record_t *rp, void *arg)
FM_SUSPECT_MESSAGE, &msg) != 0 || msg != 0);
}
+struct loglink {
+ char *path;
+ long suffix;
+ struct loglink *next;
+};
+
+static void
+addlink(struct loglink **llp, char *dirname, char *logname, long suffix)
+{
+ struct loglink *newp;
+ size_t len;
+ char *str;
+
+ newp = malloc(sizeof (struct loglink));
+ len = strlen(dirname) + strlen(logname) + 2;
+ str = malloc(len);
+ if (newp == NULL || str == NULL) {
+ (void) fprintf(stderr, "%s: failed to allocate memory: %s\n",
+ g_pname, strerror(errno));
+ exit(FMDUMP_EXIT_FATAL);
+ }
+
+ (void) snprintf(str, len, "%s/%s", dirname, logname);
+ newp->path = str;
+ newp->suffix = suffix;
+
+ while (*llp != NULL && suffix < (*llp)->suffix)
+ llp = &(*llp)->next;
+
+ newp->next = *llp;
+ *llp = newp;
+}
+
+/*
+ * Find and return all the rotated logs.
+ */
+static struct loglink *
+get_rotated_logs(char *logpath)
+{
+ char dirname[PATH_MAX], *logname, *endptr;
+ DIR *dirp;
+ struct dirent *dp;
+ long len, suffix;
+ struct loglink *head = NULL;
+
+ (void) strlcpy(dirname, logpath, sizeof (dirname));
+ logname = strrchr(dirname, '/');
+ *logname++ = '\0';
+ len = strlen(logname);
+
+ if ((dirp = opendir(dirname)) == NULL) {
+ (void) fprintf(stderr, "%s: failed to opendir `%s': %s\n",
+ g_pname, dirname, strerror(errno));
+ return (NULL);
+ }
+
+ while ((dp = readdir(dirp)) != NULL) {
+ /*
+ * Search the log directory for logs named "<logname>.0",
+ * "<logname>.1", etc and add to the link in the
+ * reverse numeric order.
+ */
+ if (strlen(dp->d_name) < len + 2 ||
+ strncmp(dp->d_name, logname, len) != 0 ||
+ dp->d_name[len] != '.')
+ continue;
+
+ /*
+ * "*.0-" file normally should not be seen. It may
+ * exist when user manually run 'fmadm rotate'.
+ * In such case, we put it at the end of the list so
+ * it'll be dumped after all the rotated logs, before
+ * the current one.
+ */
+ if (strcmp(dp->d_name + len + 1, "0-") == 0)
+ addlink(&head, dirname, dp->d_name, -1);
+ else if ((suffix = strtol(dp->d_name + len + 1,
+ &endptr, 10)) >= 0 && *endptr == '\0')
+ addlink(&head, dirname, dp->d_name, suffix);
+ }
+
+ (void) closedir(dirp);
+
+ return (head);
+}
+
int
main(int argc, char *argv[])
{
@@ -469,6 +554,8 @@ main(int argc, char *argv[])
fmd_log_t *lp;
int c, err;
off64_t off = 0;
+ ulong_t recs;
+ struct loglink *rotated_logs = NULL, *llp;
g_pname = argv[0];
@@ -553,6 +640,13 @@ main(int argc, char *argv[])
if (*ifile == '\0') {
(void) snprintf(ifile, sizeof (ifile), "%s/var/fm/fmd/%slog",
g_root ? g_root : "", opt_e && !opt_u ? "err" : "flt");
+ /*
+ * logadm may rotate the logs. When no input file is specified,
+ * we try to dump all the rotated logs as well in the right
+ * order.
+ */
+ if (!opt_H && off == 0)
+ rotated_logs = get_rotated_logs(ifile);
} else if (g_root != NULL) {
(void) fprintf(stderr, "%s: -R option is not appropriate "
"when file operand is present\n", g_pname);
@@ -640,14 +734,40 @@ main(int argc, char *argv[])
farg = &lyr;
}
+ for (llp = rotated_logs; llp != NULL; llp = llp->next) {
+ fmd_log_t *rlp;
+
+ if ((rlp = fmd_log_open(FMD_LOG_VERSION, llp->path, &err))
+ == NULL) {
+ (void) fprintf(stderr, "%s: failed to open %s: %s\n",
+ g_pname, llp->path, fmd_log_errmsg(NULL, err));
+ g_errs++;
+ continue;
+ }
+
+ recs = 0;
+ if (fmd_log_xiter(rlp, iflags, filtc, filtv,
+ func, error, farg, &recs) != 0) {
+ (void) fprintf(stderr,
+ "%s: failed to dump %s: %s\n", g_pname, llp->path,
+ fmd_log_errmsg(rlp, fmd_log_errno(rlp)));
+ g_errs++;
+ }
+ g_recs += recs;
+
+ fmd_log_close(rlp);
+ }
+
do {
+ recs = 0;
if (fmd_log_xiter(lp, iflags, filtc, filtv,
- func, error, farg, &g_recs) != 0) {
+ func, error, farg, &recs) != 0) {
(void) fprintf(stderr,
"%s: failed to dump %s: %s\n", g_pname, ifile,
fmd_log_errmsg(lp, fmd_log_errno(lp)));
g_errs++;
}
+ g_recs += recs;
if (opt_f)
(void) sleep(1);
diff --git a/usr/src/cmd/fm/modules/common/cpumem-retire/cma_main.c b/usr/src/cmd/fm/modules/common/cpumem-retire/cma_main.c
index c30a9f90d0..3c6c172e58 100644
--- a/usr/src/cmd/fm/modules/common/cpumem-retire/cma_main.c
+++ b/usr/src/cmd/fm/modules/common/cpumem-retire/cma_main.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -411,9 +411,7 @@ cma_recv_list(fmd_hdl_t *hdl, nvlist_t *nvl, const char *class)
uint_t keepopen;
int err = 0;
nvlist_t *asru = NULL;
-#ifndef i386
uint32_t index;
-#endif
err |= nvlist_lookup_string(nvl, FM_SUSPECT_UUID, &uuid);
err |= nvlist_lookup_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST,
@@ -456,7 +454,6 @@ cma_recv_list(fmd_hdl_t *hdl, nvlist_t *nvl, const char *class)
}
}
-#ifndef i386
/*
* Do not close the case if we are handling cache faults.
*/
@@ -469,7 +466,6 @@ cma_recv_list(fmd_hdl_t *hdl, nvlist_t *nvl, const char *class)
}
}
}
-#endif
if (!keepopen && strcmp(class, FM_LIST_REPAIRED_CLASS) == 0)
fmd_case_uuresolved(hdl, uuid);
diff --git a/usr/src/lib/fm/topo/libtopo/common/libtopo.h b/usr/src/lib/fm/topo/libtopo/common/libtopo.h
index 035510dc31..5ff7839b13 100644
--- a/usr/src/lib/fm/topo/libtopo/common/libtopo.h
+++ b/usr/src/lib/fm/topo/libtopo/common/libtopo.h
@@ -29,6 +29,7 @@
#include <sys/nvpair.h>
#include <stdio.h>
+#include <libdevinfo.h>
#ifdef __cplusplus
extern "C" {
@@ -70,6 +71,8 @@ extern topo_walk_t *topo_walk_init(topo_hdl_t *, const char *, topo_walk_cb_t,
void *, int *);
extern int topo_walk_step(topo_walk_t *, int);
extern void topo_walk_fini(topo_walk_t *);
+extern di_node_t topo_hdl_devinfo(topo_hdl_t *);
+extern di_prom_handle_t topo_hdl_prominfo(topo_hdl_t *);
/*
* Walk status returned from walker
diff --git a/usr/src/lib/fm/topo/libtopo/common/mapfile-vers b/usr/src/lib/fm/topo/libtopo/common/mapfile-vers
index c633a2646f..91f96bc860 100644
--- a/usr/src/lib/fm/topo/libtopo/common/mapfile-vers
+++ b/usr/src/lib/fm/topo/libtopo/common/mapfile-vers
@@ -50,11 +50,13 @@ SUNWprivate {
topo_fmri_unretire;
topo_fmri_unusable;
topo_hdl_alloc;
+ topo_hdl_devinfo;
topo_hdl_errmsg;
topo_hdl_errno;
topo_hdl_free;
topo_hdl_nvalloc;
topo_hdl_nvdup;
+ topo_hdl_prominfo;
topo_hdl_strdup;
topo_hdl_strfree;
topo_hdl_zalloc;
diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_mod.c b/usr/src/lib/fm/topo/libtopo/common/topo_mod.c
index 5876f6e0f8..61331c0b50 100644
--- a/usr/src/lib/fm/topo/libtopo/common/topo_mod.c
+++ b/usr/src/lib/fm/topo/libtopo/common/topo_mod.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -615,17 +615,6 @@ topo_mod_setdebug(topo_mod_t *mod)
mod->tm_debug = 1;
}
-di_node_t
-topo_mod_devinfo(topo_mod_t *mod)
-{
- topo_hdl_t *thp = mod->tm_hdl;
-
- if (thp->th_di == DI_NODE_NIL)
- thp->th_di = di_init("/", DINFOCPYALL);
-
- return (thp->th_di);
-}
-
ipmi_handle_t *
topo_mod_ipmi_hold(topo_mod_t *mod)
{
@@ -655,15 +644,16 @@ topo_mod_ipmi_rele(topo_mod_t *mod)
(void) pthread_mutex_unlock(&thp->th_ipmi_lock);
}
+di_node_t
+topo_mod_devinfo(topo_mod_t *mod)
+{
+ return (topo_hdl_devinfo(mod->tm_hdl));
+}
+
di_prom_handle_t
topo_mod_prominfo(topo_mod_t *mod)
{
- topo_hdl_t *thp = mod->tm_hdl;
-
- if (thp->th_pi == DI_PROM_HANDLE_NIL)
- thp->th_pi = di_prom_init();
-
- return (thp->th_pi);
+ return (topo_hdl_prominfo(mod->tm_hdl));
}
void
diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_snap.c b/usr/src/lib/fm/topo/libtopo/common/topo_snap.c
index db44b12262..66db84a5a4 100644
--- a/usr/src/lib/fm/topo/libtopo/common/topo_snap.c
+++ b/usr/src/lib/fm/topo/libtopo/common/topo_snap.c
@@ -285,12 +285,31 @@ topo_snap_create(topo_hdl_t *thp, int *errp)
uuid_generate(uuid);
uuid_unparse(uuid, thp->th_uuid);
+ if ((ustr = topo_hdl_strdup(thp, thp->th_uuid)) == NULL) {
+ *errp = ETOPO_NOMEM;
+ topo_hdl_unlock(thp);
+ return (NULL);
+ }
+
+ thp->th_di = di_init("/", DI_CACHE_SNAPSHOT_FLAGS | DINFOCLEANUP);
+ thp->th_pi = di_prom_init();
if (topo_tree_enum_all(thp) < 0) {
topo_dprintf(thp, TOPO_DBG_ERR, "enumeration failure: %s\n",
topo_hdl_errmsg(thp));
if (topo_hdl_errno(thp) == ETOPO_ENUM_FATAL) {
*errp = thp->th_errno;
+
+ if (thp->th_di != DI_NODE_NIL) {
+ di_fini(thp->th_di);
+ thp->th_di = DI_NODE_NIL;
+ }
+ if (thp->th_pi != DI_PROM_HANDLE_NIL) {
+ di_prom_fini(thp->th_pi);
+ thp->th_pi = DI_PROM_HANDLE_NIL;
+ }
+
+ topo_hdl_strfree(thp, ustr);
topo_hdl_unlock(thp);
return (NULL);
}
@@ -304,12 +323,6 @@ topo_snap_create(topo_hdl_t *thp, int *errp)
ipmi_errmsg(thp->th_ipmi));
}
- if ((ustr = topo_hdl_strdup(thp, thp->th_uuid)) == NULL)
- *errp = ETOPO_NOMEM;
-
- thp->th_di = DI_NODE_NIL;
- thp->th_pi = DI_PROM_HANDLE_NIL;
-
topo_hdl_unlock(thp);
return (ustr);
@@ -437,6 +450,19 @@ topo_snap_destroy(topo_hdl_t *thp)
}
+ /*
+ * Clean-up our cached devinfo and prom tree handles.
+ */
+ if (thp->th_di != DI_NODE_NIL) {
+ di_fini(thp->th_di);
+ thp->th_di = DI_NODE_NIL;
+ }
+ if (thp->th_pi != DI_PROM_HANDLE_NIL) {
+ di_prom_fini(thp->th_pi);
+ thp->th_pi = DI_PROM_HANDLE_NIL;
+ }
+
+
if (thp->th_uuid != NULL) {
topo_hdl_free(thp, thp->th_uuid, TOPO_UUID_SIZE);
thp->th_uuid = NULL;
@@ -711,3 +737,15 @@ topo_walk_bottomup(topo_walk_t *wp, int flag)
return (status);
}
+
+di_node_t
+topo_hdl_devinfo(topo_hdl_t *thp)
+{
+ return (thp == NULL ? DI_NODE_NIL : thp->th_di);
+}
+
+di_prom_handle_t
+topo_hdl_prominfo(topo_hdl_t *thp)
+{
+ return (thp == NULL ? DI_PROM_HANDLE_NIL : thp->th_pi);
+}
diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_tree.c b/usr/src/lib/fm/topo/libtopo/common/topo_tree.c
index 515fb3551c..5ecb564ebf 100644
--- a/usr/src/lib/fm/topo/libtopo/common/topo_tree.c
+++ b/usr/src/lib/fm/topo/libtopo/common/topo_tree.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Topology Trees
*
@@ -195,20 +193,6 @@ topo_tree_enum(topo_hdl_t *thp, ttree_t *tp)
}
}
- /*
- * It would be nice to leave the devinfo and prominfo trees
- * active but the interfaces consume copious amounts of memory
- * while searching for property information
- */
- if (thp->th_di != DI_NODE_NIL) {
- di_fini(thp->th_di);
- thp->th_di = DI_NODE_NIL;
- }
- if (thp->th_pi != DI_PROM_HANDLE_NIL) {
- di_prom_fini(thp->th_pi);
- thp->th_pi = DI_PROM_HANDLE_NIL;
- }
-
if (rv != 0)
return (topo_hdl_seterrno(thp, ETOPO_ENUM_NOMAP));
diff --git a/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c b/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c
index 1244f5d603..347c70e9c0 100644
--- a/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c
+++ b/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -309,7 +309,8 @@ create_chip(topo_mod_t *mod, tnode_t *pnode, topo_instance_t min,
nvlist_t *fmri = NULL;
int err, nerr = 0;
int32_t fms[3];
- const char *vendor = NULL;
+ const char *vendor;
+ boolean_t create_mc = B_FALSE;
if ((err = nvlist_lookup_int32(cpu, FM_PHYSCPU_INFO_CHIP_ID, &chipid))
!= 0) {
@@ -351,6 +352,8 @@ create_chip(topo_mod_t *mod, tnode_t *pnode, topo_instance_t min,
if (topo_node_range_create(mod, chip, CORE_NODE_NAME,
0, 255) != 0)
return (-1);
+
+ create_mc = B_TRUE;
}
err = create_core(mod, chip, cpu, auth);
@@ -359,11 +362,13 @@ create_chip(topo_mod_t *mod, tnode_t *pnode, topo_instance_t min,
* Create memory-controller node under a chip for architectures
* that may have on-chip memory-controller(s).
*/
- if (vendor != NULL && strcmp(vendor, "AuthenticAMD") == 0)
- amd_mc_create(mod, chip, MCT_NODE_NAME, auth,
- fms[0], fms[1], fms[2], &nerr);
- else if (!mc_offchip)
- onchip_mc_create(mod, chip, MCT_NODE_NAME, auth);
+ if (create_mc) {
+ if (strcmp(vendor, "AuthenticAMD") == 0)
+ amd_mc_create(mod, chip, MCT_NODE_NAME, auth,
+ fms[0], fms[1], fms[2], &nerr);
+ else if (!mc_offchip)
+ onchip_mc_create(mod, chip, MCT_NODE_NAME, auth);
+ }
return (err == 0 && nerr == 0 ? 0 : -1);
}
diff --git a/usr/src/uts/common/os/ndifm.c b/usr/src/uts/common/os/ndifm.c
index b00dae43a0..44e004ae50 100644
--- a/usr/src/uts/common/os/ndifm.c
+++ b/usr/src/uts/common/os/ndifm.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -429,7 +429,6 @@ ndi_fmc_entry_error(dev_info_t *dip, int flag, ddi_fm_error_t *derr,
ddi_fm_dma_err_get(dp, derr, DDI_FME_VERSION);
derr->fme_dma_handle = dp;
}
- break;
}
mutex_exit(&fcp->fc_lock);
}