diff options
author | sethg <none@none> | 2006-06-14 22:07:09 -0700 |
---|---|---|
committer | sethg <none@none> | 2006-06-14 22:07:09 -0700 |
commit | 7a0b67e3ef0ce92ca436e68c45383a76e14311a0 (patch) | |
tree | 90a8cb63acc5ddfbfe07172e73534552d083c902 | |
parent | 3ee0e49223f178da635734759b9167f924321ff0 (diff) | |
download | illumos-joyent-7a0b67e3ef0ce92ca436e68c45383a76e14311a0.tar.gz |
6438703 sfx4500-disk: Incorporate additional code review comments
13 files changed, 263 insertions, 231 deletions
diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/diskmon_conf.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/diskmon_conf.c index 7274cc39c5..bf7901a7a4 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/diskmon_conf.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/diskmon_conf.c @@ -37,7 +37,6 @@ #include <string.h> #include <strings.h> #include <errno.h> -#include <assert.h> #include <limits.h> #include <pthread.h> @@ -197,7 +196,7 @@ void link_indicator(indicator_t **first, indicator_t *to_add) { indicator_t *travptr; - assert(first != NULL); + dm_assert(first != NULL); if (*first == NULL) *first = to_add; @@ -240,7 +239,7 @@ void link_indaction(ind_action_t **first, ind_action_t *to_add) { ind_action_t *travptr; - assert(first != NULL); + dm_assert(first != NULL); if (*first == NULL) *first = to_add; @@ -283,7 +282,7 @@ void link_indrule(indrule_t **first, indrule_t *to_add) { indrule_t *travptr; - assert(first != NULL); + dm_assert(first != NULL); if (*first == NULL) *first = to_add; @@ -349,7 +348,7 @@ new_diskmon(nvlist_t *app_props, indicator_t *indp, indrule_t *indrp, dmp->ind_list = indp; dmp->indrule_list = indrp; - assert(pthread_mutex_init(&dmp->manager_mutex, NULL) == 0); + dm_assert(pthread_mutex_init(&dmp->manager_mutex, NULL) == 0); dmp->state = HPS_UNKNOWN; @@ -358,9 +357,9 @@ new_diskmon(nvlist_t *app_props, indicator_t *indp, indrule_t *indrp, dmp->fmip = NULL; dmp->faults_outstanding = B_FALSE; - assert(pthread_mutex_init(&dmp->fault_indicator_mutex, NULL) == 0); + dm_assert(pthread_mutex_init(&dmp->fault_indicator_mutex, NULL) == 0); dmp->fault_indicator_state = INDICATOR_UNKNOWN; - assert(pthread_mutex_init(&dmp->disk_faults_mutex, NULL) == 0); + dm_assert(pthread_mutex_init(&dmp->disk_faults_mutex, NULL) == 0); dmp->disk_faults = DISK_FAULT_SOURCE_NONE; dmp->due = (time_t)0; dmp->fault_inject_count = 0; @@ -373,7 +372,7 @@ new_diskmon(nvlist_t *app_props, indicator_t *indp, indrule_t *indrp, dmp->asru_fmri = NULL; dmp->fru_fmri = NULL; - assert(pthread_mutex_init(&dmp->fru_mutex, NULL) == 0); + dm_assert(pthread_mutex_init(&dmp->fru_mutex, NULL) == 0); dmp->frup = NULL; dmp->next = NULL; @@ -770,7 +769,7 @@ print_props(nvlist_t *nvlp, FILE *fp, char *prefix) char *name, *str; while (nvp != NULL) { - assert(nvpair_type(nvp) == DATA_TYPE_STRING); + dm_assert(nvpair_type(nvp) == DATA_TYPE_STRING); name = nvpair_name(nvp); (void) nvlist_lookup_string(nvlp, name, &str); (void) fprintf(fp, "%s%s = \"%s\"\n", prefix, name, str); @@ -837,7 +836,7 @@ print_cfgdata(cfgdata_t *cfgp, FILE *fp, char *prefix) int config_init(void) { - if (topo_init_configuration() == 0) { + if (init_configuration_from_topo() == 0) { config_data = new_cfgdata(NULL, NULL); return (0); } @@ -858,7 +857,7 @@ config_get(fmd_hdl_t *hdl, const fmd_prop_t *fmd_props) u64 = fmd_prop_get_int32(hdl, GLOBAL_PROP_LOG_LEVEL); g_verbose = (int)u64; - err = topo_update_configuration(NULL); + err = update_configuration_from_topo(NULL); /* Pull in the properties from the DE configuration file */ while (fmd_props[i].fmdp_name != NULL) { @@ -914,7 +913,7 @@ config_get(fmd_hdl_t *hdl, const fmd_prop_t *fmd_props) void config_fini(void) { - topo_fini_configuration(); + fini_configuration_from_topo(); cfgdata_free(config_data); config_data = NULL; } diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/fault_analyze.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/fault_analyze.c index c2de1f34a6..de79ac11f8 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/fault_analyze.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/fault_analyze.c @@ -28,7 +28,6 @@ #include <sys/types.h> #include <sys/byteorder.h> -#include <assert.h> #include <fcntl.h> #include <limits.h> #include <stdlib.h> @@ -164,7 +163,7 @@ dm_get_disk_logphys(diskmon_t *diskp, int *buflen) path = (char *)dm_prop_lookup(diskp->props, DISK_PROP_DEVPATH); - assert(path != NULL); + dm_assert(path != NULL); *buflen = strlen(path) + 1; path = dstrdup(path); @@ -245,8 +244,8 @@ disk_mode_select(int cdb_len, int fd, uchar_t page_code, int options, int senselen = sizeof (struct scsi_extended_sense); struct mode_page *mp = (struct mode_page *)buf; - assert(cdb_len == MODE_CMD_LEN_6 || cdb_len == MODE_CMD_LEN_10); - assert(headers->length == cdb_len); + dm_assert(cdb_len == MODE_CMD_LEN_6 || cdb_len == MODE_CMD_LEN_10); + dm_assert(headers->length == cdb_len); bzero(&sense, sizeof (struct scsi_extended_sense)); @@ -291,7 +290,7 @@ disk_mode_sense(int cdb_len, int fd, uchar_t page_code, uchar_t pc, struct scsi_extended_sense sense; int senselen = sizeof (struct scsi_extended_sense); - assert(cdb_len == MODE_CMD_LEN_6 || cdb_len == MODE_CMD_LEN_10); + dm_assert(cdb_len == MODE_CMD_LEN_6 || cdb_len == MODE_CMD_LEN_10); bzero(&sense, sizeof (struct scsi_extended_sense)); @@ -925,7 +924,7 @@ new_disk_fault_info(void) fmi->options = opts; - assert(pthread_mutex_init(&fmi->fault_data_mutex, NULL) == 0); + dm_assert(pthread_mutex_init(&fmi->fault_data_mutex, NULL) == 0); fmi->fault_list = NULL; return (fmi); @@ -953,7 +952,7 @@ static void free_disk_fault_info(fault_monitor_info_t **fmipp) { free_disk_fault_list(*fmipp); - assert(pthread_mutex_destroy(&(*fmipp)->fault_data_mutex) == 0); + dm_assert(pthread_mutex_destroy(&(*fmipp)->fault_data_mutex) == 0); dfree(*fmipp, sizeof (fault_monitor_info_t)); *fmipp = NULL; } @@ -1479,9 +1478,9 @@ disk_fault_uninit(diskmon_t *diskinfop) free_disk_fault_list(diskinfop->fmip); free_disk_fault_info(&diskinfop->fmip); } - assert(pthread_mutex_lock(&diskinfop->disk_faults_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskinfop->disk_faults_mutex) == 0); diskinfop->disk_faults = DISK_FAULT_SOURCE_NONE; - assert(pthread_mutex_unlock(&diskinfop->disk_faults_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskinfop->disk_faults_mutex) == 0); } int @@ -1634,7 +1633,7 @@ disk_fault_analyze(diskmon_t *diskinfop) * Grab the fault list mutex here because any of the functions below * can add to it. */ - assert(pthread_mutex_lock(&fip->fault_data_mutex) == 0); + dm_assert(pthread_mutex_lock(&fip->fault_data_mutex) == 0); if (fault_analyze_logpages(fd, diskinfop, &i, &sk, &asc, &ascq) != 0) { disk_warn(diskinfop, "Error during %s log page analysis: " @@ -1661,7 +1660,7 @@ disk_fault_analyze(diskmon_t *diskinfop) */ if (before_disk_fault_srcs == fip->disk_fault_srcs) { - assert(pthread_mutex_unlock(&fip->fault_data_mutex) == 0); + dm_assert(pthread_mutex_unlock(&fip->fault_data_mutex) == 0); return (0); } @@ -1693,7 +1692,7 @@ disk_fault_analyze(diskmon_t *diskinfop) flt = flt->next; } - assert(pthread_mutex_unlock(&fip->fault_data_mutex) == 0); + dm_assert(pthread_mutex_unlock(&fip->fault_data_mutex) == 0); return (faults); } diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/fault_mgr.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/fault_mgr.c index f331a5509f..6caed02dca 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/fault_mgr.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/fault_mgr.c @@ -26,7 +26,6 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#include <assert.h> #include <atomic.h> #include <sys/types.h> #include <time.h> @@ -132,7 +131,7 @@ disk_fault_monitor_thread(void *vdisklistp) setup_fault_injection(disklistp, i); } - assert(pthread_mutex_lock(&g_fmt_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_fmt_mutex) == 0); while (g_fmt_req_state != TS_EXIT_REQUESTED) { /* @@ -143,7 +142,8 @@ disk_fault_monitor_thread(void *vdisklistp) while (g_fmt_req_state != TS_EXIT_REQUESTED && diskp != NULL) { curtime = time(0); - assert(pthread_mutex_lock(&diskp->manager_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskp->manager_mutex) + == 0); /* * If the disk is configured (it has a device node @@ -169,7 +169,7 @@ disk_fault_monitor_thread(void *vdisklistp) earliest_due = (earliest_due < 0) ? diskp->due : MIN(earliest_due, diskp->due); - assert(pthread_mutex_unlock(&diskp->manager_mutex) + dm_assert(pthread_mutex_unlock(&diskp->manager_mutex) == 0); diskp = diskp->next; @@ -194,7 +194,7 @@ disk_fault_monitor_thread(void *vdisklistp) (void) pthread_cond_timedwait(&g_fmt_cvar, &g_fmt_mutex, &tspec); } - assert(pthread_mutex_unlock(&g_fmt_mutex) == 0); + dm_assert(pthread_mutex_unlock(&g_fmt_mutex) == 0); log_msg(MM_FAULTMGR, "Fault monitor polling thread exiting...\n"); } @@ -216,9 +216,9 @@ collect_fault_monitor_thread(void) if (g_fmt_spawned) { g_fmt_req_state = TS_EXIT_REQUESTED; - assert(pthread_mutex_lock(&g_fmt_mutex) == 0); - assert(pthread_cond_broadcast(&g_fmt_cvar) == 0); - assert(pthread_mutex_unlock(&g_fmt_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_fmt_mutex) == 0); + dm_assert(pthread_cond_broadcast(&g_fmt_cvar) == 0); + dm_assert(pthread_mutex_unlock(&g_fmt_mutex) == 0); fmd_thr_signal(g_fm_hdl, g_fmt_tid); fmd_thr_destroy(g_fm_hdl, g_fmt_tid); g_fmt_req_state = TS_NOT_RUNNING; @@ -248,9 +248,9 @@ init_fault_manager(cfgdata_t *cfgdatap) void fault_manager_poke(void) { - assert(pthread_mutex_lock(&g_fmt_mutex) == 0); - assert(pthread_cond_broadcast(&g_fmt_cvar) == 0); - assert(pthread_mutex_unlock(&g_fmt_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_fmt_mutex) == 0); + dm_assert(pthread_cond_broadcast(&g_fmt_cvar) == 0); + dm_assert(pthread_mutex_unlock(&g_fmt_mutex) == 0); } /*ARGSUSED*/ diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/hotplug_mgr.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/hotplug_mgr.c index bef93fa7ef..4f02a8bf59 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/hotplug_mgr.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/hotplug_mgr.c @@ -38,7 +38,6 @@ #include <unistd.h> #include <time.h> #include <pthread.h> -#include <assert.h> #include <libsysevent.h> #include <sys/sysevent_impl.h> @@ -136,15 +135,15 @@ disk_ap_state_to_hotplug_state(diskmon_t *diskp) int len; boolean_t list_valid = B_FALSE; - assert(app != NULL); + dm_assert(app != NULL); ap_path[0] = app; if (config_list_ext_poll(1, ap_path, &list_array, &nlist) == CFGA_OK) { - assert(nlist == 1); - assert(strcmp(app, list_array[0].ap_phys_id) == 0); + dm_assert(nlist == 1); + dm_assert(strcmp(app, list_array[0].ap_phys_id) == 0); list_valid = B_TRUE; @@ -165,8 +164,8 @@ disk_ap_state_to_hotplug_state(diskmon_t *diskp) if (config_list_ext_poll(1, ap_path, &list_array, &nlist) == CFGA_OK) { - assert(nlist == 1); - assert(strcmp(devices_app, list_array[0].ap_phys_id) + dm_assert(nlist == 1); + dm_assert(strcmp(devices_app, list_array[0].ap_phys_id) == 0); list_valid = B_TRUE; @@ -293,8 +292,8 @@ disk_match_by_device_path(diskmon_t *disklistp, const char *dev_path) char tgtnum[MAXNAMELEN]; char finalpath[MAXPATHLEN]; char devicepath[MAXPATHLEN]; - assert(disklistp != NULL); - assert(dev_path != NULL); + dm_assert(disklistp != NULL); + dm_assert(dev_path != NULL); if (strncmp(dev_path, DEVICES_PREFIX, 8) == 0) dev_path += 8; @@ -309,7 +308,7 @@ disk_match_by_device_path(diskmon_t *disklistp, const char *dev_path) while (disklistp != NULL) { char *app = (char *)dm_prop_lookup(disklistp->app_props, DISK_AP_PROP_APID); - assert(app != NULL); + dm_assert(app != NULL); /* * The disk device path is of the form: @@ -323,10 +322,10 @@ disk_match_by_device_path(diskmon_t *disklistp, const char *dev_path) /* Get the target number from the disk path: */ p = strrchr(dev_path, '/'); - assert(p != NULL); + dm_assert(p != NULL); p = strchr(p, '@'); - assert(p != NULL); + dm_assert(p != NULL); bzero(tgtnum, MAXNAMELEN); (void) strlcpy(tgtnum, p + 1, MAXNAMELEN); @@ -358,8 +357,8 @@ static diskmon_t * disk_match_by_ap_id(diskmon_t *disklistp, const char *ap_id) { const char *disk_ap_id; - assert(disklistp != NULL); - assert(ap_id != NULL); + dm_assert(disklistp != NULL); + dm_assert(ap_id != NULL); /* Match only the device-tree portion of the name */ if (strncmp(ap_id, DEVICES_PREFIX, 8 /* strlen("/devices") */) == 0) @@ -369,7 +368,7 @@ disk_match_by_ap_id(diskmon_t *disklistp, const char *ap_id) disk_ap_id = dm_prop_lookup(disklistp->app_props, DISK_AP_PROP_APID); - assert(disk_ap_id != NULL); + dm_assert(disk_ap_id != NULL); if (strcmp(disk_ap_id, ap_id) == 0) return (disklistp); @@ -465,11 +464,11 @@ dm_fmd_sysevent_thread(void *queuep) sysevent_event_t *sevevp; /* Signal the thread spawner that we're running */ - assert(pthread_mutex_lock(&g_event_handler_lock) == 0); + dm_assert(pthread_mutex_lock(&g_event_handler_lock) == 0); if (g_sysev_thread_state != TS_EXIT_REQUESTED) g_sysev_thread_state = TS_RUNNING; (void) pthread_cond_broadcast(&g_event_handler_cond); - assert(pthread_mutex_unlock(&g_event_handler_lock) == 0); + dm_assert(pthread_mutex_unlock(&g_event_handler_lock) == 0); while (g_sysev_thread_state != TS_EXIT_REQUESTED) { if ((sevevp = (sysevent_event_t *)queue_remove(qp)) == NULL) @@ -481,10 +480,10 @@ dm_fmd_sysevent_thread(void *queuep) } /* Signal the thread spawner that we've exited */ - assert(pthread_mutex_lock(&g_event_handler_lock) == 0); + dm_assert(pthread_mutex_lock(&g_event_handler_lock) == 0); g_sysev_thread_state = TS_EXITED; (void) pthread_cond_broadcast(&g_event_handler_cond); - assert(pthread_mutex_unlock(&g_event_handler_lock) == 0); + dm_assert(pthread_mutex_unlock(&g_event_handler_lock) == 0); log_msg(MM_HPMGR, "FMD sysevent handler thread exiting..."); } @@ -592,7 +591,7 @@ init_hotplug_manager() * Grab the event handler lock before spawning the thread so we can * wait for the thread to transition to the running state. */ - assert(pthread_mutex_lock(&g_event_handler_lock) == 0); + dm_assert(pthread_mutex_lock(&g_event_handler_lock) == 0); /* Create the sysevent handling thread */ g_sysev_tid = fmd_thr_create(g_fm_hdl, dm_fmd_sysevent_thread, @@ -602,7 +601,7 @@ init_hotplug_manager() while (g_sysev_thread_state != TS_RUNNING) (void) pthread_cond_wait(&g_event_handler_cond, &g_event_handler_lock); - assert(pthread_mutex_unlock(&g_event_handler_lock) == 0); + dm_assert(pthread_mutex_unlock(&g_event_handler_lock) == 0); if (init_sysevents() != 0) { log_warn_e("Error initializing sysevents"); @@ -622,13 +621,13 @@ cleanup_hotplug_manager() * Wait for the thread to exit before we can destroy * the event queue. */ - assert(pthread_mutex_lock(&g_event_handler_lock) == 0); + dm_assert(pthread_mutex_lock(&g_event_handler_lock) == 0); g_sysev_thread_state = TS_EXIT_REQUESTED; queue_add(g_sysev_queue, NULL); while (g_sysev_thread_state != TS_EXITED) (void) pthread_cond_wait(&g_event_handler_cond, &g_event_handler_lock); - assert(pthread_mutex_unlock(&g_event_handler_lock) == 0); + dm_assert(pthread_mutex_unlock(&g_event_handler_lock) == 0); (void) pthread_join(g_sysev_tid, NULL); fmd_thr_destroy(g_fm_hdl, g_sysev_tid); diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/ipmi_plugin.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/ipmi_plugin.c index 4d9925e90f..0915f014ee 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/ipmi_plugin.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/ipmi_plugin.c @@ -36,7 +36,6 @@ #include <sys/stropts.h> #include <inttypes.h> #include <stdio.h> -#include <assert.h> #include <fcntl.h> #include <unistd.h> #include <string.h> @@ -513,12 +512,12 @@ exec_action_handle(ipmi_action_handle_t *hdlp) return (DMPE_FAILURE); } - assert(pthread_mutex_lock(&ipmi_mutex) == 0); + dm_assert(pthread_mutex_lock(&ipmi_mutex) == 0); rv = ipmi_exec_action_with_replay(hdlp->netfn, hdlp->lun, hdlp->cmd, hdlp->databp, hdlp->datablen); - assert(pthread_mutex_unlock(&ipmi_mutex) == 0); + dm_assert(pthread_mutex_unlock(&ipmi_mutex) == 0); return (rv); } @@ -539,7 +538,7 @@ action_do(const char *actionString, void *arg, boolean_t exec, for (found_index = -1, i = 0; found_index == -1 && ipmi_cmd_tab[i].name != NULL; i++) { if (strcasecmp(cmd, ipmi_cmd_tab[i].name) == 0) { - assert(ipmi_cmd_tab[i].setupfn != NULL); + dm_assert(ipmi_cmd_tab[i].setupfn != NULL); rv = ipmi_cmd_tab[i].setupfn(props, &databp, &datablen, arg); found_index = i; @@ -555,17 +554,17 @@ action_do(const char *actionString, void *arg, boolean_t exec, if (exec && found_index != -1 && rv == DMPE_SUCCESS) { - assert(pthread_mutex_lock(&ipmi_mutex) == 0); + dm_assert(pthread_mutex_lock(&ipmi_mutex) == 0); rv = ipmi_exec_action_with_replay(netfn, lun, cmdno, databp, datablen); - assert(pthread_mutex_unlock(&ipmi_mutex) == 0); + dm_assert(pthread_mutex_unlock(&ipmi_mutex) == 0); dfree(databp, datablen); } else if (found_index != -1 && rv == DMPE_SUCCESS) { - assert(hdlpp != NULL); + dm_assert(hdlpp != NULL); *hdlpp = new_ipmi_action_handle(netfn, lun, cmdno, databp, datablen); @@ -864,8 +863,8 @@ bmc_replay_list_add(uint8_t netfn, uint8_t lun, uint8_t cmd, uint8_t *databp, } p->datablen = datablen; - assert(g_uu_pool_replay != NULL); - assert(g_uu_replaylist != NULL); + dm_assert(g_uu_pool_replay != NULL); + dm_assert(g_uu_replaylist != NULL); uu_list_node_init(p, &p->un_node, g_uu_pool_replay); /* The replay list is a queue, so add to its tail: */ (void) uu_list_insert_before(g_uu_replaylist, NULL, p); @@ -1198,8 +1197,8 @@ bmc_state_cache_add(uint8_t netfn, uint8_t lun, uint8_t cmd, uint8_t *databp, if (found_initfn) { - assert(g_uu_pool_cache != NULL); - assert(g_uu_cachelist != NULL); + dm_assert(g_uu_pool_cache != NULL); + dm_assert(g_uu_cachelist != NULL); uu_list_node_init(p, &p->un_node, g_uu_pool_cache); uu_list_insert(g_uu_cachelist, p, 0); @@ -1352,7 +1351,7 @@ bmc_monitor_thread(void *arg) struct timespec tspec; boolean_t refreshed; - assert(pthread_mutex_lock(&ipmi_mutex) == 0); + dm_assert(pthread_mutex_lock(&ipmi_mutex) == 0); while (!g_bmcmon_done) { if (bmc_state_refresh(&refreshed) == 0 && refreshed) { @@ -1376,7 +1375,7 @@ bmc_monitor_thread(void *arg) (void) pthread_cond_timedwait(&ipmi_cond, &ipmi_mutex, &tspec); } - assert(pthread_mutex_unlock(&ipmi_mutex) == 0); + dm_assert(pthread_mutex_unlock(&ipmi_mutex) == 0); log_msg(MM_PLUGIN, "BMC monitoring thread exiting..."); } @@ -1479,9 +1478,9 @@ ipmi_plugin_fini(void) { if (g_bmc_monitor_active) { g_bmcmon_done = B_TRUE; - assert(pthread_mutex_lock(&ipmi_mutex) == 0); + dm_assert(pthread_mutex_lock(&ipmi_mutex) == 0); (void) pthread_cond_broadcast(&ipmi_cond); - assert(pthread_mutex_unlock(&ipmi_mutex) == 0); + dm_assert(pthread_mutex_unlock(&ipmi_mutex) == 0); /* Signal the thread just in case it's blocked doing BMC I/O */ dm_plugin_thr_signal(g_bmcmon_tid); @@ -1515,7 +1514,7 @@ ipmi_bmc_send_cmd(uint8_t netfn, uint8_t lun, uint8_t cmd, bmc_reopen(); /* sendrecv_fn cannot be NULL at this point */ - assert(sendrecv_fn != NULL); + dm_assert(sendrecv_fn != NULL); rv = (*sendrecv_fn)(g_bmc_fd, netfn, lun, cmd, datap, datalen, rspp); return (rv); diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/plugin_mgr.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/plugin_mgr.c index 03125827bc..e0d7aac61c 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/plugin_mgr.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/plugin_mgr.c @@ -37,7 +37,6 @@ #include <stdlib.h> #include <dlfcn.h> #include <link.h> -#include <assert.h> #include <pthread.h> #include "util.h" @@ -192,7 +191,7 @@ load_dm_plugin(const char *protocol) fpi_out: if (plugin_loaded) { - assert(dmpip != NULL); + dm_assert(dmpip != NULL); dmpip->state = DMPS_LOADED; } else if (!plugin_loaded && dmpip != NULL) free_dm_plugin(&dmpip); @@ -262,7 +261,7 @@ protocol_to_dm_plugin(const char *protocol) * Traversing the plugin list must be atomic with * respect to plugin loads */ - assert(pthread_mutex_lock(&plugin_list_mutex) == 0); + dm_assert(pthread_mutex_lock(&plugin_list_mutex) == 0); plugin = plugin_list; @@ -278,7 +277,7 @@ protocol_to_dm_plugin(const char *protocol) plugin = (plugin == NULL) ? load_and_init_dm_plugin(protocol) : plugin; - assert(pthread_mutex_unlock(&plugin_list_mutex) == 0); + dm_assert(pthread_mutex_unlock(&plugin_list_mutex) == 0); return (plugin); } @@ -296,10 +295,10 @@ new_action_handle(const char *action, dm_plugin_t *pluginp) hip->handle = (dm_plugin_action_handle_t)NULL; /* Add the handle to the global list */ - assert(pthread_mutex_lock(&handle_list_mutex) == 0); + dm_assert(pthread_mutex_lock(&handle_list_mutex) == 0); hip->next = handle_list; handle_list = hip; - assert(pthread_mutex_unlock(&handle_list_mutex) == 0); + dm_assert(pthread_mutex_unlock(&handle_list_mutex) == 0); return (hip); } @@ -335,7 +334,7 @@ lookup_handle_by_action(const char *action) { dm_plugin_action_handle_impl_t *handle; - assert(pthread_mutex_lock(&handle_list_mutex) == 0); + dm_assert(pthread_mutex_lock(&handle_list_mutex) == 0); handle = handle_list; @@ -346,7 +345,7 @@ lookup_handle_by_action(const char *action) handle = handle->next; } - assert(pthread_mutex_unlock(&handle_list_mutex) == 0); + dm_assert(pthread_mutex_unlock(&handle_list_mutex) == 0); return (handle); } @@ -390,7 +389,7 @@ bind_action_handle(dm_plugin_t *dmpip, const char *action, hip = new_action_handle(action, dmpip); *hdlp = hip; - assert(dmpip->state == DMPS_INITED); + dm_assert(dmpip->state == DMPS_INITED); if (dmpip->ops->indicator_bind_handle) return (dmpip->ops->indicator_bind_handle(action, &hip->handle)); @@ -415,7 +414,7 @@ dm_pm_update_fru(const char *action, dm_fru_t *frup) dstrfree(protocol); if (dmpip != NULL) { - assert(dmpip->state == DMPS_INITED); + dm_assert(dmpip->state == DMPS_INITED); if (dmpip->ops->indicator_fru_update) return (dmpip->ops->indicator_fru_update(actionp, frup)); @@ -443,7 +442,7 @@ dm_pm_indicator_execute(const char *action) return (DMPE_FAILURE); } - assert(dmpip->state == DMPS_INITED); + dm_assert(dmpip->state == DMPS_INITED); if (dmpip->ops->indicator_execute) return (dmpip->ops->indicator_execute(hip->handle)); } diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/schg_mgr.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/schg_mgr.c index a1d342d5ee..5bbca4d064 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/schg_mgr.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/schg_mgr.c @@ -29,7 +29,6 @@ #include <string.h> #include <inttypes.h> #include <atomic.h> -#include <assert.h> #include <fm/fmd_api.h> #include <sys/fm/protocol.h> @@ -114,14 +113,14 @@ dm_fault_indicator_set(diskmon_t *diskp, ind_state_t istate) { const char *astring; - assert(pthread_mutex_lock(&diskp->fault_indicator_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskp->fault_indicator_mutex) == 0); /* * No need to execute redundant indicator actions */ if (istate == INDICATOR_UNKNOWN || diskp->fault_indicator_state == istate) { - assert(pthread_mutex_unlock(&diskp->fault_indicator_mutex) + dm_assert(pthread_mutex_unlock(&diskp->fault_indicator_mutex) == 0); return; } @@ -147,7 +146,7 @@ dm_fault_indicator_set(diskmon_t *diskp, ind_state_t istate) } } - assert(pthread_mutex_unlock(&diskp->fault_indicator_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskp->fault_indicator_mutex) == 0); } static void @@ -189,7 +188,7 @@ schg_execute_state_change_action(diskmon_t *diskp, hotplug_state_t oldstate, astring = lookup_action_string(diskp->ind_list, actions->ind_state, actions->ind_name); - assert(astring != NULL); + dm_assert(astring != NULL); log_msg(MM_SCHGMGR, "Executing action `%s'\n", astring); @@ -235,15 +234,15 @@ static void schg_update_fru_info(diskmon_t *diskp) { if (diskp->initial_configuration || - topo_update_configuration(diskp) == TOPO_SUCCESS) { + update_configuration_from_topo(diskp) == TOPO_SUCCESS) { diskp->initial_configuration = B_FALSE; - assert(pthread_mutex_lock(&diskp->fru_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskp->fru_mutex) == 0); if (diskp->frup != NULL) schg_send_fru_to_plugin(diskp, diskp->frup); else log_warn("frup unexpectedly went away: not updating " "FRU information for disk %s!\n", diskp->location); - assert(pthread_mutex_unlock(&diskp->fru_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskp->fru_mutex) == 0); } else { log_warn_e("Error retrieving FRU information " "for disk in %s", diskp->location); @@ -306,20 +305,20 @@ schg_consume_faults(diskmon_t *diskp) char *er_class; int e; - assert(diskp->fmip != NULL); + dm_assert(diskp->fmip != NULL); /* Use the same ENA for all current faults */ ena = dm_gen_ena(); - assert(pthread_mutex_lock(&diskp->fmip->fault_data_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskp->fmip->fault_data_mutex) == 0); faults = diskp->fmip->fault_list; /* Go through the list of faults, executing actions if present */ while (faults != NULL) { - assert(pthread_mutex_lock(&diskp->disk_faults_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskp->disk_faults_mutex) == 0); diskp->disk_faults |= faults->fault_src; - assert(pthread_mutex_unlock(&diskp->disk_faults_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskp->disk_faults_mutex) == 0); er_class = NULL; e = nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0); @@ -378,19 +377,19 @@ schg_consume_faults(diskmon_t *diskp) free_disk_fault_list(diskp->fmip); - assert(pthread_mutex_unlock(&diskp->fmip->fault_data_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskp->fmip->fault_data_mutex) == 0); } void block_state_change_events(void) { - assert(pthread_mutex_lock(&g_schgt_add_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_schgt_add_mutex) == 0); } void unblock_state_change_events(void) { - assert(pthread_mutex_unlock(&g_schgt_add_mutex) == 0); + dm_assert(pthread_mutex_unlock(&g_schgt_add_mutex) == 0); } static void @@ -441,18 +440,18 @@ disk_state_change_thread(void *vdisklistp) unblock_state_change_events(); - assert(pthread_mutex_lock(&g_schgt_state_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_schgt_state_mutex) == 0); if (g_schgt_state != TS_EXIT_REQUESTED) { g_schgt_state = TS_RUNNING; - assert(pthread_cond_broadcast(&g_schgt_state_cvar) == 0); + dm_assert(pthread_cond_broadcast(&g_schgt_state_cvar) == 0); } - assert(pthread_mutex_unlock(&g_schgt_state_mutex) == 0); + dm_assert(pthread_mutex_unlock(&g_schgt_state_mutex) == 0); while (g_schgt_state != TS_EXIT_REQUESTED) { if ((dscp = (disk_statechg_t *)queue_remove(g_schg_queue)) == NULL) { - assert(g_schgt_state == TS_EXIT_REQUESTED); + dm_assert(g_schgt_state == TS_EXIT_REQUESTED); continue; } @@ -574,7 +573,7 @@ disk_state_change_thread(void *vdisklistp) } - assert(pthread_mutex_lock(&diskp->manager_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskp->manager_mutex) == 0); /* * Make the new state visible to all observers @@ -594,7 +593,7 @@ disk_state_change_thread(void *vdisklistp) * When the disk is removed, the fault monitor state is * useless, so discard it. */ - assert(DISK_STATE(nextstate) != HPS_CONFIGURED); + dm_assert(DISK_STATE(nextstate) != HPS_CONFIGURED); disk_fault_uninit(diskp); @@ -606,13 +605,14 @@ disk_state_change_thread(void *vdisklistp) * other faults pending in the fault list, and that's * OK. */ - assert(pthread_mutex_lock(&diskp->disk_faults_mutex) + dm_assert(pthread_mutex_lock(&diskp->disk_faults_mutex) == 0); diskp->disk_faults = DISK_FAULT_SOURCE_NONE; - assert(pthread_mutex_unlock(&diskp->disk_faults_mutex) + dm_assert( + pthread_mutex_unlock(&diskp->disk_faults_mutex) == 0); } - assert(pthread_mutex_unlock(&diskp->manager_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskp->manager_mutex) == 0); if (poke_fault_manager) { @@ -642,10 +642,10 @@ disk_state_change_thread(void *vdisklistp) /* The caller is responsible for freeing the state change: */ free_statechange(dscp); } - assert(pthread_mutex_lock(&g_schgt_state_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_schgt_state_mutex) == 0); g_schgt_state = TS_EXITED; - assert(pthread_cond_broadcast(&g_schgt_state_cvar) == 0); - assert(pthread_mutex_unlock(&g_schgt_state_mutex) == 0); + dm_assert(pthread_cond_broadcast(&g_schgt_state_cvar) == 0); + dm_assert(pthread_mutex_unlock(&g_schgt_state_mutex) == 0); log_msg(MM_SCHGMGR, "State change thread exiting...\n"); } @@ -660,9 +660,9 @@ dm_state_change_nolock(diskmon_t *diskp, hotplug_state_t newstate) void dm_state_change(diskmon_t *diskp, hotplug_state_t newstate) { - assert(pthread_mutex_lock(&g_schgt_add_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_schgt_add_mutex) == 0); dm_state_change_nolock(diskp, newstate); - assert(pthread_mutex_unlock(&g_schgt_add_mutex) == 0); + dm_assert(pthread_mutex_unlock(&g_schgt_add_mutex) == 0); } int @@ -671,7 +671,7 @@ init_state_change_manager(cfgdata_t *cfgdatap) /* new_queue() is guaranteed to succeed */ g_schg_queue = new_queue(B_TRUE, dmalloc, dfree, free_statechange); - assert(pthread_mutex_lock(&g_schgt_state_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_schgt_state_mutex) == 0); g_schg_tid = fmd_thr_create(g_fm_hdl, disk_state_change_thread, cfgdatap->disk_list); @@ -688,7 +688,7 @@ init_state_change_manager(cfgdata_t *cfgdatap) &g_schgt_state_mutex); } - assert(pthread_mutex_unlock(&g_schgt_state_mutex) == 0); + dm_assert(pthread_mutex_unlock(&g_schgt_state_mutex) == 0); return (0); } @@ -702,11 +702,11 @@ cleanup_state_change_manager(cfgdata_t *cfgdatap) g_schgt_state = TS_EXIT_REQUESTED; queue_add(g_schg_queue, NULL); - assert(pthread_mutex_lock(&g_schgt_state_mutex) == 0); + dm_assert(pthread_mutex_lock(&g_schgt_state_mutex) == 0); while (g_schgt_state != TS_EXITED) - assert(pthread_cond_wait(&g_schgt_state_cvar, + dm_assert(pthread_cond_wait(&g_schgt_state_cvar, &g_schgt_state_mutex) == 0); - assert(pthread_mutex_unlock(&g_schgt_state_mutex) == 0); + dm_assert(pthread_mutex_unlock(&g_schgt_state_mutex) == 0); (void) pthread_join(g_schg_tid, NULL); fmd_thr_destroy(g_fm_hdl, g_schg_tid); queue_free(&g_schg_queue); diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/scsi_util.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/scsi_util.c index c446aa4d37..a87fc34441 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/scsi_util.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/scsi_util.c @@ -39,7 +39,6 @@ #include <unistd.h> #include <stropts.h> #include <alloca.h> -#include <assert.h> #include "util.h" #include "sfx4500-disk.h" @@ -1270,8 +1269,8 @@ uscsi_mode_sense(int fd, int page_code, int page_control, caddr_t page_data, int maximum; char *pc; - assert(page_size >= 0 && page_size < 256); - assert(page_control == PC_CURRENT || + dm_assert(page_size >= 0 && page_size < 256); + dm_assert(page_control == PC_CURRENT || page_control == PC_CHANGEABLE || page_control == PC_DEFAULT || page_control == PC_SAVED); @@ -1413,8 +1412,8 @@ uscsi_mode_sense_10(int fd, int page_code, int page_control, ushort_t length, bdesc_length; char *pc; - assert(page_size >= 0 && page_size < UINT16_MAX); - assert(page_control == PC_CURRENT || + dm_assert(page_size >= 0 && page_size < UINT16_MAX); + dm_assert(page_control == PC_CURRENT || page_control == PC_CHANGEABLE || page_control == PC_DEFAULT || page_control == PC_SAVED); @@ -1556,10 +1555,10 @@ uscsi_mode_select(int fd, int page_code, int options, caddr_t page_data, int status; char *s; - assert(((struct mode_page *)page_data)->ps == 0); - assert(header->mode_header.length == 0); - assert(header->mode_header.device_specific == 0); - assert((options & ~(MODE_SELECT_SP|MODE_SELECT_PF)) == 0); + dm_assert(((struct mode_page *)page_data)->ps == 0); + dm_assert(header->mode_header.length == 0); + dm_assert(header->mode_header.device_specific == 0); + dm_assert((options & ~(MODE_SELECT_SP|MODE_SELECT_PF)) == 0); /* * Allocate a buffer for the mode select header and data @@ -1659,10 +1658,10 @@ uscsi_mode_select_10(int fd, int page_code, int options, int status; char *s; - assert(((struct mode_page *)page_data)->ps == 0); - assert(header->mode_header.length == 0); - assert(header->mode_header.device_specific == 0); - assert((options & ~(MODE_SELECT_SP|MODE_SELECT_PF)) == 0); + dm_assert(((struct mode_page *)page_data)->ps == 0); + dm_assert(header->mode_header.length == 0); + dm_assert(header->mode_header.device_specific == 0); + dm_assert((options & ~(MODE_SELECT_SP|MODE_SELECT_PF)) == 0); /* * Allocate a buffer for the mode select header and data @@ -1759,8 +1758,8 @@ uscsi_log_sense(int fd, int page_code, int page_control, caddr_t page_data, ushort_t len; char *pc; - assert(page_size >= 0 && page_size < UINT16_MAX); - assert(page_control == PC_CURRENT || + dm_assert(page_size >= 0 && page_size < UINT16_MAX); + dm_assert(page_control == PC_CURRENT || page_control == PC_CHANGEABLE || page_control == PC_DEFAULT || page_control == PC_SAVED); diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/sfx4500-disk.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/sfx4500-disk.c index 1c25c874ee..2da359c392 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/sfx4500-disk.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/sfx4500-disk.c @@ -41,7 +41,6 @@ #include <signal.h> #include <unistd.h> #include <pthread.h> -#include <assert.h> #include <libnvpair.h> #include <fm/fmd_api.h> #include <fm/fmd_fmri.h> @@ -114,13 +113,19 @@ count_disks(diskmon_t *disklistp) static int diskmon_init(void) { + /* + * Block the generation of state change events (generated by the + * hotplug manager thread) here; they will be unblocked after the + * state change manager thread is ready to accept state changes + * (shortly after it starts). + */ + block_state_change_events(); + if (init_plugin_manager() != 0) goto cleanup; else g_init_state |= PLUGIN_MGR_INITTED; - block_state_change_events(); - if (init_hotplug_manager() != 0) goto cleanup; else @@ -225,7 +230,7 @@ dm_fault_execute_actions(diskmon_t *diskp, disk_flt_src_e fsrc) } static void -diskmon_agent(fmd_hdl_t *hdl, nvlist_t *nvl, fm_list_type_t list_type) +diskmon_agent_repair(fmd_hdl_t *hdl, nvlist_t *nvl) { char *uuid = NULL; nvlist_t **nva; @@ -235,77 +240,77 @@ diskmon_agent(fmd_hdl_t *hdl, nvlist_t *nvl, fm_list_type_t list_type) nvlist_t *fltnvl; int err = 0; - switch (list_type) { - - case LT_REPAIRED: - - err |= nvlist_lookup_string(nvl, FM_SUSPECT_UUID, &uuid); - err |= nvlist_lookup_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST, - &nva, &nvc); - if (err != 0) - return; - - while (nvc-- != 0) { + err |= nvlist_lookup_string(nvl, FM_SUSPECT_UUID, &uuid); + err |= nvlist_lookup_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST, + &nva, &nvc); + if (err != 0) + return; - fltnvl = *nva++; + while (nvc-- != 0) { - if (nvlist_lookup_nvlist(fltnvl, FM_FAULT_RESOURCE, - &fmri) != 0) - continue; + fltnvl = *nva++; - if ((diskp = dm_fmri_to_diskmon(hdl, fmri)) == NULL) - continue; + if (nvlist_lookup_nvlist(fltnvl, FM_FAULT_RESOURCE, &fmri) + != 0) + continue; - log_msg(MM_MAIN, "Disk %s repaired!\n", - diskp->location); + if ((diskp = dm_fmri_to_diskmon(hdl, fmri)) == NULL) + continue; - dm_fault_indicator_set(diskp, INDICATOR_OFF); + log_msg(MM_MAIN, "Disk %s repaired!\n", + diskp->location); - dm_state_change(diskp, HPS_REPAIRED); - } - - break; + dm_fault_indicator_set(diskp, INDICATOR_OFF); - case LT_SUSPECT: + dm_state_change(diskp, HPS_REPAIRED); + } +} - err |= nvlist_lookup_string(nvl, FM_SUSPECT_UUID, &uuid); - err |= nvlist_lookup_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST, - &nva, &nvc); - if (err != 0) - return; +static void +diskmon_agent_suspect(fmd_hdl_t *hdl, nvlist_t *nvl) +{ + char *uuid = NULL; + nvlist_t **nva; + uint_t nvc; + diskmon_t *diskp; + nvlist_t *fmri; + nvlist_t *fltnvl; + int err = 0; - while (nvc-- != 0 && !fmd_case_uuclosed(hdl, uuid)) { + err |= nvlist_lookup_string(nvl, FM_SUSPECT_UUID, &uuid); + err |= nvlist_lookup_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST, + &nva, &nvc); + if (err != 0) + return; - fltnvl = *nva++; + while (nvc-- != 0 && !fmd_case_uuclosed(hdl, uuid)) { - if (nvlist_lookup_nvlist(fltnvl, FM_FAULT_RESOURCE, - &fmri) != 0) - continue; + fltnvl = *nva++; - if ((diskp = dm_fmri_to_diskmon(hdl, fmri)) == NULL) - continue; + if (nvlist_lookup_nvlist(fltnvl, FM_FAULT_RESOURCE, &fmri) != 0) + continue; - /* Execute the actions associated with this fault */ - dm_fault_execute_actions(diskp, - nvl2fltsrc(hdl, fltnvl)); + if ((diskp = dm_fmri_to_diskmon(hdl, fmri)) == NULL) + continue; - /* - * If the fault wasn't generated by this module, send a - * state change event to the state change manager - */ - if (!dm_suspect_de_is_me(nvl)) - dm_state_change(diskp, HPS_FAULTED); + /* Execute the actions associated with this fault */ + dm_fault_execute_actions(diskp, nvl2fltsrc(hdl, fltnvl)); - /* Case is closed */ - fmd_case_uuclose(hdl, uuid); - } + /* + * If the fault wasn't generated by this module, send a + * state change event to the state change manager + */ + if (!dm_suspect_de_is_me(nvl)) + dm_state_change(diskp, HPS_FAULTED); + } - break; + if (!fmd_case_uuclosed(hdl, uuid)) { + /* Case is closed */ + fmd_case_uuclose(hdl, uuid); } } -/*ARGSUSED*/ static void diskmon_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) { @@ -329,12 +334,12 @@ diskmon_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) */ if (fmd_nvl_class_match(hdl, nvl, "list.repaired")) { - diskmon_agent(hdl, nvl, LT_REPAIRED); + diskmon_agent_repair(hdl, nvl); return; } else if (fmd_nvl_class_match(hdl, nvl, "list.suspect")) { - diskmon_agent(hdl, nvl, LT_SUSPECT); + diskmon_agent_suspect(hdl, nvl); return; } @@ -357,9 +362,9 @@ diskmon_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) /* Execute the actions associated with this fault */ dm_fault_execute_actions(diskp, fsrc); - assert(pthread_mutex_lock(&diskp->disk_faults_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskp->disk_faults_mutex) == 0); diskp->disk_faults |= fsrc; - assert(pthread_mutex_unlock(&diskp->disk_faults_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskp->disk_faults_mutex) == 0); /* * If the fault wasn't generated by this module, send a diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/topo_gather.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/topo_gather.c index 685bf71868..f9a6d75112 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/topo_gather.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/topo_gather.c @@ -32,7 +32,6 @@ * DE. */ -#include <assert.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> @@ -157,7 +156,7 @@ find_sfx4500_private_pgroup(topo_hdl_t *thp, tnode_t *node) nvpair_value_nvlist(nvp, &nvlp) != 0) continue; - assert(nvlp != NULL); + dm_assert(nvlp != NULL); pgroup_name = NULL; if (nonunique_nvlist_lookup_string(nvlp, @@ -307,7 +306,7 @@ topo_add_disk(topo_hdl_t *thp, tnode_t *node, diskmon_t *target_diskp) */ orig_cstr_len = strlen(cstr) + 1; p = strrchr(cstr, '/'); - assert(p != NULL); + dm_assert(p != NULL); *p = 0; if (nvlist_lookup_uint64(g_topo2diskmon, cstr, &ptr) != 0) { log_msg(MM_TOPO, "No diskmon for parent of node %p.\n", node); @@ -461,10 +460,10 @@ topo_add_disk(topo_hdl_t *thp, tnode_t *node, diskmon_t *target_diskp) } /* Add the fru information to the diskmon: */ - assert(pthread_mutex_lock(&diskp->fru_mutex) == 0); - assert(diskp->frup == NULL); + dm_assert(pthread_mutex_lock(&diskp->fru_mutex) == 0); + dm_assert(diskp->frup == NULL); diskp->frup = frup; - assert(pthread_mutex_unlock(&diskp->fru_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskp->fru_mutex) == 0); return (0); } @@ -531,7 +530,7 @@ topoprop_indrule_add(indrule_t **indrp, char *sts, char *acts) /* The state string is of the form "{STATE}>{STATE}" */ p = strchr(states, '>'); - assert(p != NULL); + dm_assert(p != NULL); *p = 0; strans.begin = str2dmstate(states); *p = '>'; @@ -631,10 +630,10 @@ topo_add_sata_port(topo_hdl_t *thp, tnode_t *node, diskmon_t *target_diskp) */ if (diskp->frup && (target_diskp == NULL || diskp == target_diskp)) { - assert(pthread_mutex_lock(&diskp->fru_mutex) == 0); + dm_assert(pthread_mutex_lock(&diskp->fru_mutex) == 0); dmfru_free(diskp->frup); diskp->frup = NULL; - assert(pthread_mutex_unlock(&diskp->fru_mutex) == 0); + dm_assert(pthread_mutex_unlock(&diskp->fru_mutex) == 0); } dstrfree(cstr); @@ -859,7 +858,7 @@ gather_topo_cfg(topo_hdl_t *thp, tnode_t *node, void *arg) int -topo_update_configuration(diskmon_t *diskp) +update_configuration_from_topo(diskmon_t *diskp) { int err; topo_hdl_t *thp; @@ -907,13 +906,13 @@ topo_update_configuration(diskmon_t *diskp) } int -topo_init_configuration(void) +init_configuration_from_topo(void) { return (nvlist_alloc(&g_topo2diskmon, NV_UNIQUE_NAME, 0)); } void -topo_fini_configuration(void) +fini_configuration_from_topo(void) { if (g_topo2diskmon) { nvlist_free(g_topo2diskmon); diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/topo_gather.h b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/topo_gather.h index 75028b4368..db4f0fbd8e 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/topo_gather.h +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/topo_gather.h @@ -44,9 +44,9 @@ extern "C" { #define TOPO_SNAP_ERROR 3 #define TOPO_OPEN_ERROR 4 -int topo_update_configuration(diskmon_t *diskp); -int topo_init_configuration(void); -void topo_fini_configuration(void); +int update_configuration_from_topo(diskmon_t *diskp); +int init_configuration_from_topo(void); +void fini_configuration_from_topo(void); diskmon_t *dm_fmri_to_diskmon(fmd_hdl_t *hdl, nvlist_t *fmri); #ifdef __cplusplus diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/util.c b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/util.c index 964157fbb5..c4cbd3fcb2 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/util.c +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/util.c @@ -35,7 +35,6 @@ #include <string.h> #include <stdlib.h> #include <pthread.h> -#include <assert.h> #include <smbios.h> #include <fm/fmd_api.h> @@ -165,9 +164,9 @@ log_dump(log_class_t cl, char *label, char *start, unsigned length) if ((g_verbose & cl) != cl) return; - assert(pthread_mutex_lock(&log_mutex) == 0); + dm_assert(pthread_mutex_lock(&log_mutex) == 0); dump(cl, label, start, length); - assert(pthread_mutex_unlock(&log_mutex) == 0); + dm_assert(pthread_mutex_unlock(&log_mutex) == 0); } static void @@ -175,13 +174,13 @@ verror(const char *fmt, va_list ap) { int error = errno; - assert(pthread_mutex_lock(&log_mutex) == 0); + dm_assert(pthread_mutex_lock(&log_mutex) == 0); fmd_hdl_vdebug(g_fm_hdl, fmt, ap); if (fmt[strlen(fmt) - 1] != '\n') fmd_hdl_debug(g_fm_hdl, ": %s\n", strerror(error)); - assert(pthread_mutex_unlock(&log_mutex) == 0); + dm_assert(pthread_mutex_unlock(&log_mutex) == 0); } static void @@ -189,23 +188,23 @@ vwarn_e(const char *fmt, va_list ap) { int error = errno; - assert(pthread_mutex_lock(&log_mutex) == 0); + dm_assert(pthread_mutex_lock(&log_mutex) == 0); fmd_hdl_debug(g_fm_hdl, "WARNING: "); fmd_hdl_vdebug(g_fm_hdl, fmt, ap); if (fmt[strlen(fmt) - 1] != '\n') fmd_hdl_debug(g_fm_hdl, ": %s\n", strerror(error)); - assert(pthread_mutex_unlock(&log_mutex) == 0); + dm_assert(pthread_mutex_unlock(&log_mutex) == 0); } static void vwarn(const char *fmt, va_list ap) { - assert(pthread_mutex_lock(&log_mutex) == 0); + dm_assert(pthread_mutex_lock(&log_mutex) == 0); fmd_hdl_debug(g_fm_hdl, "WARNING: "); fmd_hdl_vdebug(g_fm_hdl, fmt, ap); - assert(pthread_mutex_unlock(&log_mutex) == 0); + dm_assert(pthread_mutex_unlock(&log_mutex) == 0); } void @@ -216,13 +215,13 @@ vcont(log_class_t cl, const char *fmt, va_list ap) if ((g_verbose & cl) != cl) return; - assert(pthread_mutex_lock(&log_mutex) == 0); + dm_assert(pthread_mutex_lock(&log_mutex) == 0); fmd_hdl_vdebug(g_fm_hdl, fmt, ap); if (fmt[strlen(fmt) - 1] != '\n') fmd_hdl_debug(g_fm_hdl, ": %s\n", strerror(error)); - assert(pthread_mutex_unlock(&log_mutex) == 0); + dm_assert(pthread_mutex_unlock(&log_mutex) == 0); } static void @@ -246,11 +245,11 @@ log_msg(log_class_t cl, const char *fmt, ...) if ((g_verbose & cl) != cl) return; - assert(pthread_mutex_lock(&log_mutex) == 0); + dm_assert(pthread_mutex_lock(&log_mutex) == 0); va_start(ap, fmt); fmd_hdl_vdebug(g_fm_hdl, fmt, ap); va_end(ap); - assert(pthread_mutex_unlock(&log_mutex) == 0); + dm_assert(pthread_mutex_unlock(&log_mutex) == 0); } /*PRINTFLIKE1*/ @@ -335,7 +334,7 @@ queue_add(qu_t *qp, void *data) qnp->data = data; qnp->next = NULL; - assert(pthread_mutex_lock(&qp->mutex) == 0); + dm_assert(pthread_mutex_lock(&qp->mutex) == 0); if (qp->nodep == NULL) qp->nodep = qnp; @@ -350,8 +349,8 @@ queue_add(qu_t *qp, void *data) /* If the queue was empty, we need to wake people up */ if (qp->boe && qp->nodep == qnp) - assert(pthread_cond_broadcast(&qp->cvar) == 0); - assert(pthread_mutex_unlock(&qp->mutex) == 0); + dm_assert(pthread_cond_broadcast(&qp->cvar) == 0); + dm_assert(pthread_mutex_unlock(&qp->mutex) == 0); } void * @@ -360,7 +359,7 @@ queue_remove(qu_t *qp) void *rv = NULL; struct q_node *nextnode; - assert(pthread_mutex_lock(&qp->mutex) == 0); + dm_assert(pthread_mutex_lock(&qp->mutex) == 0); /* Wait while the queue is empty */ while (qp->boe && qp->nodep == NULL) { @@ -377,7 +376,7 @@ queue_remove(qu_t *qp) qp->nodep = nextnode; } - assert(pthread_mutex_unlock(&qp->mutex) == 0); + dm_assert(pthread_mutex_unlock(&qp->mutex) == 0); return (rv); } @@ -391,8 +390,8 @@ new_queue(boolean_t block_on_empty, void *(*nodealloc)(size_t), newqp->nalloc = nodealloc; newqp->nfree = nodefree; newqp->data_dealloc = data_deallocator; - assert(pthread_mutex_init(&newqp->mutex, NULL) == 0); - assert(pthread_cond_init(&newqp->cvar, NULL) == 0); + dm_assert(pthread_mutex_init(&newqp->mutex, NULL) == 0); + dm_assert(pthread_cond_init(&newqp->cvar, NULL) == 0); newqp->nodep = NULL; return (newqp); @@ -404,8 +403,8 @@ queue_free(qu_t **qpp) qu_t *qp = *qpp; void *item; - assert(pthread_mutex_destroy(&qp->mutex) == 0); - assert(pthread_cond_destroy(&qp->cvar) == 0); + dm_assert(pthread_mutex_destroy(&qp->mutex) == 0); + dm_assert(pthread_cond_destroy(&qp->cvar) == 0); qp->boe = B_FALSE; @@ -413,8 +412,26 @@ queue_free(qu_t **qpp) qp->data_dealloc(item); } - assert(qp->nodep == NULL); + dm_assert(qp->nodep == NULL); dfree(qp, sizeof (qu_t)); *qpp = NULL; } + +int +_dm_assert(const char *assertion, const char *file, int line, const char *func) +{ + /* + * No newline is appended to the assertion message so that + * errno can be translated for us by fmd_hdl_abort(). + */ + if (func) + fmd_hdl_abort(g_fm_hdl, "Assertion failed: " + "%s, file: %s, line: %d, function: %s", assertion, file, + line, func); + else + fmd_hdl_abort(g_fm_hdl, "Assertion failed: " + "%s, file: %s, line: %d", assertion, file, line); + /*NOTREACHED*/ + return (0); +} diff --git a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/util.h b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/util.h index 4848093835..8f57895131 100644 --- a/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/util.h +++ b/usr/src/cmd/fm/modules/i86pc/sfx4500-disk/util.h @@ -30,7 +30,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" /* - * Definitions for data structures used in the SCSI IE module + * Utility functions and macros */ #ifdef __cplusplus @@ -41,6 +41,23 @@ extern "C" { #include <stdarg.h> #include <time.h> +extern int _dm_assert(const char *assertion, const char *file, int line, + const char *func); + +#if defined(__STDC__) +#if __STDC_VERSION__ - 0 >= 199901L +#define dm_assert(EX) (void)((EX) ? 0 : \ + _dm_assert(#EX, __FILE__, __LINE__, __func__)) +#else +#define dm_assert(EX) (void)((EX) ? 0 : \ + _dm_assert(#EX, __FILE__, __LINE__, NULL)) +#endif /* __STDC_VERSION__ - 0 >= 199901L */ +#else +#define dm_assert(EX) (void)((EX) ? 0 : \ + _dm_assert("EX", __FILE__, __LINE__, NULL)) +#endif /* __STDC__ */ + + /* * List of strings with arbitrary matching values */ |