Commit 7cae47df authored by Yoni Fogel's avatar Yoni Fogel

Fixes #1542 h->dirty protected by the translation table lock

git-svn-id: file:///svn/toku/tokudb@10162 c7de825b-a66e-492c-adef-691d508d4ae1
parent 73286984
...@@ -136,8 +136,9 @@ update_size_on_disk(BLOCK_TABLE bt) { ...@@ -136,8 +136,9 @@ update_size_on_disk(BLOCK_TABLE bt) {
} }
void void
toku_block_realloc(BLOCK_TABLE bt, BLOCKNUM b, u_int64_t size, u_int64_t *offset) { toku_block_realloc(BLOCK_TABLE bt, BLOCKNUM b, u_int64_t size, u_int64_t *offset, int *dirty) {
lock_for_blocktable(); lock_for_blocktable();
*dirty = 1;
extend_block_translation(bt, b); extend_block_translation(bt, b);
block_free_blocknum(bt, b); block_free_blocknum(bt, b);
block_alloc_and_set_translation(bt, b, size, offset); block_alloc_and_set_translation(bt, b, size, offset);
......
...@@ -14,7 +14,7 @@ struct block_translation_pair { ...@@ -14,7 +14,7 @@ struct block_translation_pair {
void toku_blocktable_lock_init(void); void toku_blocktable_lock_init(void);
void toku_blocktable_lock_destroy(void); void toku_blocktable_lock_destroy(void);
void toku_block_realloc(BLOCK_TABLE bt, BLOCKNUM b, u_int64_t size, u_int64_t *offset); void toku_block_realloc(BLOCK_TABLE bt, BLOCKNUM b, u_int64_t size, u_int64_t *offset, int *dirty);
void toku_block_alloc(BLOCK_TABLE bt, u_int64_t size, u_int64_t *offset); void toku_block_alloc(BLOCK_TABLE bt, u_int64_t size, u_int64_t *offset);
void toku_block_free(BLOCK_TABLE bt, u_int64_t offset); void toku_block_free(BLOCK_TABLE bt, u_int64_t offset);
DISKOFF toku_block_get_offset(BLOCK_TABLE bt, BLOCKNUM b); DISKOFF toku_block_get_offset(BLOCK_TABLE bt, BLOCKNUM b);
......
...@@ -360,10 +360,11 @@ int toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct b ...@@ -360,10 +360,11 @@ int toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct b
//printf("%s:%d translated_blocknum_limit=%lu blocknum.b=%lu\n", __FILE__, __LINE__, h->translated_blocknum_limit, blocknum.b); //printf("%s:%d translated_blocknum_limit=%lu blocknum.b=%lu\n", __FILE__, __LINE__, h->translated_blocknum_limit, blocknum.b);
//printf("%s:%d allocator=%p\n", __FILE__, __LINE__, h->block_allocator); //printf("%s:%d allocator=%p\n", __FILE__, __LINE__, h->block_allocator);
//printf("%s:%d bt=%p\n", __FILE__, __LINE__, h->block_translation); //printf("%s:%d bt=%p\n", __FILE__, __LINE__, h->block_translation);
h->dirty = 1; // Allocating a block dirties the header.
size_t n_to_write = uncompressed_magic_len + compression_header_len + compressed_len; size_t n_to_write = uncompressed_magic_len + compression_header_len + compressed_len;
u_int64_t offset; u_int64_t offset;
toku_block_realloc(h->blocktable, blocknum, n_to_write, &offset);
//h will be dirtied
toku_block_realloc(h->blocktable, blocknum, n_to_write, &offset, &h->dirty);
ssize_t n_wrote; ssize_t n_wrote;
r=toku_pwrite_extend(fd, compressed_buf, n_to_write, offset, &n_wrote); r=toku_pwrite_extend(fd, compressed_buf, n_to_write, offset, &n_wrote);
if (r) { if (r) {
......
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