Commit 4d74fb5c authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

[t:4570] finishing the enum->int change for checksum errors

git-svn-id: file:///svn/toku/tokudb@44326 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4ba7bcad
......@@ -778,12 +778,12 @@ translation_default(struct translation *t) { // destination into which to creat
}
static enum deserialize_error_code
static int
translation_deserialize_from_buffer(struct translation *t, // destination into which to deserialize
DISKOFF location_on_disk, //Location of translation_buffer
u_int64_t size_on_disk,
unsigned char * translation_buffer) { // buffer with serialized translation
enum deserialize_error_code e;
int r = 0;
assert(location_on_disk!=0);
t->type = TRANSLATION_CHECKPOINTED;
{
......@@ -794,7 +794,7 @@ translation_deserialize_from_buffer(struct translation *t, // destination int
u_int32_t stored_x1764 = toku_dtoh32(*(int*)(translation_buffer + offset));
if (x1764 != stored_x1764) {
fprintf(stderr, "Translation table checksum failure: calc=0x%08x read=0x%08x\n", x1764, stored_x1764);
e = DS_XSUM_FAIL;
r = TOKUDB_BAD_CHECKSUM;
goto exit;
}
}
......@@ -817,9 +817,8 @@ PRNTF("ReadIn", i, t->block_translation[i].size, t->block_translation[i].u.disko
assert(calculate_size_on_disk(t) == (int64_t)size_on_disk);
assert(t->block_translation[RESERVED_BLOCKNUM_TRANSLATION].size == (int64_t)size_on_disk);
assert(t->block_translation[RESERVED_BLOCKNUM_TRANSLATION].u.diskoff == location_on_disk);
e = DS_OK;
exit:
return e;
return r;
}
// We just initialized a translation, inform block allocator to reserve space for each blocknum in use.
......@@ -848,15 +847,15 @@ blocktable_note_translation (BLOCK_ALLOCATOR allocator, struct translation *t) {
// The one read from disk is the last known checkpointed one, so we are keeping it in
// place and then setting current (which is never stored on disk) for current use.
// The translation_buffer has translation only, we create the rest of the block_table.
enum deserialize_error_code
int
toku_blocktable_create_from_buffer(int fd,
BLOCK_TABLE *btp,
DISKOFF location_on_disk, //Location of translation_buffer
DISKOFF size_on_disk,
unsigned char *translation_buffer) {
BLOCK_TABLE bt = blocktable_create_internal();
enum deserialize_error_code e = translation_deserialize_from_buffer(&bt->checkpointed, location_on_disk, size_on_disk, translation_buffer);
if (e != DS_OK) {
int r = translation_deserialize_from_buffer(&bt->checkpointed, location_on_disk, size_on_disk, translation_buffer);
if (r != 0) {
goto exit;
}
blocktable_note_translation(bt->block_allocator, &bt->checkpointed);
......@@ -864,14 +863,14 @@ toku_blocktable_create_from_buffer(int fd,
copy_translation(&bt->current, &bt->checkpointed, TRANSLATION_CURRENT);
int64_t file_size;
int r = toku_os_get_file_size(fd, &file_size);
r = toku_os_get_file_size(fd, &file_size);
lazy_assert_zero(r);
invariant(file_size >= 0);
bt->safe_file_size = file_size;
*btp = bt;
exit:
return e;
return r;
}
......
......@@ -24,7 +24,7 @@ struct block_translation_pair {
};
void toku_blocktable_create_new(BLOCK_TABLE *btp);
enum deserialize_error_code toku_blocktable_create_from_buffer(int fd, BLOCK_TABLE *btp, DISKOFF location_on_disk, DISKOFF size_on_disk, unsigned char *translation_buffer);
int toku_blocktable_create_from_buffer(int fd, BLOCK_TABLE *btp, DISKOFF location_on_disk, DISKOFF size_on_disk, unsigned char *translation_buffer);
void toku_blocktable_destroy(BLOCK_TABLE *btp);
void toku_ft_lock(FT h);
......
......@@ -529,10 +529,9 @@ deserialize_ft_from_fd_into_rbuf(int fd,
struct rbuf *rb,
u_int64_t *checkpoint_count,
LSN *checkpoint_lsn,
u_int32_t * version_p,
enum deserialize_error_code *e);
u_int32_t * version_p);
enum deserialize_error_code
int
deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ft, uint32_t version);
int
......@@ -593,7 +592,7 @@ int toku_serialize_ft_to_wbuf (
DISKOFF translation_location_on_disk,
DISKOFF translation_size_on_disk
);
enum deserialize_error_code toku_deserialize_ft_from (int fd, LSN max_acceptable_lsn, FT *ft);
int toku_deserialize_ft_from (int fd, LSN max_acceptable_lsn, FT *ft);
int toku_serialize_descriptor_contents_to_fd(int fd, const DESCRIPTOR desc, DISKOFF offset);
void toku_serialize_descriptor_contents_to_wbuf(struct wbuf *wb, const DESCRIPTOR desc);
BASEMENTNODE toku_create_empty_bn(void);
......
......@@ -774,16 +774,13 @@ int toku_ftnode_fetch_callback (CACHEFILE UU(cachefile), int fd, BLOCKNUM nodena
// deserialize the node, must pass the bfe in because we cannot
// evaluate what piece of the the node is necessary until we get it at
// least partially into memory
enum deserialize_error_code e;
int r = 0;
e = toku_deserialize_ftnode_from(fd, nodename, fullhash, node, ndd, bfe);
if (e != DS_OK) {
if (e == DS_XSUM_FAIL) {
int r = toku_deserialize_ftnode_from(fd, nodename, fullhash, node, ndd, bfe);
if (r != 0) {
if (r == TOKUDB_BAD_CHECKSUM) {
fprintf(stderr,
"Checksum failure while reading node in file %s.\n",
toku_cachefile_fname_in_env(cachefile));
} else if (e == DS_ERRNO) {
r = errno;
} else {
fprintf(stderr, "Error deserializing node, errno = %d", r);
}
// make absolutely sure we crash before doing anything else.
......@@ -1091,7 +1088,7 @@ ft_status_update_partial_fetch_reason(
// callback for partially reading a node
// could have just used toku_ftnode_fetch_callback, but wanted to separate the two cases to separate functions
int toku_ftnode_pf_callback(void* ftnode_pv, void* disk_data, void* read_extraargs, int fd, PAIR_ATTR* sizep) {
enum deserialize_error_code e = DS_OK;
int r = 0;
FTNODE node = ftnode_pv;
FTNODE_DISK_DATA ndd = disk_data;
struct ftnode_fetch_extra *bfe = read_extraargs;
......@@ -1119,22 +1116,22 @@ int toku_ftnode_pf_callback(void* ftnode_pv, void* disk_data, void* read_extraar
if ((lc <= i && i <= rc) || toku_bfe_wants_child_available(bfe, i)) {
ft_status_update_partial_fetch_reason(bfe, i, BP_STATE(node, i), (node->height == 0));
if (BP_STATE(node,i) == PT_COMPRESSED) {
e = toku_deserialize_bp_from_compressed(node, i, &bfe->h->cmp_descriptor, bfe->h->compare_fun);
r = toku_deserialize_bp_from_compressed(node, i, &bfe->h->cmp_descriptor, bfe->h->compare_fun);
}
else if (BP_STATE(node,i) == PT_ON_DISK) {
e = toku_deserialize_bp_from_disk(node, ndd, i, fd, bfe);
r = toku_deserialize_bp_from_disk(node, ndd, i, fd, bfe);
}
else {
assert(FALSE);
}
}
if (e != DS_OK) {
if (e == DS_XSUM_FAIL) {
if (r != 0) {
if (r == TOKUDB_BAD_CHECKSUM) {
fprintf(stderr,
"Checksum failure while reading node partition in file %s.\n",
toku_cachefile_fname_in_env(bfe->h->cf));
} else if (e == DS_ERRNO) {
} else {
fprintf(stderr,
"Error while reading node partition %d\n",
errno);
......
This diff is collapsed.
......@@ -510,16 +510,10 @@ int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_ac
int r;
{
int fd = toku_cachefile_get_fd(cf);
enum deserialize_error_code e = toku_deserialize_ft_from(fd, max_acceptable_lsn, &h);
if (e == DS_XSUM_FAIL) {
r = toku_deserialize_ft_from(fd, max_acceptable_lsn, &h);
if (r == TOKUDB_BAD_CHECKSUM) {
fprintf(stderr, "Checksum failure while reading header in file %s.\n", toku_cachefile_fname_in_env(cf));
assert(false); // make absolutely sure we crash before doing anything else
} else if (e == DS_ERRNO) {
r = errno;
} else if (e == DS_OK) {
r = 0;
} else {
assert(false);
}
}
if (r!=0) return r;
......
......@@ -288,12 +288,6 @@ enum reactivity {
RE_FISSIBLE
};
enum deserialize_error_code {
DS_OK = 0,
DS_XSUM_FAIL,
DS_ERRNO
};
#if defined(__cplusplus) || defined(__cilkplusplus)
};
#endif
......
......@@ -98,7 +98,7 @@ deserialize_headers(int fd, struct ft **h1p, struct ft **h2p)
BOOL h0_acceptable = FALSE;
BOOL h1_acceptable = FALSE;
int r0, r1;
enum deserialize_error_code e = DS_OK;
int r;
{
toku_off_t header_0_off = 0;
......@@ -108,8 +108,7 @@ deserialize_headers(int fd, struct ft **h1p, struct ft **h2p)
&rb_0,
&checkpoint_count_0,
&checkpoint_lsn_0,
&version_0,
&e
&version_0
);
if ((r0==0) && (checkpoint_lsn_0.lsn <= MAX_LSN.lsn)) {
h0_acceptable = TRUE;
......@@ -123,8 +122,7 @@ deserialize_headers(int fd, struct ft **h1p, struct ft **h2p)
&rb_1,
&checkpoint_count_1,
&checkpoint_lsn_1,
&version_1,
&e
&version_1
);
if ((r1==0) && (checkpoint_lsn_1.lsn <= MAX_LSN.lsn)) {
h1_acceptable = TRUE;
......@@ -138,9 +136,9 @@ deserialize_headers(int fd, struct ft **h1p, struct ft **h2p)
}
if (h0_acceptable) {
printf("Found dictionary header 1 with LSN %"PRIu64"\n", checkpoint_lsn_0.lsn);
e = deserialize_ft_versioned(fd, &rb_0, h1p, version_0);
r = deserialize_ft_versioned(fd, &rb_0, h1p, version_0);
if (e != DS_OK) {
if (r != 0) {
printf("---Header Error----\n");
}
......@@ -149,8 +147,8 @@ deserialize_headers(int fd, struct ft **h1p, struct ft **h2p)
}
if (h1_acceptable) {
printf("Found dictionary header 2 with LSN %"PRIu64"\n", checkpoint_lsn_1.lsn);
e = deserialize_ft_versioned(fd, &rb_1, h2p, version_1);
if (e != DS_OK) {
r = deserialize_ft_versioned(fd, &rb_1, h2p, version_1);
if (r != 0) {
printf("---Header Error----\n");
}
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment