void ccp_exitwm1( ccp_db_header *db) { sgmnt_addrs *cs_addrs; uint4 status; assert(lib$ast_in_prog()); if ((db->qio_iosb.cond & 1) == 0) ccp_signal_cont(db->qio_iosb.cond); /***** Is this reasonable? *****/ cs_addrs = db->segment; if (db->last_lk_sequence < cs_addrs->ti->lock_sequence) { status = sys$qio(0, FILE_INFO(db->greg)->fab->fab$l_stv, IO$_WRITEVBLK, &db->qio_iosb, ccp_exitwm1a, db, cs_addrs->lock_addrs[0], db->glob_sec->lock_space_size, LOCK_BLOCK(db->glob_sec) + 1, 0, 0, 0); if ((status & 1) == 0) ccp_signal_cont(status); /***** Is this reasonable? *****/ db->last_lk_sequence = cs_addrs->ti->lock_sequence; } else ccp_exitwm2(db); return; }
int cce_sec_size(gds_file_id *file) { uint4 status; int size; short iosb[4]; sgmnt_data sd; sgmnt_data_ptr_t csd = &sd; char expanded_file_name[MAX_FN_LEN]; struct FAB fab; struct NAM nam; int buckets; fab = cc$rms_fab; fab.fab$l_fop = FAB$M_NAM | FAB$M_UFO; fab.fab$b_fac = FAB$M_GET | FAB$M_PUT | FAB$M_BIO; fab.fab$b_shr = FAB$M_SHRPUT | FAB$M_SHRGET | FAB$M_UPI; fab.fab$l_nam = &nam; nam = cc$rms_nam; nam.nam$b_ess = MAX_FN_LEN; nam.nam$l_esa = expanded_file_name; memcpy(nam.nam$t_dvi, file->dvi,file->dvi[0] + 1); memcpy(nam.nam$w_fid, file->fid, SIZEOF(file->fid)); status = sys$open(&fab, 0, 0); if (!(status & 1)) return 0; status = sys$qiow(EFN$C_ENF,fab.fab$l_stv, IO$_READVBLK, &iosb[0], 0,0, csd, SIZEOF(sgmnt_data), 1,0,0,0); if (!(status & 1)) return 0; buckets = getprime(sd.n_bts); size = (LOCK_BLOCK(csd) * DISK_BLOCK_SIZE) + LOCK_SPACE_SIZE(csd) + CACHE_CONTROL_SIZE(csd) + NODE_LOCAL_SPACE(csd) + JNL_SHARE_SIZE(csd); sys$dassgn(fab.fab$l_stv); return size / OS_PAGELET_SIZE; }
void dbsecspc(gd_region *reg, sgmnt_data_ptr_t csd) { switch(reg->dyn.addr->acc_meth) { case dba_mm: reg->sec_size = NODE_LOCAL_SPACE + LOCK_SPACE_SIZE(csd) + MMBLK_CONTROL_SIZE(csd) + JNL_SHARE_SIZE(csd) + BACKUP_BUFFER_SIZE; break; case dba_bg: reg->sec_size = NODE_LOCAL_SPACE + (LOCK_BLOCK(csd) * DISK_BLOCK_SIZE) + LOCK_SPACE_SIZE(csd) + CACHE_CONTROL_SIZE(csd) + JNL_SHARE_SIZE(csd) + BACKUP_BUFFER_SIZE; break; default: GTMASSERT; } return; }
void ccp_tr_opendb3(ccp_action_record *rec) { ccp_db_header *db; sgmnt_addrs *csa; sgmnt_data *csd; jnl_private_control *jpc; uint4 status; db = rec->v.h; db->master_map_start_tn = 0; csa = db->segment; csd = db->glob_sec = csa->hdr = csa->db_addrs[0]; adawi(1, &csa->nl->ref_cnt); /* GT.M process that sent open request */ csa->lock_addrs[0] = (unsigned char *)csd + (LOCK_BLOCK(csd) * DISK_BLOCK_SIZE); csa->lock_addrs[1] = csa->lock_addrs[0] + csd->lock_space_size; if (JNL_ENABLED(csd)) { jpc = csa->jnl = malloc(SIZEOF(jnl_private_control)); memset(jpc, 0, SIZEOF(jnl_private_control)); jpc->region = db->greg; jpc->jnl_buff = csa->lock_addrs[1] + CACHE_CONTROL_SIZE(csd) + JNL_NAME_EXP_SIZE; FILE_INFO(db->greg)->s_addrs.jnl->jnllsb->lockid = 0; if (db->wm_iosb.valblk[CCP_VALBLK_JNL_ADDR] == 0) { /* Open jnl file based on data in file header, first machine to open */ jnl_file_open(db->greg, FALSE, ccp_closejnl_ast); if (jpc->channel == 0) { /* Open failed */ ccp_close1(db); ccp_signal_cont(ERR_CCPJNLOPNERR); /***** Is this reasonable? *****/ return; } /* Write out file id for other machines */ csd->trans_hist.ccp_jnl_filesize = jpc->jnl_buff->filesize; csd->ccp_jnl_before = jpc->jnl_buff->before_images; status = sys$qio(0, FILE_INFO(db->greg)->fab->fab$l_stv, IO$_WRITEVBLK, &db->qio_iosb, ccp_opendb3a, db, csd, (MM_BLOCK - 1) * OS_PAGELET_SIZE, 1, 0, 0, 0); } else { /* ??? --> */ /* Open jnl file based on id in header. Read in header to make sure get file id from first machine */ status = sys$qio(0, FILE_INFO(db->greg)->fab->fab$l_stv, IO$_READVBLK, &db->qio_iosb, ccp_opendb3a, db, csd, (MM_BLOCK - 1) * OS_PAGELET_SIZE, 1, 0, 0, 0); } if (status != SS$_NORMAL) { ccp_signal_cont(status); /***** Is this reasonable? *****/ ccp_close1(db); } } else ccp_opendb3b(db); }
void cce_cluster(void ) { enum db_ver database; char fn[256]; struct FAB ccpfab; struct XABFHC xab; sgmnt_data *old_data, *dummy_data; short iosb[4]; unsigned short fn_len; int4 status, size, cluster, space_needed; error_def(ERR_CCERDERR); error_def(ERR_CCEWRTERR); error_def(ERR_CCEDBCL); error_def(ERR_CCEDBNTCL); error_def(ERR_CCEBADFN); error_def(ERR_DBOPNERR); error_def(ERR_DBNOTGDS); error_def(ERR_BADDBVER); error_def(ERR_CCEBGONLY); $DESCRIPTOR(cluster_qualifier, "CLUSTER"); fn_len = SIZEOF(fn); if (!cli_get_str("FILE",fn,&fn_len)) { lib$signal(ERR_CCEBADFN); return; } ccpfab = cc$rms_fab; ccpfab.fab$l_fna = fn; ccpfab.fab$b_fns = fn_len; ccpfab.fab$b_fac = FAB$M_BIO | FAB$M_GET | FAB$M_PUT; ccpfab.fab$l_fop = FAB$M_UFO; xab = cc$rms_xabfhc; ccpfab.fab$l_xab = &xab; status = sys$open(&ccpfab); if (status != RMS$_NORMAL) { lib$signal(ERR_DBOPNERR, 2, ccpfab.fab$b_fns, ccpfab.fab$l_fna, status); return; } dummy_data = malloc(ROUND_UP(SIZEOF(sgmnt_data), OS_PAGELET_SIZE)); status = sys$qiow(EFN$C_ENF, ccpfab.fab$l_stv, IO$_READVBLK, iosb, 0, 0, dummy_data, ROUND_UP(SIZEOF(sgmnt_data), OS_PAGELET_SIZE), 1,0,0,0); if (status & 1) status = iosb[0]; if ((status & 1) == 0) { lib$signal(ERR_CCERDERR, 2, ccpfab.fab$b_fns, ccpfab.fab$l_fna, status); sys$dassgn(ccpfab.fab$l_stv); free(dummy_data); return; } /* Commented out as this is unused code and we are removing the old version database references (SE - 4/2005 V5.0) if (memcmp(&dummy_data->label[0], GDS_LABEL, GDS_LABEL_SZ)) { if (memcmp(&dummy_data->label[0], GDS_LABEL, GDS_LABEL_SZ - 3)) { lib$signal (ERR_DBNOTGDS, 2, ccpfab.fab$b_fns, ccpfab.fab$l_fna); status = sys$dassgn(ccpfab.fab$l_stv); assert(status & 1); free(dummy_data); return; }else { if (!memcmp(&dummy_data->label[GDS_LABEL_SZ - 3],GDS_V23,2)) database = v23; else if (!memcmp(&dummy_data->label[GDS_LABEL_SZ - 3],GDS_V24,2)) database = v24; else if (!memcmp(&dummy_data->label[GDS_LABEL_SZ - 3],GDS_V25,2)) database = v25; else if (!memcmp(&dummy_data->label[GDS_LABEL_SZ - 3],GDS_V254,2)) database = v254; else lib$signal (ERR_BADDBVER, 2, ccpfab.fab$b_fns, ccpfab.fab$l_fna); } } else database = v255; */ if (dummy_data->acc_meth != dba_bg) { lib$signal(ERR_CCEBGONLY); status = sys$dassgn(ccpfab.fab$l_stv); assert(status & 1); free(dummy_data); return; } size = (LOCK_BLOCK(dummy_data) * DISK_BLOCK_SIZE) + LOCK_SPACE_SIZE(dummy_data); old_data = malloc(size); memcpy(old_data, dummy_data, SIZEOF(sgmnt_data)); cluster = cli$present(&cluster_qualifier); if (cluster == CLI$_NEGATED) old_data->clustered = FALSE; else if (cluster == CLI$_PRESENT) { old_data->clustered = TRUE; old_data->trans_hist.lock_sequence = 0; } change_fhead_timer("STALE_INTERVAL", old_data->staleness, -50000000, TRUE); change_fhead_timer("RESPONSE_INTERVAL",old_data->ccp_response_interval, -600000000, TRUE); change_fhead_timer("QUANTUM_INTERVAL", old_data->ccp_quantum_interval, -10000000, FALSE); change_fhead_timer("TICK_INTERVAL", old_data->ccp_tick_interval, -1000000, FALSE); if (old_data->unbacked_cache) { space_needed = (old_data->n_bts + getprime(old_data->n_bts) + 1) * SIZEOF(bt_rec); if (space_needed > old_data->free_space) { old_data->n_bts = old_data->free_space/(2*SIZEOF(bt_rec)); for (;;) { space_needed = (old_data->n_bts + getprime(old_data->n_bts) + 1) * SIZEOF(bt_rec); if (space_needed <= old_data->free_space) { old_data->bt_buckets = getprime(old_data->n_bts); break; } old_data->n_bts--; } util_out_open(0); util_out_print("Only have space for !UL cache records in clustered file !AD, adjusting file",TRUE, old_data->n_bts, fn_len, fn); } old_data->free_space -= space_needed; old_data->unbacked_cache = FALSE; } status = dbcx_ref(old_data, ccpfab.fab$l_stv); if ((status & 1) == 0) lib$signal(ERR_CCEWRTERR, 2, ccpfab.fab$b_fns, ccpfab.fab$l_fna, status); if (cluster != CLI$_ABSENT) lib$signal ((old_data->clustered) ? ERR_CCEDBCL : ERR_CCEDBNTCL, 2, ccpfab.fab$b_fns, ccpfab.fab$l_fna); status = sys$dassgn(ccpfab.fab$l_stv); assert(status & 1); free(dummy_data); free(old_data); return; }