Commit a5dbbe4b authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel
Browse files

[t:3983] merging auto-upgrade to mainline

git-svn-id: file:///svn/toku/tokudb@41591 c7de825b-a66e-492c-adef-691d508d4ae1
parent 77168d0c
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -755,11 +755,12 @@ translation_default(struct translation *t) { // destination into which to creat
}


static void
static enum deserialize_error_code
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;
    assert(location_on_disk!=0);
    t->type = TRANSLATION_CHECKPOINTED;
    {
@@ -768,7 +769,11 @@ translation_deserialize_from_buffer(struct translation *t, // destination int
        u_int64_t offset = size_on_disk - 4;
        //printf("%s:%d read from %ld (x1764 offset=%ld) size=%ld\n", __FILE__, __LINE__, block_translation_address_on_disk, offset, block_translation_size_on_disk);
        u_int32_t stored_x1764 = toku_dtoh32(*(int*)(translation_buffer + offset));
        assert(x1764 == stored_x1764);
        if (x1764 != stored_x1764) {
            fprintf(stderr, "Translation table checksum failure: calc=0x%08x read=0x%08x\n", x1764, stored_x1764);
            e = DS_XSUM_FAIL;
            goto exit;
        }
    }
    struct rbuf rt;
    rt.buf = translation_buffer;
@@ -789,6 +794,9 @@ 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;
}

// We just initialized a translation, inform block allocator to reserve space for each blocknum in use.
@@ -817,17 +825,22 @@ 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.
void
enum deserialize_error_code
toku_blocktable_create_from_buffer(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();
    translation_deserialize_from_buffer(&bt->checkpointed, location_on_disk, size_on_disk, translation_buffer);
    enum deserialize_error_code e = translation_deserialize_from_buffer(&bt->checkpointed, location_on_disk, size_on_disk, translation_buffer);
    if (e != DS_OK) {
        goto exit;
    }
    blocktable_note_translation(bt->block_allocator, &bt->checkpointed);
    // we just filled in checkpointed, now copy it to current.  
    copy_translation(&bt->current, &bt->checkpointed, TRANSLATION_CURRENT);
    *btp = bt;
exit:
    return e;
}


+3 −1
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
#ident "Copyright (c) 2007-2010 Tokutek Inc.  All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."

#include <brttypes.h>

