64-bit entry numbers

This commit is contained in:
Steve Dee 2014-04-08 09:25:49 -07:00
parent 0ebce498bd
commit c9a4cf19cf
10 changed files with 68 additions and 64 deletions

View File

@ -212,12 +212,12 @@ u2_loom_exit(void)
/* u2_loom_save(): checkpoint at current date, with hat and mat.
*/
u2_bean
u2_loom_save(c3_w ent_w)
u2_loom_save(c3_d ent_d)
{
u2_cheg* ceg_u;
c3_w tot_w = 0;
// uL(fprintf(uH, "# saving at event %u...\n", ent_w));
// uL(fprintf(uH, "# saving at event %llu...\n", ent_d));
u2_wr_check_save();
for ( ceg_u = &LoomSegmentA; ceg_u; ceg_u = ceg_u->nex_u ) {
@ -225,7 +225,7 @@ u2_loom_save(c3_w ent_w)
c3_w i_w;
c3_w num_w = 0;
chf_u.ent_w = ent_w;
chf_u.ent_d = ent_d;
chf_u.ven_w = LoomVersion;
chf_u.bot_w = ceg_u->bot_w;
chf_u.pgs_w = ceg_u->pgs_w;

View File

@ -12,7 +12,7 @@
u2_noun vir; // effects of ovum
u2_bean did; // cart considered for commit?
u2_bean cit; // cart committed?
c3_w ent_w; // entry in raft queue?
c3_d ent_d; // entry in raft queue?
void (*clr_f) // ovum processing failed
(struct _u2_reck *rec_u, // system
u2_noun, // egg itself
@ -26,7 +26,7 @@
typedef struct _u2_reck {
c3_w kno_w; // kernel stage
c3_w rno_w; // rotor index (always 0)
c3_w ent_w; // event counter XX 64
c3_d ent_d; // event counter
u2_noun yot; // new toy system
u2_noun now; // current time, as noun

View File

@ -34,7 +34,7 @@
/* u2_chef: memory control, per whole, on disk.
*/
typedef struct _u2_chef { // control image
c3_w ent_w; // event number
c3_d ent_d; // event number
c3_w ven_w; // version
c3_w bot_w; // offset in loom
c3_w pgs_w; // pages saved
@ -513,7 +513,7 @@
** Save the current loom at the current event number.
*/
u2_bean
u2_loom_save(c3_w ent_w);
u2_loom_save(c3_d ent_d);
/** General.
**/

View File

@ -213,7 +213,7 @@
typedef struct _u2_save {
uv_timer_t tim_u; // checkpoint timer
uv_signal_t sil_u; // child signal
c3_w ent_w; // event number, XX 64
c3_d ent_d; // event number
c3_w pid_w; // pid of checkpoint process
} u2_save;
@ -275,7 +275,7 @@
*/
typedef struct {
c3_w syn_w; // must equal mug of address
c3_w ent_w; // event sequence number
c3_d ent_d; // event sequence number
c3_w len_w; // word length of this event
c3_w mug_w; // mug of entry
c3_w tem_w; // raft term of event
@ -434,7 +434,7 @@
uv_tcp_t wax_u; // TCP listener
uv_timer_t tim_u; // election/heartbeat timer
u2_ulog lug_u; // event log
c3_w ent_w; // last log index
c3_d ent_d; // last log index
c3_w lat_w; // last log term
u2_raty typ_e; // server type
struct _u2_rnam* nam_u; // list of peers

View File

@ -477,7 +477,7 @@ u2_lo_shut(u2_bean inn)
//
u2_cm_purge();
// u2_lo_grab("lo_exit", u2_none);
u2_loom_save(u2A->ent_w);
u2_loom_save(u2A->ent_d);
u2_loom_exit();
u2_lo_exit();
@ -672,9 +672,9 @@ u2_lo_lead(u2_reck* rec_u)
_lo_poll();
#if 1
u2_loom_save(rec_u->ent_w);
u2_loom_save(rec_u->ent_d);
u2_Host.sav_u.ent_w = rec_u->ent_w;
u2_Host.sav_u.ent_d = rec_u->ent_d;
#endif
if ( u2_yes == u2_Host.ops_u.nuu ) {

View File

@ -333,7 +333,7 @@ main(c3_i argc,
// If we have not loaded from checkpoint, build kernel.
//
if ( 0 != u2_Host.arv_u->ent_w ) {
if ( 0 != u2_Host.arv_u->ent_d ) {
u2_reck_time(u2_Host.arv_u);
u2_reck_numb(u2_Host.arv_u);
{

View File

@ -334,7 +334,7 @@ _raft_do_revo(u2_rcon* ron_u, const u2_rmsg* msg_u)
0 == strcmp(raf_u->vog_c, ron_u->nam_u->str_c)) &&
(raf_u->lat_w < msg_u->rest.lat_w ||
(raf_u->lat_w == msg_u->rest.lat_w &&
raf_u->ent_w <= msg_u->rest.lai_d)) )
raf_u->ent_d <= msg_u->rest.lai_d)) )
{
raf_u->vog_c = ron_u->nam_u->str_c;
u2_sist_put("vote", (c3_y*)raf_u->vog_c, strlen(raf_u->vog_c));
@ -1189,7 +1189,7 @@ _raft_write_revo(u2_rcon* ron_u, u2_rmsg* msg_u)
{
u2_raft* raf_u = ron_u->raf_u;
_raft_write_rest(ron_u, raf_u->ent_w, raf_u->lat_w, msg_u);
_raft_write_rest(ron_u, raf_u->ent_d, raf_u->lat_w, msg_u);
msg_u->typ_w = c3__revo;
}
@ -1591,7 +1591,7 @@ _raft_punk(u2_reck* rec_u, u2_noun ovo)
}
static void
_raft_comm(u2_reck* rec_u, c3_w bid_w)
_raft_comm(u2_reck* rec_u, c3_d bid_d)
{
u2_cart* egg_u;
@ -1599,7 +1599,7 @@ _raft_comm(u2_reck* rec_u, c3_w bid_w)
egg_u = rec_u->ova.egg_u;
while ( egg_u ) {
if ( egg_u->ent_w <= bid_w ) {
if ( egg_u->ent_d <= bid_d ) {
egg_u->did = u2_yes;
egg_u->cit = u2_yes;
} else break;
@ -1613,10 +1613,10 @@ _raft_comm_cb(uv_timer_t* tim_u, c3_i sas_i)
{
u2_raft* raf_u = tim_u->data;
_raft_comm(u2A, raf_u->ent_w);
_raft_comm(u2A, raf_u->ent_d);
}
static c3_w
static c3_d
_raft_push(u2_raft* raf_u, c3_w* bob_w, c3_w len_w)
{
c3_assert(raf_u->typ_e == u2_raty_lead);
@ -1624,14 +1624,14 @@ _raft_push(u2_raft* raf_u, c3_w* bob_w, c3_w len_w)
if ( 1 == raf_u->pop_w ) {
c3_assert(u2_raty_lead == raf_u->typ_e);
raf_u->ent_w = u2_sist_pack(u2A, raf_u->tem_w, c3__ov, bob_w, len_w);
raf_u->ent_d = u2_sist_pack(u2A, raf_u->tem_w, c3__ov, bob_w, len_w);
raf_u->lat_w = raf_u->tem_w; // XX
if ( !uv_is_active((uv_handle_t*)&raf_u->tim_u) ) {
uv_timer_start(&raf_u->tim_u, _raft_comm_cb, 0, 0);
}
return raf_u->ent_w;
return raf_u->ent_d;
}
else {
// TODO
@ -1726,7 +1726,7 @@ u2_raft_work(u2_reck* rec_u)
// Cartify, jam, and encrypt this batch of events. Take a number, Raft will
// be with you shortly.
{
c3_w bid_w;
c3_d bid_d;
c3_w len_w;
c3_w* bob_w;
u2_noun ron;
@ -1757,8 +1757,8 @@ u2_raft_work(u2_reck* rec_u)
u2_cr_words(0, len_w, bob_w, ron);
u2z(ron);
bid_w = _raft_push(u2R, bob_w, len_w);
egg_u->ent_w = bid_w;
bid_d = _raft_push(u2R, bob_w, len_w);
egg_u->ent_d = bid_d;
if ( 0 == rec_u->ova.geg_u ) {
c3_assert(0 == rec_u->ova.egg_u);

View File

@ -368,7 +368,7 @@ u2_reck_cold(u2_reck* rec_u, c3_w kno_w)
memset(rec_u, 0, sizeof(*rec_u));
rec_u->kno_w = kno_w;
rec_u->rno_w = 0;
rec_u->ent_w = 1;
rec_u->ent_d = 1;
rec_u->own = 0;
rec_u->now = 0;

View File

@ -42,8 +42,8 @@ _save_time_cb(uv_timer_t* tim_u, c3_i sas_i)
return;
}
if ( u2A->ent_w > sav_u->ent_w ) {
// uL(fprintf(uH, "autosaving... ent_w %d\n", u2A->ent_w));
if ( u2A->ent_d > sav_u->ent_d ) {
// uL(fprintf(uH, "autosaving... ent_d %llu\n", u2A->ent_d));
u2_cm_purge();
u2_lo_grab("save", u2_none);
@ -51,18 +51,18 @@ _save_time_cb(uv_timer_t* tim_u, c3_i sas_i)
#ifdef FORKPT
c3_w pid_w;
if ( 0 == (pid_w = fork()) ) {
u2_loom_save(u2A->ent_w);
u2_loom_save(u2A->ent_d);
exit(0);
}
else {
uL(fprintf(uH, "checkpoint: process %d\n", pid_w));
sav_u->ent_w = u2A->ent_w;
sav_u->ent_d = u2A->ent_d;
sav_u->pid_w = pid_w;
}
#else
u2_loom_save(u2A->ent_w);
sav_u->ent_w = u2A->ent_w;
u2_loom_save(u2A->ent_d);
sav_u->ent_d = u2A->ent_d;
#endif
}
}
@ -96,7 +96,7 @@ u2_save_io_init(void)
{
u2_save* sav_u = &u2_Host.sav_u;
sav_u->ent_w = 0;
sav_u->ent_d = 0;
sav_u->pid_w = 0;
uv_timer_init(u2L, &sav_u->tim_u);

View File

@ -24,7 +24,7 @@
/* u2_sist_pack(): write a blob to disk, transferring.
*/
c3_w
c3_d
u2_sist_pack(u2_reck* rec_u, c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w)
{
u2_ulog* lug_u = &u2R->lug_u;
@ -39,8 +39,8 @@ u2_sist_pack(u2_reck* rec_u, c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w)
lar_u.mug_w = u2_cr_mug_both(u2_cr_mug_words(bob_w, len_w),
u2_cr_mug_both(u2_cr_mug(lar_u.tem_w),
u2_cr_mug(lar_u.typ_w)));
lar_u.ent_w = rec_u->ent_w;
rec_u->ent_w++;
lar_u.ent_d = rec_u->ent_d;
rec_u->ent_d++;
lar_u.len_w = len_w;
if ( -1 == lseek64(lug_u->fid_i, 4ULL * tar_d, SEEK_SET) ) {
@ -59,10 +59,10 @@ u2_sist_pack(u2_reck* rec_u, c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w)
c3_assert(0);
}
#if 0
uL(fprintf(uH, "sist_pack: write %llu, %llu: lar ent %d, len %d, mug %x\n",
uL(fprintf(uH, "sist_pack: write %llu, %llu: lar ent %llu, len %d, mug %x\n",
lug_u->len_d,
tar_d,
lar_u.ent_w,
lar_u.ent_d,
lar_u.len_w,
lar_u.mug_w));
#endif
@ -75,7 +75,7 @@ u2_sist_pack(u2_reck* rec_u, c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w)
free(bob_w);
return rec_u->ent_w;
return rec_u->ent_d;
}
/* u2_sist_put(): moronic key-value store put.
@ -707,7 +707,7 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c)
}
{
c3_w ent_w = 1;
c3_d ent_d = 1;
c3_assert(end_d == c3_wiseof(u2_uled));
while ( u2_nul != roe ) {
@ -720,7 +720,7 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c)
lar_u.len_w = u2_cr_met(5, ovo);
tar_d = end_d + lar_u.len_w;
lar_u.syn_w = u2_cr_mug(tar_d);
lar_u.ent_w = ent_w;
lar_u.ent_d = ent_d;
lar_u.tem_w = 0;
lar_u.typ_w = c3__ov;
lar_u.mug_w = u2_cr_mug_both(u2_cr_mug(ovo),
@ -742,7 +742,7 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c)
u2_lo_bail(u2A);
}
ent_w++;
ent_d++;
end_d = tar_d + c3_wiseof(u2_ular);
u2z(roe); roe = nex;
}
@ -769,8 +769,8 @@ _sist_rest(u2_reck* rec_u)
struct stat buf_b;
c3_i fid_i;
c3_c ful_c[2048];
c3_w old_w = rec_u->ent_w;
c3_w las_w = 0;
c3_d old_d = rec_u->ent_d;
c3_d las_d = 0;
u2_noun roe = u2_nul;
u2_noun sev_l, tno_l, key_l, sal_l;
u2_bean ohh = u2_no;
@ -787,9 +787,13 @@ _sist_rest(u2_reck* rec_u)
}
}
if ( 0 != rec_u->ent_w ) {
u2_noun ent = u2_dc("scot", c3__ud, rec_u->ent_w);
c3_c* ent_c = u2_cr_string(ent);
if ( 0 != rec_u->ent_d ) {
u2_noun ent;
c3_c* ent_c;
ent = u2_ci_chubs(1, &rec_u->ent_d);
ent = u2_dc("scot", c3__ud, ent);
ent_c = u2_cr_string(ent);
uL(fprintf(uH, "rest: checkpoint to event %s\n", ent_c));
free(ent_c);
u2z(ent);
@ -882,11 +886,11 @@ _sist_rest(u2_reck* rec_u)
// Read in the fscking events. These are probably corrupt as well.
{
c3_w ent_w;
c3_d ent_d;
c3_d end_d;
end_d = u2R->lug_u.len_d;
ent_w = 0;
ent_d = 0;
if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) {
fprintf(stderr, "end_d %llx\n", end_d);
@ -917,32 +921,32 @@ _sist_rest(u2_reck* rec_u)
u2_lo_bail(rec_u);
}
if ( lar_u.ent_w == 0 ) {
if ( lar_u.ent_d == 0 ) {
ohh = u2_yes;
}
#if 0
uL(fprintf(uH, "log: read: at %d, %d: lar ent %d, len %d, mug %x\n",
uL(fprintf(uH, "log: read: at %d, %d: lar ent %llu, len %d, mug %x\n",
(tar_w - lar_u.len_w),
tar_w,
lar_u.ent_w,
lar_u.ent_d,
lar_u.len_w,
lar_u.mug_w));
#endif
if ( end_d == u2R->lug_u.len_d ) {
ent_w = las_w = lar_u.ent_w;
ent_d = las_d = lar_u.ent_d;
}
else {
if ( lar_u.ent_w != (ent_w - 1) ) {
if ( lar_u.ent_d != (ent_d - 1ULL) ) {
uL(fprintf(uH, "record (%s) is corrupt (g)\n", ful_c));
uL(fprintf(uH, "lar_u.ent_w %x, ent_w %x\n", lar_u.ent_w, ent_w));
uL(fprintf(uH, "lar_u.ent_d %llx, ent_d %llx\n", lar_u.ent_d, ent_d));
u2_lo_bail(rec_u);
}
ent_w -= 1;
ent_d -= 1ULL;
}
end_d = (tar_d - (c3_d)lar_u.len_w);
if ( ent_w < old_w ) {
if ( ent_d < old_d ) {
// XX this could be a break if we didn't want to see the sequence
// number of the first event.
continue;
@ -991,14 +995,14 @@ _sist_rest(u2_reck* rec_u)
}
roe = u2nc(u2_cke_cue(ron), roe);
}
rec_u->ent_w = c3_max(las_w + 1, old_w);
rec_u->ent_d = c3_max(las_d + 1ULL, old_d);
}
if ( u2_nul == roe ) {
// Nothing in the log that was not also in the checkpoint.
//
c3_assert(rec_u->ent_w == old_w);
c3_assert((las_w + 1) == old_w);
c3_assert(rec_u->ent_d == old_d);
c3_assert((las_d + 1ULL) == old_d);
}
else {
u2_noun rou = roe;
@ -1006,7 +1010,7 @@ _sist_rest(u2_reck* rec_u)
// Execute the fscking things. This is pretty much certain to crash.
//
uL(fprintf(uH, "rest: replaying through event %d\n", las_w));
uL(fprintf(uH, "rest: replaying through event %d\n", las_d));
fprintf(uH, "---------------- playback starting----------------\n");
xno_w = 0;
@ -1080,12 +1084,12 @@ _sist_rest(u2_reck* rec_u)
// Increment sequence numbers. New logs start at 1.
if ( u2_yes == ohh ) {
uL(fprintf(uH, "rest: bumping ent_w, don't panic.\n"));
uL(fprintf(uH, "rest: bumping ent_d, don't panic.\n"));
u2_ular lar_u;
c3_d end_d;
c3_d tar_d;
rec_u->ent_w++;
rec_u->ent_d++;
end_d = u2R->lug_u.len_d;
while ( end_d != c3_wiseof(u2_uled) ) {
tar_d = end_d - c3_wiseof(u2_ular);
@ -1097,7 +1101,7 @@ _sist_rest(u2_reck* rec_u)
uL(fprintf(uH, "bumping sequence numbers failed (b)\n"));
u2_lo_bail(rec_u);
}
lar_u.ent_w++;
lar_u.ent_d++;
if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) {
uL(fprintf(uH, "bumping sequence numbers failed (c)\n"));
u2_lo_bail(rec_u);