char gtcmtr_lke_clearrep(struct CLB *lnk, clear_request *creq) { gd_region *cur_region; sgmnt_addrs *cs_adr; mlk_ctldata_ptr_t lke_ctl; mstr dnode; show_reply srep; uint4 status; cur_region = gv_cur_region = gtcm_find_region(curr_entry, creq->rnum)->reghead->reg; if (dba_bg == cur_region->dyn.addr->acc_meth || dba_mm == cur_region->dyn.addr->acc_meth) { cs_adr = &FILE_INFO(cur_region)->s_addrs; lke_ctl = (mlk_ctldata_ptr_t)cs_adr->lock_addrs[0]; util_cm_print(lnk, 0, NULL, RESET); dnode.len = creq->nodelength; dnode.addr = creq->node; if (cs_adr->critical != NULL) crash_count = cs_adr->critical->crashcnt; grab_crit(cur_region); if (lke_ctl->blkroot != 0) lke_cleartree(cur_region, lnk, lke_ctl, (mlk_shrblk_ptr_t)R2A(lke_ctl->blkroot), creq->all, creq->interactive, creq->pid, dnode); rel_crit(cur_region); } srep.code = CMMS_U_LKEDELETE; lnk->cbl = sizeof(srep.code); lnk->ast = NULL; #ifndef vinu_marker assert(0 == offsetof(show_reply, code)); lnk->mbf = (unsigned char *)&srep; /* no need since lnk->mbf can be re-used. vinu 06/27/01 */ status = cmi_write(lnk); if (CMI_ERROR(status)) { /* This routine is a server routine; not sure why it does error processing similar to a client. vinu 06/27/01 */ ((link_info *)(lnk->usr))->neterr = TRUE; gvcmz_error(CMMS_U_LKEDELETE, status); } else lnk->mbf = (unsigned char *)creq; /* don't restore if lnk->mbf isn't modified. vinu 06/27/01 */ #else /* server calls to cmi_* should do error processing as a callback. vinu 06/27/01 */ *lnk->mbf = srep.code; cmi_write(lnk); #endif return CM_READ; }
void lke_clear(void) { bool locks, all = TRUE, wait = FALSE, interactive = TRUE, match = FALSE, memory = FALSE, nocrit = FALSE; boolean_t exact = TRUE, was_crit; int4 pid; int n; char regbuf[MAX_RN_LEN], nodebuf[32], one_lockbuf[MAX_KEY_SZ]; mlk_ctldata_ptr_t ctl; mstr reg, node, one_lock; /* Get all command parameters */ reg.addr = regbuf; reg.len = SIZEOF(regbuf); node.addr = nodebuf; node.len = SIZEOF(nodebuf); one_lock.addr = one_lockbuf; one_lock.len = SIZEOF(one_lockbuf); if (lke_getcli(&all, &wait, &interactive, &pid, ®, &node, &one_lock, &memory, &nocrit, &exact) == 0) return; /* Search all regions specified on the command line */ for (gv_cur_region = gd_header->regions, n = 0; n != gd_header->n_regions; ++gv_cur_region, ++n) { /* If region matches and is open */ if ((reg.len == 0 || gv_cur_region->rname_len == reg.len && memcmp(gv_cur_region->rname, reg.addr, reg.len) == 0) && gv_cur_region->open) { match = TRUE; util_out_print("!/!AD!/", NOFLUSH, REG_LEN_STR(gv_cur_region)); /* If distributed database, the region is located on another node */ if (gv_cur_region->dyn.addr->acc_meth == dba_cm) { # if defined(LKE_WORKS_OK_WITH_CM) /* Remote lock clears are not supported, so LKE CLEAR -EXACT qualifier * will not be supported on GT.CM.*/ locks = gtcmtr_lke_clearreq(gv_cur_region->dyn.addr->cm_blk, gv_cur_region->cmx_regnum, all, interactive, pid, &node); # else gtm_putmsg(VARLSTCNT(10) ERR_UNIMPLOP, 0, ERR_TEXT, 2, LEN_AND_LIT("GT.CM region - locks must be cleared on the local node"), ERR_TEXT, 2, REG_LEN_STR(gv_cur_region)); continue; # endif } else if ((dba_bg == gv_cur_region->dyn.addr->acc_meth) || (dba_mm == gv_cur_region->dyn.addr->acc_meth)) { /* Local region */ cs_addrs = &FILE_INFO(gv_cur_region)->s_addrs; ctl = (mlk_ctldata_ptr_t)cs_addrs->lock_addrs[0]; /* Prevent any modifications of locks while we are clearing */ if (cs_addrs->critical != NULL) crash_count = cs_addrs->critical->crashcnt; was_crit = cs_addrs->now_crit; if (!was_crit) grab_crit(gv_cur_region); locks = ctl->blkroot == 0 ? FALSE : lke_cleartree(gv_cur_region, NULL, ctl, (mlk_shrblk_ptr_t)R2A(ctl->blkroot), all, interactive, pid, one_lock, exact); if (!was_crit) rel_crit(gv_cur_region); } else { gtm_putmsg(VARLSTCNT(2) ERR_BADREGION, 0); locks = TRUE; } if (!locks) { gtm_putmsg(VARLSTCNT(4) ERR_NOLOCKMATCH, 2, REG_LEN_STR(gv_cur_region)); } } } if (!match && reg.len != 0) rts_error(VARLSTCNT(4) ERR_NOREGION, 2, reg.len, reg.addr); }