#if defined(__cplusplus) || defined(__cilkplusplus)
extern "C" {
#endif
@@ -21,7 +23,7 @@ struct block_translation_pair {
};

void toku_blocktable_create_new(BLOCK_TABLE *btp);
void toku_blocktable_create_from_buffer(BLOCK_TABLE *btp, DISKOFF location_on_disk, DISKOFF size_on_disk, unsigned char *translation_buffer);
enum deserialize_error_code toku_blocktable_create_from_buffer(BLOCK_TABLE *btp, DISKOFF location_on_disk, DISKOFF size_on_disk, unsigned char *translation_buffer);
void toku_blocktable_destroy(BLOCK_TABLE *btp);

void toku_brtheader_lock(struct brt_header *h);
+5 −12
Original line number Diff line number Diff line
@@ -251,7 +251,6 @@ struct brtnode {
    int    height; /* height is always >= 0.  0 for leaf, >0 for nonleaf. */
    int    dirty;
    u_int32_t fullhash;
    uint32_t optimized_for_upgrade;   // version number to which this leaf has been optimized, zero if never optimized for upgrade
    int n_children; //for internal nodes, if n_children==TREE_FANOUT+1 then the tree needs to be rebalanced.
                    // for leaf nodes, represents number of basement nodes
    unsigned int    totalchildkeylens;
@@ -377,9 +376,6 @@ struct brt_header {
    uint64_t time_of_creation;          // time this tree was created
    uint64_t time_of_last_modification; // last time this header was serialized to disk (read from disk, overwritten when written to disk)
    uint64_t time_of_last_verification; // last time that this tree was verified
    BOOL upgrade_brt_performed;         // initially FALSE, set TRUE when brt has been fully updated (even though nodes may not have been)
    int64_t num_blocks_to_upgrade_13;   // Number of v13 blocks still not newest version. 
    int64_t num_blocks_to_upgrade_14;   // Number of v14 blocks still not newest version. 
    unsigned int nodesize;
    unsigned int basementnodesize;
    // this field is protected by tree_lock, see comment for tree_lock
@@ -411,6 +407,10 @@ struct brt_header {
    uint32_t count_of_optimize_in_progress_read_from_disk;   // the number of hot optimize operations in progress on this tree at the time of the last crash  (this field is in-memory only)
    MSN      msn_at_start_of_last_completed_optimize;   // all messages before this msn have been applied to leaf nodes
    enum toku_compression_method compression_method;
    // Current Minimum MSN to be used when upgrading pre-MSN BRT's.
    // This is decremented from our currnt MIN_MSN so as not to clash
    // with any existing 'normal' MSN's.
    MSN      highest_unused_msn_for_upgrade;
};

struct brt {
@@ -479,7 +479,7 @@ toku_brt_header_init(struct brt_header *h,
int toku_serialize_brt_header_size (struct brt_header *h);
int toku_serialize_brt_header_to (int fd, struct brt_header *h);
int toku_serialize_brt_header_to_wbuf (struct wbuf *, struct brt_header *h, int64_t address_translation, int64_t size_translation);
int toku_deserialize_brtheader_from (int fd, LSN max_acceptable_lsn, struct brt_header **brth);
enum deserialize_error_code toku_deserialize_brtheader_from (int fd, LSN max_acceptable_lsn, struct brt_header **brth);
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);
@@ -818,7 +818,6 @@ int toku_brtheader_close (CACHEFILE cachefile, int fd, void *header_v, char **er
int toku_brtheader_begin_checkpoint (LSN checkpoint_lsn, void *header_v) __attribute__((__warn_unused_result__));
int toku_brtheader_checkpoint (CACHEFILE cachefile, int fd, void *header_v) __attribute__((__warn_unused_result__));
int toku_brtheader_end_checkpoint (CACHEFILE cachefile, int fd, void *header_v) __attribute__((__warn_unused_result__));
int toku_maybe_upgrade_brt(BRT t) __attribute__((__warn_unused_result__));
int toku_db_badformat(void) __attribute__((__warn_unused_result__));

int toku_brt_remove_on_commit(TOKUTXN child, DBT* iname_dbt_p) __attribute__((__warn_unused_result__));
@@ -826,10 +825,6 @@ int toku_brt_remove_now(CACHETABLE ct, DBT* iname_dbt_p) __attribute__((__warn_u

typedef enum {
    BRT_UPGRADE_FOOTPRINT = 0,
    BRT_UPGRADE_HEADER_13,    // how many headers were upgraded from version 13
    BRT_UPGRADE_NONLEAF_13,
    BRT_UPGRADE_LEAF_13, 
    BRT_UPGRADE_OPTIMIZED_FOR_UPGRADE, // how many optimize_for_upgrade messages were sent
    BRT_UPGRADE_STATUS_NUM_ROWS
} brt_upgrade_status_entry;

@@ -937,7 +932,6 @@ brt_leaf_put_cmd (
    BRTNODE leafnode,
    BASEMENTNODE bn, 
    BRT_MSG cmd, 
    bool* made_change,
    uint64_t *workdone,
    OMT snapshot_txnids,
    OMT live_list_reverse
@@ -949,7 +943,6 @@ void toku_apply_cmd_to_leaf(
    DESCRIPTOR desc, 
    BRTNODE node, 
    BRT_MSG cmd, 
    bool *made_change, 
    uint64_t *workdone,
    OMT snapshot_txnids,
    OMT live_list_reverse
+1017 −381

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@


// dummymsn needed to simulate msn because messages are injected at a lower level than toku_brt_root_put_cmd()
#define MIN_DUMMYMSN ((MSN) {(uint64_t)100000000000})
#define MIN_DUMMYMSN ((MSN) {(uint64_t)1 << 62})
static MSN dummymsn;      
static int testsetup_initialized = 0;

Loading