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
...@@ -3241,23 +3241,25 @@ verify_builtin_comparisons_consistent(BRT t, u_int32_t flags) { ...@@ -3241,23 +3241,25 @@ verify_builtin_comparisons_consistent(BRT t, u_int32_t flags) {
return 0; return 0;
} }
int 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; int r = 0;
DISKOFF offset; DISKOFF offset;
//4 for checksum //4 for checksum
toku_realloc_descriptor_on_disk(h->blocktable, toku_serialize_descriptor_size(d)+4, &offset, h); 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); r = toku_serialize_descriptor_contents_to_fd(fd, d, offset);
return r; if (r) {
} goto cleanup;
}
void if (h->descriptor.dbt.data) {
update_descriptor_in_memory(BRT t, const DBT* new_descriptor) { toku_free(h->descriptor.dbt.data);
if (t->h->descriptor.dbt.data) {
toku_free(t->h->descriptor.dbt.data);
} }
t->h->descriptor.dbt.size = new_descriptor->size; h->descriptor.dbt.size = d->dbt.size;
t->h->descriptor.dbt.data = toku_memdup(new_descriptor->data, new_descriptor->size); h->descriptor.dbt.data = toku_memdup(d->dbt.data, d->dbt.size);
r = 0;
cleanup:
return r;
} }
int int
...@@ -3304,11 +3306,10 @@ toku_brt_change_descriptor( ...@@ -3304,11 +3306,10 @@ toku_brt_change_descriptor(
// write new_descriptor to header // write new_descriptor to header
new_d.dbt = *new_descriptor; new_d.dbt = *new_descriptor;
fd = toku_cachefile_get_and_pin_fd (t->cf); 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); toku_cachefile_unpin_fd(t->cf);
if (r!=0) goto cleanup; if (r!=0) goto cleanup;
update_descriptor_in_memory(t, new_descriptor);
cleanup: cleanup:
return r; return r;
} }
......
...@@ -30,8 +30,7 @@ typedef int(*BRT_GET_CALLBACK_FUNCTION)(ITEMLEN, bytevec, ITEMLEN, bytevec, void ...@@ -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_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_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); int toku_update_descriptor(struct brt_header * h, DESCRIPTOR d, int fd);
void update_descriptor_in_memory(BRT t, const DBT* new_descriptor);
int toku_dictionary_redirect (const char *dst_fname_in_env, BRT old_brt, TOKUTXN txn) __attribute__ ((warn_unused_result)); 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, ...@@ -563,10 +563,8 @@ toku_rollback_change_fdescriptor(FILENUM filenum,
DESCRIPTOR_S d; DESCRIPTOR_S d;
toku_fill_dbt(&d.dbt, old_descriptor.data, old_descriptor.len); 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); assert(r == 0);
update_descriptor_in_memory(brt, &d.dbt);
} }
toku_cachefile_unpin_fd(cf); toku_cachefile_unpin_fd(cf);
done: 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