Lines Matching refs:res

56 child_cleanup(struct hast_resource *res)  in child_cleanup()  argument
59 proto_close(res->hr_ctrl); in child_cleanup()
60 res->hr_ctrl = NULL; in child_cleanup()
61 if (res->hr_event != NULL) { in child_cleanup()
62 proto_close(res->hr_event); in child_cleanup()
63 res->hr_event = NULL; in child_cleanup()
65 if (res->hr_conn != NULL) { in child_cleanup()
66 proto_close(res->hr_conn); in child_cleanup()
67 res->hr_conn = NULL; in child_cleanup()
69 res->hr_workerpid = 0; in child_cleanup()
74 uint8_t role, struct hast_resource *res, const char *name, unsigned int no) in control_set_role_common() argument
82 if (res == NULL) { in control_set_role_common()
86 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { in control_set_role_common()
87 if (strcmp(res->hr_name, name) == 0) in control_set_role_common()
90 if (res == NULL) { in control_set_role_common()
95 PJDLOG_ASSERT(res != NULL); in control_set_role_common()
98 nv_add_string(nvout, role2str(res->hr_role), "role%u", no); in control_set_role_common()
101 if (role == res->hr_role) in control_set_role_common()
104 pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); in control_set_role_common()
108 oldrole = res->hr_role; in control_set_role_common()
109 res->hr_role = role; in control_set_role_common()
110 pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); in control_set_role_common()
116 if (res->hr_workerpid != 0) { in control_set_role_common()
117 if (kill(res->hr_workerpid, SIGTERM) == -1) { in control_set_role_common()
120 (unsigned int)res->hr_workerpid); in control_set_role_common()
121 } else if (waitpid(res->hr_workerpid, NULL, 0) != in control_set_role_common()
122 res->hr_workerpid) { in control_set_role_common()
125 (unsigned int)res->hr_workerpid); in control_set_role_common()
128 (unsigned int)res->hr_workerpid); in control_set_role_common()
130 child_cleanup(res); in control_set_role_common()
135 hastd_primary(res); in control_set_role_common()
137 hook_exec(res->hr_exec, "role", res->hr_name, role2str(oldrole), in control_set_role_common()
138 role2str(res->hr_role), NULL); in control_set_role_common()
142 control_set_role(struct hast_resource *res, uint8_t role) in control_set_role() argument
145 control_set_role_common(NULL, NULL, role, res, NULL, 0); in control_set_role()
149 control_status_worker(struct hast_resource *res, struct nv *nvout, in control_status_worker() argument
169 if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) == -1) { in control_status_worker()
178 if (hast_proto_recv_hdr(res->hr_ctrl, &cnvin) == -1) { in control_status_worker()
238 struct hast_resource *res, const char *name, unsigned int no) in control_status() argument
248 if (res == NULL) { in control_status()
249 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { in control_status()
250 if (strcmp(res->hr_name, name) == 0) in control_status()
253 if (res == NULL) { in control_status()
258 PJDLOG_ASSERT(res != NULL); in control_status()
259 nv_add_string(nvout, res->hr_provname, "provname%u", no); in control_status()
260 nv_add_string(nvout, res->hr_localpath, "localpath%u", no); in control_status()
261 nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no); in control_status()
262 if (res->hr_sourceaddr[0] != '\0') in control_status()
263 nv_add_string(nvout, res->hr_sourceaddr, "sourceaddr%u", no); in control_status()
264 switch (res->hr_replication) { in control_status()
278 nv_add_string(nvout, checksum_name(res->hr_checksum), in control_status()
280 nv_add_string(nvout, compression_name(res->hr_compression), in control_status()
282 nv_add_string(nvout, role2str(res->hr_role), "role%u", no); in control_status()
283 nv_add_int32(nvout, res->hr_workerpid, "workerpid%u", no); in control_status()
285 switch (res->hr_role) { in control_status()
287 PJDLOG_ASSERT(res->hr_workerpid != 0); in control_status()
290 if (res->hr_workerpid != 0) in control_status()
301 control_status_worker(res, nvout, no); in control_status()
365 struct hast_resource *res; in control_handle() local
370 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { in control_handle()
373 control_set_role_common(cfg, nvout, role, res, in control_handle()
374 res->hr_name, ii++); in control_handle()
377 control_status(cfg, nvout, res, res->hr_name, in control_handle()
433 struct hast_resource *res = arg; in ctrl_thread() local
438 if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) == -1) { in ctrl_thread()
455 if (res->hr_remotein != NULL && in ctrl_thread()
456 res->hr_remoteout != NULL) { in ctrl_thread()
461 nv_add_uint32(nvout, (uint32_t)res->hr_extentsize, in ctrl_thread()
463 if (res->hr_role == HAST_ROLE_PRIMARY) { in ctrl_thread()
465 (uint32_t)res->hr_keepdirty, "keepdirty"); in ctrl_thread()
467 (uint64_t)(activemap_ndirty(res->hr_amp) * in ctrl_thread()
468 res->hr_extentsize), "dirty"); in ctrl_thread()
473 nv_add_uint64(nvout, res->hr_stat_read, "stat_read"); in ctrl_thread()
474 nv_add_uint64(nvout, res->hr_stat_write, "stat_write"); in ctrl_thread()
475 nv_add_uint64(nvout, res->hr_stat_delete, in ctrl_thread()
477 nv_add_uint64(nvout, res->hr_stat_flush, "stat_flush"); in ctrl_thread()
478 nv_add_uint64(nvout, res->hr_stat_activemap_update, in ctrl_thread()
480 nv_add_uint64(nvout, res->hr_stat_read_error, in ctrl_thread()
482 nv_add_uint64(nvout, res->hr_stat_write_error + in ctrl_thread()
483 res->hr_stat_activemap_write_error, in ctrl_thread()
485 nv_add_uint64(nvout, res->hr_stat_delete_error, in ctrl_thread()
487 nv_add_uint64(nvout, res->hr_stat_flush_error + in ctrl_thread()
488 res->hr_stat_activemap_flush_error, in ctrl_thread()
490 res->output_status_aux(nvout); in ctrl_thread()
499 PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY); in ctrl_thread()
500 primary_config_reload(res, nvin); in ctrl_thread()
513 if (hast_proto_send(NULL, res->hr_ctrl, nvout, NULL, 0) == -1) { in ctrl_thread()