mirror of
https://github.com/urbit/ares.git
synced 2024-11-23 00:25:49 +03:00
pma: file extension bug fixes. test changes
file extension seems to be working now after reordering freelist restoration and calling _bt_falloc in _nlist_new to create the first partition should be able to move on to partition striping now and the explicit call to _bt_falloc will make this easier
This commit is contained in:
parent
a604f19d74
commit
390c1c3356
@ -307,11 +307,26 @@ int main(int argc, char *argv[])
|
||||
return errno;
|
||||
assert(SUCC(bt_state_open(state4, "./pmatest4", 0, 0644)));
|
||||
|
||||
#define PMA_INITIAL_SIZE_p PMA_GROW_SIZE_p
|
||||
BYTE *t4a = bt_malloc(state4, PMA_GROW_SIZE_p * 2);
|
||||
BYTE *t4b = t4a;
|
||||
for (size_t i = 0; i < PMA_GROW_SIZE_b * 2; i++) {
|
||||
*t4b++ = rand();
|
||||
}
|
||||
|
||||
assert(state4->file_size_p == PMA_INITIAL_SIZE_p + PMA_GROW_SIZE_p * 2);
|
||||
/* given the allocation pattern the head of the flist should also be the
|
||||
tail. The hi page here should match the file size */
|
||||
assert(state4->flist->hi == state4->file_size_p);
|
||||
|
||||
bt_state_close(state4);
|
||||
|
||||
bt_state_new(&state4);
|
||||
|
||||
assert(SUCC(bt_state_open(state4, "./pmatest4", 0, 0644)));
|
||||
|
||||
assert(state4->file_size_p == PMA_INITIAL_SIZE_p + PMA_GROW_SIZE_p * 2);
|
||||
assert(state4->flist->hi == state4->file_size_p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2374,6 +2374,14 @@ _bt_state_load(BT_state *state)
|
||||
assert(SUCC(_mlist_new(state)));
|
||||
}
|
||||
else {
|
||||
/* Set the file length */
|
||||
if (fstat(state->data_fd, &stat) != 0)
|
||||
return errno;
|
||||
|
||||
/* the file size should be a multiple of our pagesize */
|
||||
assert((stat.st_size % BT_PAGESIZE) == 0);
|
||||
state->file_size_p = stat.st_size / BT_PAGESIZE;
|
||||
|
||||
/* restore data memory maps */
|
||||
_bt_state_restore_maps(state);
|
||||
|
||||
@ -2382,15 +2390,6 @@ _bt_state_load(BT_state *state)
|
||||
|
||||
/* Dirty the metapage and root page */
|
||||
assert(SUCC(_bt_flip_meta(state)));
|
||||
|
||||
/* Set the file length */
|
||||
// XX make sure the flist is updated with this!
|
||||
if (fstat(state->data_fd, &stat) != 0)
|
||||
return errno;
|
||||
|
||||
/* the file size should be a multiple of our pagesize */
|
||||
assert((stat.st_size % BT_PAGESIZE) == 0);
|
||||
state->file_size_p = stat.st_size / BT_PAGESIZE;
|
||||
}
|
||||
|
||||
return BT_SUCC;
|
||||
|
Loading…
Reference in New Issue
Block a user