1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
/****************************************************************
* *
* Copyright 2001, 2010 Fidelity Information Services, Inc *
* *
* This source code contains the intellectual property *
* of its copyright holder(s), and is made available *
* under a license. If you do not know the terms of *
* the license, please stop and do not read further. *
* *
****************************************************************/
#include "mdef.h"
#include "gtm_string.h"
#include "gdsroot.h"
#include "gdsblk.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "filestruct.h"
#include "gdscc.h"
#include "min_max.h" /* needed for gdsblkops.h */
#include "gdsblkops.h"
#include "probe.h"
#if defined(__alpha) && defined(__VMS)
#include "gtmsecshr.h"
#endif
#include "sec_shr_blk_build.h"
int sec_shr_blk_build(sgmnt_addrs *csa, sgmnt_data_ptr_t csd, boolean_t is_bg,
cw_set_element *cse, sm_uc_ptr_t base_addr, trans_num ctn)
{
blk_segment *seg, *stop_ptr, *array;
unsigned char *ptr;
boolean_t do_accounting;
array = (blk_segment *)cse->upd_addr;
assert(csa->read_write);
if (csa->now_crit) /* csa->now_crit can be FALSE if we are finishing bg_update_phase2 part of the commit */
do_accounting = TRUE; /* used by SECSHR_ACCOUNTING macro */
if (!(GTM_PROBE(SIZEOF(blk_segment), array, READ)))
{
SECSHR_ACCOUNTING(4);
SECSHR_ACCOUNTING(__LINE__);
SECSHR_ACCOUNTING((INTPTR_T)cse->upd_addr);
SECSHR_ACCOUNTING(SIZEOF(blk_segment));
assert(FALSE);
return FALSE;
}
if (!(GTM_PROBE(SIZEOF(blk_hdr), base_addr, WRITE)))
{
SECSHR_ACCOUNTING(4);
SECSHR_ACCOUNTING(__LINE__);
SECSHR_ACCOUNTING((INTPTR_T)base_addr);
SECSHR_ACCOUNTING(SIZEOF(blk_hdr));
assert(FALSE);
return FALSE;
}
/* block transaction number needs to be modified first. see comment in gvcst_blk_build as to why */
((blk_hdr_ptr_t)base_addr)->bver = GDSVCURR;
assert(csa->now_crit || (ctn < csd->trans_hist.curr_tn));
assert(!csa->now_crit || (ctn == csd->trans_hist.curr_tn));
((blk_hdr_ptr_t)base_addr)->tn = ctn;
((blk_hdr_ptr_t)base_addr)->bsiz = UINTCAST(array->len);
((blk_hdr_ptr_t)base_addr)->levl = cse->level;
if (cse->forward_process)
{
ptr = base_addr + SIZEOF(blk_hdr);
for (seg = array + 1, stop_ptr = (blk_segment *)array->addr; seg <= stop_ptr; seg++)
{
if (!(GTM_PROBE(SIZEOF(blk_segment), seg, READ)))
{
SECSHR_ACCOUNTING(4);
SECSHR_ACCOUNTING(__LINE__);
SECSHR_ACCOUNTING((INTPTR_T)seg);
SECSHR_ACCOUNTING(SIZEOF(blk_segment));
assert(FALSE);
return FALSE;
}
if (!seg->len)
continue; /* GTM_PROBE on a zero length returns FALSE so check for it explicitly here */
if (!(GTM_PROBE(seg->len, seg->addr, READ)))
{
SECSHR_ACCOUNTING(5);
SECSHR_ACCOUNTING(__LINE__);
SECSHR_ACCOUNTING((INTPTR_T)seg);
SECSHR_ACCOUNTING((INTPTR_T)seg->addr);
SECSHR_ACCOUNTING(seg->len);
assert(FALSE);
return FALSE;
}
if (!(GTM_PROBE(seg->len, ptr, WRITE)))
{
SECSHR_ACCOUNTING(6);
SECSHR_ACCOUNTING(__LINE__);
SECSHR_ACCOUNTING((INTPTR_T)seg);
SECSHR_ACCOUNTING((INTPTR_T)ptr);
SECSHR_ACCOUNTING((INTPTR_T)seg->addr);
SECSHR_ACCOUNTING(seg->len);
assert(FALSE);
return FALSE;
}
DBG_BG_PHASE2_CHECK_CR_IS_PINNED(csa, seg);
memmove(ptr, seg->addr, seg->len);
ptr += seg->len;
}
} else
{
ptr = base_addr + array->len;
for (seg = (blk_segment*)array->addr, stop_ptr = array; seg > stop_ptr; seg--)
{
if (!(GTM_PROBE(SIZEOF(blk_segment), seg, READ)))
{
SECSHR_ACCOUNTING(4);
SECSHR_ACCOUNTING(__LINE__);
SECSHR_ACCOUNTING((INTPTR_T)seg);
SECSHR_ACCOUNTING(SIZEOF(blk_segment));
assert(FALSE);
return FALSE;
}
if (!seg->len)
continue; /* GTM_PROBE on a zero length returns FALSE so check for it explicitly here */
if (!(GTM_PROBE(seg->len, seg->addr, READ)))
{
SECSHR_ACCOUNTING(5);
SECSHR_ACCOUNTING(__LINE__);
SECSHR_ACCOUNTING((INTPTR_T)seg);
SECSHR_ACCOUNTING((INTPTR_T)seg->addr);
SECSHR_ACCOUNTING(seg->len);
assert(FALSE);
return FALSE;
}
ptr -= seg->len;
if (!(GTM_PROBE(seg->len, ptr, WRITE)))
{
SECSHR_ACCOUNTING(6);
SECSHR_ACCOUNTING(__LINE__);
SECSHR_ACCOUNTING((INTPTR_T)seg);
SECSHR_ACCOUNTING((INTPTR_T)ptr);
SECSHR_ACCOUNTING((INTPTR_T)seg->addr);
SECSHR_ACCOUNTING(seg->len);
assert(FALSE);
return FALSE;
}
DBG_BG_PHASE2_CHECK_CR_IS_PINNED(csa, seg);
memmove(ptr, seg->addr, seg->len);
}
}
return TRUE;
}
|