1/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
3#ident "$Id$"
4/*======
5This file is part of PerconaFT.
6
7
8Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
9
10 PerconaFT is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License, version 2,
12 as published by the Free Software Foundation.
13
14 PerconaFT is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
21
22----------------------------------------
23
24 PerconaFT is free software: you can redistribute it and/or modify
25 it under the terms of the GNU Affero General Public License, version 3,
26 as published by the Free Software Foundation.
27
28 PerconaFT is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU Affero General Public License for more details.
32
33 You should have received a copy of the GNU Affero General Public License
34 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
35======= */
36
37#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
38
39#pragma once
40
41#include "ft/ft.h"
42#include "ft/node.h"
43#include "ft/serialize/sub_block.h"
44#include "ft/serialize/rbuf.h"
45#include "ft/serialize/wbuf.h"
46#include "ft/serialize/block_table.h"
47
48unsigned int toku_serialize_ftnode_size(FTNODE node);
49int toku_serialize_ftnode_to_memory(
50 FTNODE node,
51 FTNODE_DISK_DATA *ndd,
52 unsigned int basementnodesize,
53 enum toku_compression_method compression_method,
54 bool do_rebalancing,
55 bool in_parallel,
56 size_t *n_bytes_to_write,
57 size_t *n_uncompressed_bytes,
58 char **bytes_to_write);
59int toku_serialize_ftnode_to(int fd,
60 BLOCKNUM,
61 FTNODE node,
62 FTNODE_DISK_DATA *ndd,
63 bool do_rebalancing,
64 FT ft,
65 bool for_checkpoint);
66int toku_serialize_rollback_log_to(int fd,
67 ROLLBACK_LOG_NODE log,
68 SERIALIZED_ROLLBACK_LOG_NODE serialized_log,
69 bool is_serialized,
70 FT ft,
71 bool for_checkpoint);
72void toku_serialize_rollback_log_to_memory_uncompressed(
73 ROLLBACK_LOG_NODE log,
74 SERIALIZED_ROLLBACK_LOG_NODE serialized);
75
76int toku_deserialize_rollback_log_from(int fd,
77 BLOCKNUM blocknum,
78 ROLLBACK_LOG_NODE *logp,
79 FT ft);
80int toku_deserialize_bp_from_disk(FTNODE node,
81 FTNODE_DISK_DATA ndd,
82 int childnum,
83 int fd,
84 ftnode_fetch_extra *bfe);
85int toku_deserialize_bp_from_compressed(FTNODE node,
86 int childnum,
87 ftnode_fetch_extra *bfe);
88int toku_deserialize_ftnode_from(int fd,
89 BLOCKNUM off,
90 uint32_t fullhash,
91 FTNODE *node,
92 FTNODE_DISK_DATA *ndd,
93 ftnode_fetch_extra *bfe);
94
95void toku_serialize_set_parallel(bool);
96
97// used by nonleaf node partial eviction
98void toku_create_compressed_partition_from_available(FTNODE node, int childnum,
99 enum toku_compression_method compression_method, SUB_BLOCK sb);
100
101// <CER> For verifying old, non-upgraded nodes (versions 13 and 14).
102int decompress_from_raw_block_into_rbuf(uint8_t *raw_block, size_t raw_block_size, struct rbuf *rb, BLOCKNUM blocknum);
103
104// used by verify
105int deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ft, uint32_t version);
106void read_block_from_fd_into_rbuf(int fd,
107 BLOCKNUM blocknum,
108 FT ft,
109 struct rbuf *rb);
110int read_compressed_sub_block(struct rbuf *rb, struct sub_block *sb);
111int verify_ftnode_sub_block(struct sub_block *sb,
112 const char *fname,
113 BLOCKNUM blocknum);
114void just_decompress_sub_block(struct sub_block *sb);
115
116// used by ft-node-deserialize.cc
117void initialize_ftnode(FTNODE node, BLOCKNUM blocknum);
118int read_and_check_magic(struct rbuf *rb);
119int read_and_check_version(FTNODE node, struct rbuf *rb);
120void read_node_info(FTNODE node, struct rbuf *rb, int version);
121void allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DATA *ndd);
122int check_node_info_checksum(struct rbuf *rb);
123void read_legacy_node_info(FTNODE node, struct rbuf *rb, int version);
124int check_legacy_end_checksum(struct rbuf *rb);
125
126// exported so the loader can dump bad blocks
127void dump_bad_block(unsigned char *vp, uint64_t size);
128