Commit b33c3a65 authored by Christian Rober's avatar Christian Rober Committed by Yoni Fogel

refs #4885 Fixed comments and comment structure for upgrade helper functions

git-svn-id: file:///svn/toku/tokudb@45214 c7de825b-a66e-492c-adef-691d508d4ae1
parent f6f07370
/* -*- mode: C; c-basic-offset: 4 -*- */ /* -*- mode: C; c-basic-offset: 4 -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4: // vim: expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id: ft-serialize.c 43686 2012-05-18 23:21:00Z leifwalsh $" #ident "$Id: ft-node-serialize.c 43686 2012-05-18 23:21:00Z leifwalsh $"
#ident "Copyright (c) 2007-2010 Tokutek Inc. All rights reserved." #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." #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 <ft-internal.h> #include <ft-internal.h>
#include <db.h> #include <db.h>
//////////////////////////////////////// /*
// 1. Sets initial values * ft-node-deserialize.c -
// * This file contains functions used by deserializtion
* code paths in and out of the engine. The functions can,
* essentially, be broken up into two types. Some of these
* functions return error codes based expected values inside
* the fractal tree node, others merely read the specific
* quantities of bytes out of the buffer. It is expeceted
* that these will be called in the correct order by users
* of these functions/this API.
*
*/
// Sets initial values for the given fractal tree node to be
// desiralized
inline void inline void
initialize_ftnode(FTNODE node, BLOCKNUM blocknum) initialize_ftnode(FTNODE node, BLOCKNUM blocknum)
{ {
...@@ -22,18 +34,15 @@ initialize_ftnode(FTNODE node, BLOCKNUM blocknum) ...@@ -22,18 +34,15 @@ initialize_ftnode(FTNODE node, BLOCKNUM blocknum)
node->layout_version_read_from_disk = 0; node->layout_version_read_from_disk = 0;
} }
// TODO:
/************************ /************************
* In other deserialization code, we check the rb size member. We * TODO: In other deserialization code, we check the rb size member. We
* verify that it is greater than or equal to 24. Ignoring this magic * verify that it is greater than or equal to 24. Ignoring this magic
* number for a moment, should we put this check in its own function? * * number for a moment, should we put this check in its own function? *
*************************/ *************************/
/////////////////////////////////////////////////////////////////////
// 2. Read and check the 'magic' bytes on disk. Returns an error if // Read and check the 'magic' bytes on disk. Returns an error if
// the magic does not match. // the magic does not match.
//
int int
read_and_check_magic(struct rbuf *rb) read_and_check_magic(struct rbuf *rb)
{ {
...@@ -42,14 +51,14 @@ read_and_check_magic(struct rbuf *rb) ...@@ -42,14 +51,14 @@ read_and_check_magic(struct rbuf *rb)
rbuf_literal_bytes(rb, &magic, 8); rbuf_literal_bytes(rb, &magic, 8);
if (memcmp(magic, "tokuleaf", 8)!=0 && if (memcmp(magic, "tokuleaf", 8)!=0 &&
memcmp(magic, "tokunode", 8)!=0) { memcmp(magic, "tokunode", 8)!=0) {
r = DB_BADFORMAT; // TODO: Return more meaningful error. r = DB_BADFORMAT; // TODO: Return more meaningful error.
} }
return r; return r;
} }
//////////////////// // Read the version number from the given buffer
// 3. // and returns an error if the version is too old.
int int
read_and_check_version(FTNODE node, struct rbuf *rb) read_and_check_version(FTNODE node, struct rbuf *rb)
{ {
...@@ -57,14 +66,14 @@ read_and_check_version(FTNODE node, struct rbuf *rb) ...@@ -57,14 +66,14 @@ read_and_check_version(FTNODE node, struct rbuf *rb)
int version = rbuf_int(rb); int version = rbuf_int(rb);
node->layout_version_read_from_disk = version; node->layout_version_read_from_disk = version;
if (version < FT_LAYOUT_MIN_SUPPORTED_VERSION) { if (version < FT_LAYOUT_MIN_SUPPORTED_VERSION) {
r = 1; // TODO: Better error reporting. r = 1; // TODO: Better error reporting.
} }
return r; return r;
} }
//////////////////// // Reads the basic version, build, and child info from
// 4. // the given buffer.
void void
read_node_info(FTNODE node, struct rbuf *rb, int version) read_node_info(FTNODE node, struct rbuf *rb, int version)
{ {
...@@ -74,9 +83,10 @@ read_node_info(FTNODE node, struct rbuf *rb, int version) ...@@ -74,9 +83,10 @@ read_node_info(FTNODE node, struct rbuf *rb, int version)
node->n_children = rbuf_int(rb); node->n_children = rbuf_int(rb);
} }
//////////////////// // Allocates the partitions based on the given node's nubmer
// 5. // of children. It then reads, out of the given buffer,
// <CER> Should these be two seperate functions? // the start and size of each child partition.
// TODO: Should these be two seperate functions?
void void
allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DATA *ndd) allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DATA *ndd)
{ {
...@@ -90,8 +100,9 @@ allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DA ...@@ -90,8 +100,9 @@ allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DA
} }
} }
//////////////////// // Compares checksum of stored (in the given buffer) checksum
// 6. Check the node info checksum. // and the checksum of the buffer itself. If these are NOT
// equal, this function returns an appropriate error code.
int int
check_node_info_checksum(struct rbuf *rb) check_node_info_checksum(struct rbuf *rb)
{ {
...@@ -102,54 +113,8 @@ check_node_info_checksum(struct rbuf *rb) ...@@ -102,54 +113,8 @@ check_node_info_checksum(struct rbuf *rb)
if (stored_checksum != checksum) { if (stored_checksum != checksum) {
// TODO: dump_bad_block(rb->buf, rb->size); // TODO: dump_bad_block(rb->buf, rb->size);
r = TOKUDB_BAD_CHECKSUM; r = TOKUDB_BAD_CHECKSUM;
} }
return r; return r;
} }
// Two functions, at this point, SHOULD be split into sperate read and
// checksum check calls:
// 1. read_and_decompress_sub_block - this is generic, used elsewhere.
// So....
// a. call read_compressed_sub_block() directly
// then....
//
// 2. deserialize_ftnode_info() - this actually reads in the node
// 'info' fields, such as height, nodesize, etc.
/////////////////////////////////
// ?. ----
// setup_ftnode_paritions() -
// calls :
// a. update_bfe_using_ftnode
// b. setup_partitions_using_bfe()
/////////////////////////////////
// ?. partition from sub-block deserialization.
// A.decompress_and_deserialize_worker()
// calls:
// a. read_and_decompress_sub_block (SEE ABOVE) -
// -calls:
// -ii. read_compressed_sub_block() - Returns checksum error AND reads out buffer.
// b. deserialize_ftnode_partition()
// -calls:
// -ii. verify_ftnode_sub_block() - JUST verifies checksum.
//
// OR
//
// B. check_and_copy_compressed_sub_block_worker
// calls:
// a. read_compressed_sub_block() - Returns checksum AND reads out of buffer.
/////////////////////////////////
// 1. first calls verify_ftnode_sub_block() which must be refactored
// into two seperate calls.
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