Deserialize the fifo header inside the header deserialization code instead of separately. Addresses #1131, #1080, #1000.

git-svn-id: file:///svn/tokudb.1131b+1080a@6057 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
Bradley C. Kuszmaul 2013-04-16 23:57:18 -04:00 committed by Yoni Fogel
parent 5ff7b0c746
commit fcd8cb084c
4 changed files with 9 additions and 6 deletions

View file

@ -170,7 +170,6 @@ int toku_serialize_brt_header_to_wbuf (struct wbuf *, struct brt_header *h);
int toku_deserialize_brtheader_from (int fd, BLOCKNUM off, u_int32_t fullhash, struct brt_header **brth);
int toku_serialize_fifo_at (int fd, off_t freeoff, FIFO fifo); // Write a fifo into a disk, without worrying about fitting it into a block. This write is done at the end of the file.
int toku_deserialize_fifo_at (int fd, off_t at, FIFO *fifo);
void toku_brtnode_free (BRTNODE *node);

View file

@ -29,6 +29,8 @@ static const int brtnode_header_overhead = (8+ // magic "tokunode" or "tokulea
4+ // localfingerprint
4); // crc32 at the end
static int deserialize_fifo_at (int fd, off_t at, FIFO *fifo);
int addupsize (OMTVALUE lev, u_int32_t UU(idx), void *vp) {
LEAFENTRY le=lev;
unsigned int *ip=vp;
@ -606,7 +608,7 @@ int toku_serialize_brt_header_to (int fd, struct brt_header *h) {
return r;
}
int deserialize_brtheader_7_or_later(u_int32_t size, int fd, DISKOFF off, struct brt_header **brth, u_int32_t fullhash) {
int deserialize_brtheader (u_int32_t size, int fd, DISKOFF off, struct brt_header **brth, u_int32_t fullhash) {
// We already know the first 8 bytes are "tokudata", and we read in the size.
struct brt_header *MALLOC(h);
if (h==0) return errno;
@ -660,6 +662,10 @@ int deserialize_brtheader_7_or_later(u_int32_t size, int fd, DISKOFF off, struct
}
if (rc.ndone!=rc.size) {ret = EINVAL; goto died5;}
toku_free(rc.buf);
{
int r;
if ((r = deserialize_fifo_at(fd, h->unused_blocks.b*h->nodesize, &h->fifo))) return r;
}
*brth = h;
return 0;
}
@ -677,7 +683,7 @@ int toku_deserialize_brtheader_from (int fd, BLOCKNUM blocknum, u_int32_t fullha
if (r!=12) return EINVAL;
assert(memcmp(magic,"tokudata",8)==0);
// It's version 7 or later, and the magi clooks OK
return deserialize_brtheader_7_or_later(ntohl(*(int*)(&magic[8])), fd, offset, brth, fullhash);
return deserialize_brtheader(ntohl(*(int*)(&magic[8])), fd, offset, brth, fullhash);
}
unsigned int toku_brt_pivot_key_len (BRT brt, struct kv_pair *pk) {
@ -773,7 +779,7 @@ int read_nbytes (int fd, off_t *at, char **data, u_int32_t len) {
return 0;
}
int toku_deserialize_fifo_at (int fd, off_t at, FIFO *fifo) {
static int deserialize_fifo_at (int fd, off_t at, FIFO *fifo) {
FIFO result;
int r = toku_fifo_create(&result);
if (r) return r;

View file

@ -230,7 +230,6 @@ int toku_brtheader_fetch_callback (CACHEFILE cachefile, BLOCKNUM nodename, u_int
struct brt_header **h = (struct brt_header **)headerp_v;
assert(nodename.b==0);
if ((r = toku_deserialize_brtheader_from(toku_cachefile_fd(cachefile), nodename, fullhash, h))) return r;
if ((r = toku_deserialize_fifo_at(toku_cachefile_fd(cachefile), (*h)->unused_blocks.b*(*h)->nodesize, &(*h)->fifo))) return r;
//printf("%s:%d fifo=%p\nn", __FILE__, __LINE__, (*h)->fifo);
written_lsn->lsn = 0; // !!! WRONG. This should be stored or kept redundantly or something.
assert((*h)->free_blocks.b==-1);

View file

@ -49,7 +49,6 @@ void dump_header (int f, struct brt_header **header) {
}
*header = h;
printf("Fifo:\n");
r = toku_deserialize_fifo_at(f, h->unused_blocks.b*h->nodesize, &h->fifo);
printf(" fifo has %d entries\n", toku_fifo_n_entries(h->fifo));
if (dump_data) {
FIFO_ITERATE(h->fifo, key, keylen, data, datalen, type, xid,