diff --git a/newbrt/brt-internal.h b/newbrt/brt-internal.h index 62ed3056cad..14a9f622dd3 100644 --- a/newbrt/brt-internal.h +++ b/newbrt/brt-internal.h @@ -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); diff --git a/newbrt/brt-serialize.c b/newbrt/brt-serialize.c index 9057eccab9b..38d18d904a0 100644 --- a/newbrt/brt-serialize.c +++ b/newbrt/brt-serialize.c @@ -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; diff --git a/newbrt/brt.c b/newbrt/brt.c index 53f579aff36..aa71a811ba7 100644 --- a/newbrt/brt.c +++ b/newbrt/brt.c @@ -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); diff --git a/newbrt/brtdump.c b/newbrt/brtdump.c index 368bbba5cf9..7228957a590 100644 --- a/newbrt/brtdump.c +++ b/newbrt/brtdump.c @@ -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,