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 | /*====== |
5 | This file is part of PerconaFT. |
6 | |
7 | |
8 | Copyright (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 | |
48 | unsigned int toku_serialize_ftnode_size(FTNODE node); |
49 | int 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); |
59 | int 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); |
66 | int 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); |
72 | void toku_serialize_rollback_log_to_memory_uncompressed( |
73 | ROLLBACK_LOG_NODE log, |
74 | SERIALIZED_ROLLBACK_LOG_NODE serialized); |
75 | |
76 | int toku_deserialize_rollback_log_from(int fd, |
77 | BLOCKNUM blocknum, |
78 | ROLLBACK_LOG_NODE *logp, |
79 | FT ft); |
80 | int (FTNODE node, |
81 | FTNODE_DISK_DATA ndd, |
82 | int childnum, |
83 | int fd, |
84 | ftnode_fetch_extra *bfe); |
85 | int (FTNODE node, |
86 | int childnum, |
87 | ftnode_fetch_extra *bfe); |
88 | int (int fd, |
89 | BLOCKNUM off, |
90 | uint32_t fullhash, |
91 | FTNODE *node, |
92 | FTNODE_DISK_DATA *ndd, |
93 | ftnode_fetch_extra *bfe); |
94 | |
95 | void toku_serialize_set_parallel(bool); |
96 | |
97 | // used by nonleaf node partial eviction |
98 | void 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). |
102 | int 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 |
105 | int deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ft, uint32_t version); |
106 | void read_block_from_fd_into_rbuf(int fd, |
107 | BLOCKNUM blocknum, |
108 | FT ft, |
109 | struct rbuf *rb); |
110 | int read_compressed_sub_block(struct rbuf *rb, struct sub_block *sb); |
111 | int verify_ftnode_sub_block(struct sub_block *sb, |
112 | const char *fname, |
113 | BLOCKNUM blocknum); |
114 | void just_decompress_sub_block(struct sub_block *sb); |
115 | |
116 | // used by ft-node-deserialize.cc |
117 | void initialize_ftnode(FTNODE node, BLOCKNUM blocknum); |
118 | int read_and_check_magic(struct rbuf *rb); |
119 | int read_and_check_version(FTNODE node, struct rbuf *rb); |
120 | void read_node_info(FTNODE node, struct rbuf *rb, int version); |
121 | void allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DATA *ndd); |
122 | int check_node_info_checksum(struct rbuf *rb); |
123 | void read_legacy_node_info(FTNODE node, struct rbuf *rb, int version); |
124 | int check_legacy_end_checksum(struct rbuf *rb); |
125 | |
126 | // exported so the loader can dump bad blocks |
127 | void dump_bad_block(unsigned char *vp, uint64_t size); |
128 | |