Commit e5374ac8 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:3266], per CR comments, collapse two functions into one

git-svn-id: file:///svn/toku/tokudb@29159 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9a64a896
......@@ -3242,22 +3242,24 @@ verify_builtin_comparisons_consistent(BRT t, u_int32_t flags) {
}
int
toku_write_descriptor_to_disk(struct brt_header * h, DESCRIPTOR d, int fd) {
toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd) {
int r = 0;
DISKOFF offset;
//4 for checksum
toku_realloc_descriptor_on_disk(h->blocktable, toku_serialize_descriptor_size(d)+4, &offset, h);
r = toku_serialize_descriptor_contents_to_fd(fd, d, offset);
return r;
}
void
update_descriptor_in_memory(BRT t, const DBT* new_descriptor) {
if (t->h->descriptor.dbt.data) {
toku_free(t->h->descriptor.dbt.data);
if (r) {
goto cleanup;
}
t->h->descriptor.dbt.size = new_descriptor->size;
t->h->descriptor.dbt.data = toku_memdup(new_descriptor->data, new_descriptor->size);
if (h->descriptor.dbt.data) {
toku_free(h->descriptor.dbt.data);
}
h->descriptor.dbt.size = d->dbt.size;
h->descriptor.dbt.data = toku_memdup(d->dbt.data, d->dbt.size);
r = 0;
cleanup:
return r;
}
int
......@@ -3304,11 +3306,10 @@ toku_brt_change_descriptor(
// write new_descriptor to header
new_d.dbt = *new_descriptor;
fd = toku_cachefile_get_and_pin_fd (t->cf);
r = toku_write_descriptor_to_disk(t->h, &new_d, fd);
r = toku_update_descriptor(t->h, &new_d, fd);
toku_cachefile_unpin_fd(t->cf);
if (r!=0) goto cleanup;
update_descriptor_in_memory(t, new_descriptor);
cleanup:
return r;
}
......
......@@ -30,8 +30,7 @@ typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN, bytevec, ITEMLEN, bytevec, void
int toku_open_brt (const char *fname, int is_create, BRT *, int nodesize, CACHETABLE, TOKUTXN, int(*)(DB*,const DBT*,const DBT*), DB*) __attribute__ ((warn_unused_result));
int toku_brt_change_descriptor(BRT t, const DBT* old_descriptor, const DBT* new_descriptor, BOOL do_log, TOKUTXN txn);
int toku_write_descriptor_to_disk(struct brt_header * h, DESCRIPTOR d, int fd);
void update_descriptor_in_memory(BRT t, const DBT* new_descriptor);
int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd);
int toku_dictionary_redirect (const char *dst_fname_in_env, BRT old_brt, TOKUTXN txn) __attribute__ ((warn_unused_result));
......
......@@ -563,10 +563,8 @@ toku_rollback_change_fdescriptor(FILENUM filenum,
DESCRIPTOR_S d;
toku_fill_dbt(&d.dbt, old_descriptor.data, old_descriptor.len);
r = toku_write_descriptor_to_disk(brt->h, &d, fd);
r = toku_update_descriptor(brt->h, &d, fd);
assert(r == 0);
update_descriptor_in_memory(brt, &d.dbt);
}
toku_cachefile_unpin_fd(cf);
done:
......
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