Lines Matching defs:res
55 child_cleanup(struct hast_resource *res)
58 proto_close(res->hr_ctrl);
59 res->hr_ctrl = NULL;
60 if (res->hr_event != NULL) {
61 proto_close(res->hr_event);
62 res->hr_event = NULL;
64 if (res->hr_conn != NULL) {
65 proto_close(res->hr_conn);
66 res->hr_conn = NULL;
68 res->hr_workerpid = 0;
73 uint8_t role, struct hast_resource *res, const char *name, unsigned int no)
81 if (res == NULL) {
85 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
86 if (strcmp(res->hr_name, name) == 0)
89 if (res == NULL) {
94 PJDLOG_ASSERT(res != NULL);
97 nv_add_string(nvout, role2str(res->hr_role), "role%u", no);
100 if (role == res->hr_role)
103 pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
107 oldrole = res->hr_role;
108 res->hr_role = role;
109 pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
115 if (res->hr_workerpid != 0) {
116 if (kill(res->hr_workerpid, SIGTERM) == -1) {
119 (unsigned int)res->hr_workerpid);
120 } else if (waitpid(res->hr_workerpid, NULL, 0) !=
121 res->hr_workerpid) {
124 (unsigned int)res->hr_workerpid);
127 (unsigned int)res->hr_workerpid);
129 child_cleanup(res);
134 hastd_primary(res);
136 hook_exec(res->hr_exec, "role", res->hr_name, role2str(oldrole),
137 role2str(res->hr_role), NULL);
141 control_set_role(struct hast_resource *res, uint8_t role)
144 control_set_role_common(NULL, NULL, role, res, NULL, 0);
148 control_status_worker(struct hast_resource *res, struct nv *nvout,
168 if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) == -1) {
177 if (hast_proto_recv_hdr(res->hr_ctrl, &cnvin) == -1) {
237 struct hast_resource *res, const char *name, unsigned int no)
247 if (res == NULL) {
248 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
249 if (strcmp(res->hr_name, name) == 0)
252 if (res == NULL) {
257 PJDLOG_ASSERT(res != NULL);
258 nv_add_string(nvout, res->hr_provname, "provname%u", no);
259 nv_add_string(nvout, res->hr_localpath, "localpath%u", no);
260 nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no);
261 if (res->hr_sourceaddr[0] != '\0')
262 nv_add_string(nvout, res->hr_sourceaddr, "sourceaddr%u", no);
263 switch (res->hr_replication) {
277 nv_add_string(nvout, checksum_name(res->hr_checksum),
279 nv_add_string(nvout, compression_name(res->hr_compression),
281 nv_add_string(nvout, role2str(res->hr_role), "role%u", no);
282 nv_add_int32(nvout, res->hr_workerpid, "workerpid%u", no);
284 switch (res->hr_role) {
286 PJDLOG_ASSERT(res->hr_workerpid != 0);
289 if (res->hr_workerpid != 0)
300 control_status_worker(res, nvout, no);
364 struct hast_resource *res;
369 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
372 control_set_role_common(cfg, nvout, role, res,
373 res->hr_name, ii++);
376 control_status(cfg, nvout, res, res->hr_name,
432 struct hast_resource *res = arg;
437 if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) == -1) {
454 if (res->hr_remotein != NULL &&
455 res->hr_remoteout != NULL) {
460 nv_add_uint32(nvout, (uint32_t)res->hr_extentsize,
462 if (res->hr_role == HAST_ROLE_PRIMARY) {
464 (uint32_t)res->hr_keepdirty, "keepdirty");
466 (uint64_t)(activemap_ndirty(res->hr_amp) *
467 res->hr_extentsize), "dirty");
472 nv_add_uint64(nvout, res->hr_stat_read, "stat_read");
473 nv_add_uint64(nvout, res->hr_stat_write, "stat_write");
474 nv_add_uint64(nvout, res->hr_stat_delete,
476 nv_add_uint64(nvout, res->hr_stat_flush, "stat_flush");
477 nv_add_uint64(nvout, res->hr_stat_activemap_update,
479 nv_add_uint64(nvout, res->hr_stat_read_error,
481 nv_add_uint64(nvout, res->hr_stat_write_error +
482 res->hr_stat_activemap_write_error,
484 nv_add_uint64(nvout, res->hr_stat_delete_error,
486 nv_add_uint64(nvout, res->hr_stat_flush_error +
487 res->hr_stat_activemap_flush_error,
489 res->output_status_aux(nvout);
498 PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY);
499 primary_config_reload(res, nvin);
512 if (hast_proto_send(NULL, res->hr_ctrl, nvout, NULL, 0) == -1) {