Skip to content

Commit

Permalink
disk: save top-level metadata on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
joemfb committed Jan 30, 2024
1 parent 8d97aac commit d28cbd3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
40 changes: 29 additions & 11 deletions pkg/vere/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,33 @@ u3_disk_save_meta(MDB_env* mdb_u,
return c3y;
}


/* u3_disk_save_meta_meta(): save meta metadata.
*/
c3_o
u3_disk_save_meta_meta(c3_c* log_c,
c3_d who_d[2],
c3_o fak_o,
c3_w lif_w)
{
MDB_env* dbm_u;

if ( 0 == (dbm_u = u3_lmdb_init(log_c, siz_i)) ) {
fprintf(stderr, "disk: failed to initialize meta-lmdb\r\n");
return c3n;
}

if ( c3n == u3_disk_save_meta(dbm_u, U3D_VERLAT, who_d, fak_o, lif_w) ) {
fprintf(stderr, "disk: failed to save metadata\r\n");
return c3n;
}

u3_lmdb_exit(dbm_u);

return c3y;
}


typedef struct {
ssize_t hav_i;
c3_y buf_y[16];
Expand Down Expand Up @@ -1866,20 +1893,11 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
return 0;
}

MDB_env* dbm_u;
if ( 0 == (dbm_u = u3_lmdb_init(log_c, siz_i)) ) {
fprintf(stderr, "disk: failed to initialize lmdb\r\n");
if ( c3n == u3_disk_save_meta_meta(log_c, who_d, fak_o, lif_w) ) {
fprintf(stderr, "disk: failed to save top-level metadata\r\n");
c3_free(log_u);
return 0;
}

if ( c3n == u3_disk_save_meta(dbm_u, U3D_VERLAT, who_d, fak_o, lif_w) ) {
fprintf(stderr, "disk: failed to read metadata\r\n");
c3_free(log_u);
return 0;
}

u3_lmdb_exit(dbm_u);
}

return log_u;
Expand Down
7 changes: 7 additions & 0 deletions pkg/vere/pier.c
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,13 @@ _pier_boot_plan(u3_pier* pir_u,
return c3n;
}

if ( c3n == u3_disk_save_meta_meta(pir_u->log_u->com_u->pax_c,
pir_u->who_d, pir_u->fak_o, pir_u->lif_w) )
{
fprintf(stderr, "disk: failed to save top-level metadata\r\n");
return c3n;
}

// insert boot sequence directly
//
// Note that these are not ovum or (pair @da ovum) events,
Expand Down
8 changes: 8 additions & 0 deletions pkg/vere/vere.h
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,14 @@
c3_o fak_o,
c3_w lif_w);

/* u3_disk_save_meta_meta(): save meta metadata.
*/
c3_o
u3_disk_save_meta_meta(c3_c* log_c,
c3_d who_d[2],
c3_o fak_o,
c3_w lif_w);

/* u3_disk_read(): read [len_d] events starting at [eve_d].
*/
void
Expand Down

0 comments on commit d28cbd3

Please sign in to comment.