Lines Matching refs:ahp
66 fmd_asru_strhash(fmd_asru_hash_t *ahp, const char *val) in fmd_asru_strhash() argument
68 return (topo_fmri_strhash(ahp->ah_topo->ft_hdl, val) % ahp->ah_hashlen); in fmd_asru_strhash()
72 fmd_asru_strcmp(fmd_asru_hash_t *ahp, const char *a, const char *b) in fmd_asru_strcmp() argument
74 return (topo_fmri_strcmp(ahp->ah_topo->ft_hdl, a, b)); in fmd_asru_strcmp()
78 fmd_asru_create(fmd_asru_hash_t *ahp, const char *uuid, in fmd_asru_create() argument
90 ap->asru_root = fmd_strdup(ahp->ah_dirpath, FMD_SLEEP); in fmd_asru_create()
117 fmd_asru_hash_insert(fmd_asru_hash_t *ahp, fmd_asru_t *ap) in fmd_asru_hash_insert() argument
119 uint_t h = fmd_asru_strhash(ahp, ap->asru_name); in fmd_asru_hash_insert()
121 ASSERT(RW_WRITE_HELD(&ahp->ah_lock)); in fmd_asru_hash_insert()
122 ap->asru_next = ahp->ah_hash[h]; in fmd_asru_hash_insert()
123 ahp->ah_hash[h] = ap; in fmd_asru_hash_insert()
124 ahp->ah_count++; in fmd_asru_hash_insert()
143 fmd_asru_hash_lookup(fmd_asru_hash_t *ahp, const char *name) in fmd_asru_hash_lookup() argument
148 ASSERT(RW_LOCK_HELD(&ahp->ah_lock)); in fmd_asru_hash_lookup()
149 h = fmd_asru_strhash(ahp, name); in fmd_asru_hash_lookup()
151 for (ap = ahp->ah_hash[h]; ap != NULL; ap = ap->asru_next) { in fmd_asru_hash_lookup()
152 if (fmd_asru_strcmp(ahp, ap->asru_name, name)) in fmd_asru_hash_lookup()
232 fmd_asru_asru_hash_insert(fmd_asru_hash_t *ahp, fmd_asru_link_t *alp, in fmd_asru_asru_hash_insert() argument
235 uint_t h = fmd_asru_strhash(ahp, name); in fmd_asru_asru_hash_insert()
237 ASSERT(RW_WRITE_HELD(&ahp->ah_lock)); in fmd_asru_asru_hash_insert()
238 alp->al_asru_next = ahp->ah_asru_hash[h]; in fmd_asru_asru_hash_insert()
239 ahp->ah_asru_hash[h] = alp; in fmd_asru_asru_hash_insert()
240 ahp->ah_al_count++; in fmd_asru_asru_hash_insert()
244 fmd_asru_case_hash_insert(fmd_asru_hash_t *ahp, fmd_asru_link_t *alp, in fmd_asru_case_hash_insert() argument
247 uint_t h = fmd_asru_strhash(ahp, name); in fmd_asru_case_hash_insert()
249 ASSERT(RW_WRITE_HELD(&ahp->ah_lock)); in fmd_asru_case_hash_insert()
250 alp->al_case_next = ahp->ah_case_hash[h]; in fmd_asru_case_hash_insert()
251 ahp->ah_case_hash[h] = alp; in fmd_asru_case_hash_insert()
255 fmd_asru_fru_hash_insert(fmd_asru_hash_t *ahp, fmd_asru_link_t *alp, char *name) in fmd_asru_fru_hash_insert() argument
257 uint_t h = fmd_asru_strhash(ahp, name); in fmd_asru_fru_hash_insert()
259 ASSERT(RW_WRITE_HELD(&ahp->ah_lock)); in fmd_asru_fru_hash_insert()
260 alp->al_fru_next = ahp->ah_fru_hash[h]; in fmd_asru_fru_hash_insert()
261 ahp->ah_fru_hash[h] = alp; in fmd_asru_fru_hash_insert()
265 fmd_asru_label_hash_insert(fmd_asru_hash_t *ahp, fmd_asru_link_t *alp, in fmd_asru_label_hash_insert() argument
268 uint_t h = fmd_asru_strhash(ahp, name); in fmd_asru_label_hash_insert()
270 ASSERT(RW_WRITE_HELD(&ahp->ah_lock)); in fmd_asru_label_hash_insert()
271 alp->al_label_next = ahp->ah_label_hash[h]; in fmd_asru_label_hash_insert()
272 ahp->ah_label_hash[h] = alp; in fmd_asru_label_hash_insert()
276 fmd_asru_rsrc_hash_insert(fmd_asru_hash_t *ahp, fmd_asru_link_t *alp, in fmd_asru_rsrc_hash_insert() argument
279 uint_t h = fmd_asru_strhash(ahp, name); in fmd_asru_rsrc_hash_insert()
281 ASSERT(RW_WRITE_HELD(&ahp->ah_lock)); in fmd_asru_rsrc_hash_insert()
282 alp->al_rsrc_next = ahp->ah_rsrc_hash[h]; in fmd_asru_rsrc_hash_insert()
283 ahp->ah_rsrc_hash[h] = alp; in fmd_asru_rsrc_hash_insert()
323 fmd_asru_al_hash_release(fmd_asru_hash_t *ahp, fmd_asru_link_t *alp) in fmd_asru_al_hash_release() argument
353 fmd_asru_al_create(fmd_asru_hash_t *ahp, nvlist_t *nvl, fmd_case_t *cp, in fmd_asru_al_create() argument
382 (void) pthread_rwlock_wrlock(&ahp->ah_lock); in fmd_asru_al_create()
399 if ((ap = fmd_asru_hash_lookup(ahp, name)) == NULL) { in fmd_asru_al_create()
400 ap = fmd_asru_create(ahp, al_uuid, name, got_asru ? asru : in fmd_asru_al_create()
402 fmd_asru_hash_insert(ahp, ap); in fmd_asru_al_create()
414 fmd_asru_asru_hash_insert(ahp, alp, alp->al_asru_name); in fmd_asru_al_create()
416 fmd_asru_fru_hash_insert(ahp, alp, alp->al_fru_name); in fmd_asru_al_create()
418 fmd_asru_rsrc_hash_insert(ahp, alp, alp->al_rsrc_name); in fmd_asru_al_create()
420 fmd_asru_label_hash_insert(ahp, alp, label); in fmd_asru_al_create()
422 fmd_asru_case_hash_insert(ahp, alp, cip->ci_uuid); in fmd_asru_al_create()
424 (void) pthread_rwlock_unlock(&ahp->ah_lock); in fmd_asru_al_create()
438 fmd_asru_hash_recreate(fmd_log_t *lp, fmd_event_t *ep, fmd_asru_hash_t *ahp) in fmd_asru_hash_recreate() argument
466 ahp->ah_error = EFMD_ASRU_EVENT; in fmd_asru_hash_recreate()
472 ahp->ah_error = EFMD_ASRU_EVENT; in fmd_asru_hash_recreate()
538 alp = fmd_asru_al_create(ahp, flt, cp, fmd_strbasename(lp->log_name)); in fmd_asru_hash_recreate()
601 fmd_asru_hash_discard(fmd_asru_hash_t *ahp, const char *uuid, int err) in fmd_asru_hash_discard() argument
605 (void) snprintf(src, PATH_MAX, "%s/%s", ahp->ah_dirpath, uuid); in fmd_asru_hash_discard()
606 (void) snprintf(dst, PATH_MAX, "%s/%s-", ahp->ah_dirpath, uuid); in fmd_asru_hash_discard()
624 fmd_asru_hash_logopen(fmd_asru_hash_t *ahp, const char *uuid) in fmd_asru_hash_logopen() argument
626 fmd_log_t *lp = fmd_log_tryopen(ahp->ah_dirpath, uuid, FMD_LOG_ASRU); in fmd_asru_hash_logopen()
630 fmd_asru_hash_discard(ahp, uuid, errno); in fmd_asru_hash_logopen()
634 ahp->ah_error = 0; in fmd_asru_hash_logopen()
635 n = ahp->ah_al_count; in fmd_asru_hash_logopen()
637 fmd_log_replay(lp, (fmd_log_f *)fmd_asru_hash_recreate, ahp); in fmd_asru_hash_logopen()
640 if (ahp->ah_al_count == n) in fmd_asru_hash_logopen()
641 fmd_asru_hash_discard(ahp, uuid, ahp->ah_error); in fmd_asru_hash_logopen()
645 fmd_asru_hash_refresh(fmd_asru_hash_t *ahp) in fmd_asru_hash_refresh() argument
651 if ((dirp = opendir(ahp->ah_dirpath)) == NULL) { in fmd_asru_hash_refresh()
653 "failed to open asru cache directory %s", ahp->ah_dirpath); in fmd_asru_hash_refresh()
659 (void) pthread_rwlock_wrlock(&ahp->ah_lock); in fmd_asru_hash_refresh()
666 fmd_asru_hash_discard(ahp, dp->d_name, 0); in fmd_asru_hash_refresh()
668 fmd_asru_hash_logopen(ahp, dp->d_name); in fmd_asru_hash_refresh()
671 (void) pthread_rwlock_unlock(&ahp->ah_lock); in fmd_asru_hash_refresh()
706 fmd_asru_hash_replay(fmd_asru_hash_t *ahp) in fmd_asru_hash_replay() argument
708 fmd_asru_hash_apply(ahp, fmd_asru_hash_replay_asru, NULL); in fmd_asru_hash_replay()
813 fmd_asru_hash_t *ahp; in fmd_asru_hash_create() local
816 ahp = fmd_alloc(sizeof (fmd_asru_hash_t), FMD_SLEEP); in fmd_asru_hash_create()
817 (void) pthread_rwlock_init(&ahp->ah_lock, NULL); in fmd_asru_hash_create()
818 ahp->ah_hashlen = fmd.d_str_buckets; in fmd_asru_hash_create()
819 ahp->ah_hash = fmd_zalloc(sizeof (void *) * ahp->ah_hashlen, FMD_SLEEP); in fmd_asru_hash_create()
820 ahp->ah_asru_hash = fmd_zalloc(sizeof (void *) * ahp->ah_hashlen, in fmd_asru_hash_create()
822 ahp->ah_case_hash = fmd_zalloc(sizeof (void *) * ahp->ah_hashlen, in fmd_asru_hash_create()
824 ahp->ah_fru_hash = fmd_zalloc(sizeof (void *) * ahp->ah_hashlen, in fmd_asru_hash_create()
826 ahp->ah_label_hash = fmd_zalloc(sizeof (void *) * ahp->ah_hashlen, in fmd_asru_hash_create()
828 ahp->ah_rsrc_hash = fmd_zalloc(sizeof (void *) * ahp->ah_hashlen, in fmd_asru_hash_create()
831 ahp->ah_dirpath = fmd_strdup(path, FMD_SLEEP); in fmd_asru_hash_create()
832 (void) fmd_conf_getprop(fmd.d_conf, "rsrc.age", &ahp->ah_lifetime); in fmd_asru_hash_create()
835 ahp->ah_al_count = 0; in fmd_asru_hash_create()
836 ahp->ah_count = 0; in fmd_asru_hash_create()
837 ahp->ah_error = 0; in fmd_asru_hash_create()
838 ahp->ah_topo = fmd_topo_hold(); in fmd_asru_hash_create()
840 return (ahp); in fmd_asru_hash_create()
844 fmd_asru_hash_destroy(fmd_asru_hash_t *ahp) in fmd_asru_hash_destroy() argument
849 for (i = 0; i < ahp->ah_hashlen; i++) { in fmd_asru_hash_destroy()
850 for (alp = ahp->ah_case_hash[i]; alp != NULL; alp = np) { in fmd_asru_hash_destroy()
855 fmd_asru_al_hash_release(ahp, alp); in fmd_asru_hash_destroy()
859 fmd_strfree(ahp->ah_dirpath); in fmd_asru_hash_destroy()
860 fmd_free(ahp->ah_hash, sizeof (void *) * ahp->ah_hashlen); in fmd_asru_hash_destroy()
861 fmd_free(ahp->ah_asru_hash, sizeof (void *) * ahp->ah_hashlen); in fmd_asru_hash_destroy()
862 fmd_free(ahp->ah_case_hash, sizeof (void *) * ahp->ah_hashlen); in fmd_asru_hash_destroy()
863 fmd_free(ahp->ah_fru_hash, sizeof (void *) * ahp->ah_hashlen); in fmd_asru_hash_destroy()
864 fmd_free(ahp->ah_label_hash, sizeof (void *) * ahp->ah_hashlen); in fmd_asru_hash_destroy()
865 fmd_free(ahp->ah_rsrc_hash, sizeof (void *) * ahp->ah_hashlen); in fmd_asru_hash_destroy()
866 fmd_topo_rele(ahp->ah_topo); in fmd_asru_hash_destroy()
867 fmd_free(ahp, sizeof (fmd_asru_hash_t)); in fmd_asru_hash_destroy()
875 fmd_asru_hash_apply(fmd_asru_hash_t *ahp, in fmd_asru_hash_apply() argument
881 (void) pthread_rwlock_rdlock(&ahp->ah_lock); in fmd_asru_hash_apply()
883 aps = app = fmd_alloc(ahp->ah_count * sizeof (fmd_asru_t *), FMD_SLEEP); in fmd_asru_hash_apply()
884 apc = ahp->ah_count; in fmd_asru_hash_apply()
886 for (i = 0; i < ahp->ah_hashlen; i++) { in fmd_asru_hash_apply()
887 for (ap = ahp->ah_hash[i]; ap != NULL; ap = ap->asru_next) in fmd_asru_hash_apply()
892 (void) pthread_rwlock_unlock(&ahp->ah_lock); in fmd_asru_hash_apply()
897 fmd_asru_hash_release(ahp, aps[i]); in fmd_asru_hash_apply()
904 fmd_asru_al_hash_apply(fmd_asru_hash_t *ahp, in fmd_asru_al_hash_apply() argument
910 (void) pthread_rwlock_rdlock(&ahp->ah_lock); in fmd_asru_al_hash_apply()
912 alps = alpp = fmd_alloc(ahp->ah_al_count * sizeof (fmd_asru_link_t *), in fmd_asru_al_hash_apply()
914 alpc = ahp->ah_al_count; in fmd_asru_al_hash_apply()
916 for (i = 0; i < ahp->ah_hashlen; i++) { in fmd_asru_al_hash_apply()
917 for (alp = ahp->ah_case_hash[i]; alp != NULL; in fmd_asru_al_hash_apply()
923 (void) pthread_rwlock_unlock(&ahp->ah_lock); in fmd_asru_al_hash_apply()
927 fmd_asru_al_hash_release(ahp, alps[i]); in fmd_asru_al_hash_apply()
934 fmd_asru_do_hash_apply(fmd_asru_hash_t *ahp, const char *name, in fmd_asru_do_hash_apply() argument
942 (void) pthread_rwlock_rdlock(&ahp->ah_lock); in fmd_asru_do_hash_apply()
944 h = fmd_asru_strhash(ahp, name); in fmd_asru_do_hash_apply()
949 if (fmd_asru_strcmp(ahp, in fmd_asru_do_hash_apply()
959 if (fmd_asru_strcmp(ahp, in fmd_asru_do_hash_apply()
965 (void) pthread_rwlock_unlock(&ahp->ah_lock); in fmd_asru_do_hash_apply()
969 fmd_asru_al_hash_release(ahp, alps[i]); in fmd_asru_do_hash_apply()
976 fmd_asru_hash_apply_by_asru(fmd_asru_hash_t *ahp, const char *name, in fmd_asru_hash_apply_by_asru() argument
979 fmd_asru_do_hash_apply(ahp, name, func, arg, ahp->ah_asru_hash, in fmd_asru_hash_apply_by_asru()
985 fmd_asru_hash_apply_by_case(fmd_asru_hash_t *ahp, fmd_case_t *cp, in fmd_asru_hash_apply_by_case() argument
988 fmd_asru_do_hash_apply(ahp, ((fmd_case_impl_t *)cp)->ci_uuid, func, arg, in fmd_asru_hash_apply_by_case()
989 ahp->ah_case_hash, offsetof(fmd_asru_link_t, al_case_uuid), in fmd_asru_hash_apply_by_case()
994 fmd_asru_hash_apply_by_fru(fmd_asru_hash_t *ahp, const char *name, in fmd_asru_hash_apply_by_fru() argument
997 fmd_asru_do_hash_apply(ahp, name, func, arg, ahp->ah_fru_hash, in fmd_asru_hash_apply_by_fru()
1003 fmd_asru_hash_apply_by_rsrc(fmd_asru_hash_t *ahp, const char *name, in fmd_asru_hash_apply_by_rsrc() argument
1006 fmd_asru_do_hash_apply(ahp, name, func, arg, ahp->ah_rsrc_hash, in fmd_asru_hash_apply_by_rsrc()
1012 fmd_asru_hash_apply_by_label(fmd_asru_hash_t *ahp, const char *name, in fmd_asru_hash_apply_by_label() argument
1015 fmd_asru_do_hash_apply(ahp, name, func, arg, ahp->ah_label_hash, in fmd_asru_hash_apply_by_label()
1025 fmd_asru_hash_lookup_name(fmd_asru_hash_t *ahp, const char *name) in fmd_asru_hash_lookup_name() argument
1029 (void) pthread_rwlock_rdlock(&ahp->ah_lock); in fmd_asru_hash_lookup_name()
1030 ap = fmd_asru_hash_lookup(ahp, name); in fmd_asru_hash_lookup_name()
1031 (void) pthread_rwlock_unlock(&ahp->ah_lock); in fmd_asru_hash_lookup_name()
1055 fmd_asru_hash_create_entry(fmd_asru_hash_t *ahp, fmd_case_t *cp, nvlist_t *nvl) in fmd_asru_hash_create_entry() argument
1076 alp = fmd_asru_al_create(ahp, nvl, cp, parsed_uuid); in fmd_asru_hash_create_entry()
1091 fmd_asru_hash_release(fmd_asru_hash_t *ahp, fmd_asru_t *ap) in fmd_asru_hash_release() argument
1103 fmd_asru_do_delete_entry(fmd_asru_hash_t *ahp, fmd_case_t *cp, in fmd_asru_do_delete_entry() argument
1109 (void) pthread_rwlock_wrlock(&ahp->ah_lock); in fmd_asru_do_delete_entry()
1110 h = fmd_asru_strhash(ahp, name); in fmd_asru_do_delete_entry()
1122 (void) pthread_rwlock_unlock(&ahp->ah_lock); in fmd_asru_do_delete_entry()
1126 fmd_asru_do_hash_delete(fmd_asru_hash_t *ahp, fmd_case_susp_t *cis, in fmd_asru_do_hash_delete() argument
1137 fmd_asru_do_delete_entry(ahp, cp, hash, next_offset, in fmd_asru_do_hash_delete()
1141 fmd_asru_do_delete_entry(ahp, cp, hash, next_offset, ""); in fmd_asru_do_hash_delete()
1145 fmd_asru_hash_delete_case(fmd_asru_hash_t *ahp, fmd_case_t *cp) in fmd_asru_hash_delete_case() argument
1159 fmd_asru_do_hash_delete(ahp, cis, cp, ahp->ah_fru_hash, in fmd_asru_hash_delete_case()
1161 fmd_asru_do_hash_delete(ahp, cis, cp, ahp->ah_rsrc_hash, in fmd_asru_hash_delete_case()
1166 fmd_asru_do_delete_entry(ahp, cp, ahp->ah_label_hash, in fmd_asru_hash_delete_case()
1168 fmd_asru_do_hash_delete(ahp, cis, cp, ahp->ah_asru_hash, in fmd_asru_hash_delete_case()
1175 (void) pthread_rwlock_wrlock(&ahp->ah_lock); in fmd_asru_hash_delete_case()
1176 h = fmd_asru_strhash(ahp, cip->ci_uuid); in fmd_asru_hash_delete_case()
1177 plp = &ahp->ah_case_hash[h]; in fmd_asru_hash_delete_case()
1183 ASSERT(ahp->ah_al_count != 0); in fmd_asru_hash_delete_case()
1184 ahp->ah_al_count--; in fmd_asru_hash_delete_case()
1202 ahp->ah_dirpath, alp->al_uuid); in fmd_asru_hash_delete_case()
1220 ASSERT(ahp->ah_count != 0); in fmd_asru_hash_delete_case()
1221 ahp->ah_count--; in fmd_asru_hash_delete_case()
1222 h = fmd_asru_strhash(ahp, ap->asru_name); in fmd_asru_hash_delete_case()
1223 pp = &ahp->ah_hash[h]; in fmd_asru_hash_delete_case()
1235 fmd_asru_al_hash_release(ahp, alp); in fmd_asru_hash_delete_case()
1239 (void) pthread_rwlock_unlock(&ahp->ah_lock); in fmd_asru_hash_delete_case()