static void _write_array(struct pfilter *pf, FILE *fp, const char *path, void *data) { void *d; int first = 1; struct dm_hash_node *n; for (n = dm_hash_get_first(pf->devices); n; n = dm_hash_get_next(pf->devices, n)) { d = dm_hash_get_data(pf->devices, n); if (d != data) continue; if (!first) fprintf(fp, ",\n"); else { fprintf(fp, "\t%s=[\n", path); first = 0; } fprintf(fp, "\t\t\"%s\"", dm_hash_get_key(pf->devices, n)); } if (!first) fprintf(fp, "\n\t]\n"); return; }
/* Called at shutdown to tidy the lockspace */ void destroy_lvhash() { struct dm_hash_node *v; struct lv_info *lvi; char *resource; int status; pthread_mutex_lock(&lv_hash_lock); dm_hash_iterate(v, lv_hash) { lvi = dm_hash_get_data(lv_hash, v); resource = dm_hash_get_key(lv_hash, v); if ((status = sync_unlock(resource, lvi->lock_id))) DEBUGLOG("unlock_all. unlock failed(%d): %s\n", status, strerror(errno)); free(lvi); }
/* Call a callback for each node, so the caller knows whether it's up or down */ static int _cluster_do_node_callback(struct local_client *master_client, void (*callback)(struct local_client *, const char *csid, int node_up)) { struct dm_hash_node *hn; struct node_info *ninfo; dm_hash_iterate(hn, node_hash) { char csid[COROSYNC_CSID_LEN]; ninfo = dm_hash_get_data(node_hash, hn); memcpy(csid, dm_hash_get_key(node_hash, hn), COROSYNC_CSID_LEN); DEBUGLOG("down_callback. node %d, state = %d\n", ninfo->nodeid, ninfo->state); if (ninfo->state == NODE_CLVMD) callback(master_client, csid, 1); }