| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 2017, 2026, Oracle and/or its affiliates. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify it under |
| 6 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
|
| 28 |
/** @file include/clone0desc.h |
| 29 |
Innodb clone descriptors |
| 30 |
|
| 31 |
*******************************************************/ |
| 32 |
|
| 33 |
#ifndef CLONE_DESC_INCLUDE |
| 34 |
#define CLONE_DESC_INCLUDE |
| 35 |
|
| 36 |
#include "mem0mem.h" |
| 37 |
#include "os0file.h" |
| 38 |
#include "univ.i" |
| 39 |
|
| 40 |
/** Invalid locator ID. */ |
| 41 |
const uint64_t CLONE_LOC_INVALID_ID = 0; |
| 42 |
|
| 43 |
/** Maximum base length for any serialized descriptor. This is only used for |
| 44 |
optimal allocation and has no impact on version compatibility. */ |
| 45 |
const uint32_t CLONE_DESC_MAX_BASE_LEN = |
| 46 |
64 + Encryption::KEY_LEN + Encryption::KEY_LEN; |
| 47 |
/** Align by 4K for O_DIRECT */ |
| 48 |
const uint32_t CLONE_ALIGN_DIRECT_IO = 4 * 1024; |
| 49 |
|
| 50 |
/** Maximum number of concurrent tasks for each clone */ |
| 51 |
const int CLONE_MAX_TASKS = 128; |
| 52 |
|
| 53 |
/** Snapshot state transfer during clone. |
| 54 |
|
| 55 |
Clone Type: HA_CLONE_BLOCKING |
| 56 |
@startuml |
| 57 |
state CLONE_SNAPSHOT_INIT |
| 58 |
state CLONE_SNAPSHOT_FILE_COPY |
| 59 |
state CLONE_SNAPSHOT_DONE |
| 60 |
|
| 61 |
[*] -down-> CLONE_SNAPSHOT_INIT : Build snapshot |
| 62 |
CLONE_SNAPSHOT_INIT -right-> CLONE_SNAPSHOT_FILE_COPY |
| 63 |
CLONE_SNAPSHOT_FILE_COPY -right-> CLONE_SNAPSHOT_DONE |
| 64 |
CLONE_SNAPSHOT_DONE -down-> [*] : Destroy snapshot |
| 65 |
@enduml |
| 66 |
|
| 67 |
Clone Type: HA_CLONE_REDO |
| 68 |
@startuml |
| 69 |
state CLONE_SNAPSHOT_REDO_COPY |
| 70 |
|
| 71 |
[*] -down-> CLONE_SNAPSHOT_INIT : Build snapshot |
| 72 |
CLONE_SNAPSHOT_INIT -right-> CLONE_SNAPSHOT_FILE_COPY : Start redo archiving |
| 73 |
CLONE_SNAPSHOT_FILE_COPY -right-> CLONE_SNAPSHOT_REDO_COPY |
| 74 |
CLONE_SNAPSHOT_REDO_COPY -right-> CLONE_SNAPSHOT_DONE |
| 75 |
CLONE_SNAPSHOT_DONE -down-> [*] : Destroy snapshot |
| 76 |
@enduml |
| 77 |
|
| 78 |
Clone Type: HA_CLONE_HYBRID |
| 79 |
@startuml |
| 80 |
state CLONE_SNAPSHOT_PAGE_COPY |
| 81 |
|
| 82 |
[*] -down-> CLONE_SNAPSHOT_INIT : Build snapshot |
| 83 |
CLONE_SNAPSHOT_INIT -right-> CLONE_SNAPSHOT_FILE_COPY : Start page tracking |
| 84 |
CLONE_SNAPSHOT_FILE_COPY -right-> CLONE_SNAPSHOT_PAGE_COPY : Start redo \ |
| 85 |
archiving |
| 86 |
CLONE_SNAPSHOT_PAGE_COPY -right-> CLONE_SNAPSHOT_REDO_COPY |
| 87 |
CLONE_SNAPSHOT_REDO_COPY -right> CLONE_SNAPSHOT_DONE |
| 88 |
CLONE_SNAPSHOT_DONE -down-> [*] : Destroy snapshot |
| 89 |
@enduml |
| 90 |
|
| 91 |
Clone Type: HA_CLONE_PAGE: Not implemented |
| 92 |
*/ |
| 93 |
enum Snapshot_State : uint32_t { |
| 94 |
/** Invalid state */ |
| 95 |
CLONE_SNAPSHOT_NONE = 0, |
| 96 |
|
| 97 |
/** Initialize state when snapshot object is created */ |
| 98 |
CLONE_SNAPSHOT_INIT, |
| 99 |
|
| 100 |
/** Snapshot state while transferring files. */ |
| 101 |
CLONE_SNAPSHOT_FILE_COPY, |
| 102 |
|
| 103 |
/** Snapshot state while transferring pages. */ |
| 104 |
CLONE_SNAPSHOT_PAGE_COPY, |
| 105 |
|
| 106 |
/** Snapshot state while transferring redo. */ |
| 107 |
CLONE_SNAPSHOT_REDO_COPY, |
| 108 |
|
| 109 |
/** Snapshot state at end after finishing transfer. */ |
| 110 |
CLONE_SNAPSHOT_DONE |
| 111 |
}; |
| 112 |
|
| 113 |
/** Total number of data transfer stages in clone. */ |
| 114 |
const size_t CLONE_MAX_TRANSFER_STAGES = 3; |
| 115 |
|
| 116 |
/** Choose lowest descriptor version between reference locator |
| 117 |
and currently supported version. |
| 118 |
@param[in] ref_loc reference locator |
| 119 |
@return chosen version */ |
| 120 |
uint choose_desc_version(const byte *ref_loc); |
| 121 |
|
| 122 |
/** Check if clone locator is valid |
| 123 |
@param[in] desc_loc serialized descriptor |
| 124 |
@param[in] desc_len descriptor length |
| 125 |
@return true, if valid locator */ |
| 126 |
bool clone_validate_locator(const byte *desc_loc, uint desc_len); |
| 127 |
|
| 128 |
/** Clone descriptors contain meta information needed for applying cloned data. |
| 129 |
These are PODs with interface to serialize and deserialize them. */ |
| 130 |
enum Clone_Desc_Type { |
| 131 |
/** Logical pointer to identify a clone operation */ |
| 132 |
CLONE_DESC_LOCATOR = 1, |
| 133 |
|
| 134 |
/** Metadata for a Task/Thread for clone operation */ |
| 135 |
CLONE_DESC_TASK_METADATA, |
| 136 |
|
| 137 |
/** Information for snapshot state */ |
| 138 |
CLONE_DESC_STATE, |
| 139 |
|
| 140 |
/** Metadata for a database file */ |
| 141 |
CLONE_DESC_FILE_METADATA, |
| 142 |
|
| 143 |
/** Information for a data block */ |
| 144 |
CLONE_DESC_DATA, |
| 145 |
|
| 146 |
/** Must be the last member */ |
| 147 |
CLONE_DESC_MAX |
| 148 |
}; |
| 149 |
|
| 150 |
/** Header common to all descriptors. */ |
| 151 |
struct Clone_Desc_Header { |
| 152 |
/** Descriptor version */ |
| 153 |
uint m_version; |
| 154 |
|
| 155 |
/** Serialized length of descriptor in bytes */ |
| 156 |
uint m_length; |
| 157 |
|
| 158 |
/** Descriptor type */ |
| 159 |
Clone_Desc_Type m_type; |
| 160 |
|
| 161 |
/** Serialize the descriptor header: Caller must allocate |
| 162 |
the serialized buffer. |
| 163 |
@param[out] desc_hdr serialized header */ |
| 164 |
void serialize(byte *desc_hdr); |
| 165 |
|
| 166 |
/** Deserialize the descriptor header. |
| 167 |
@param[in] desc_hdr serialized header |
| 168 |
@param[in] desc_len descriptor length |
| 169 |
@return true, if successful. */ |
| 170 |
bool deserialize(const byte *desc_hdr, uint desc_len); |
| 171 |
}; |
| 172 |
|
| 173 |
/** Task information in clone operation. */ |
| 174 |
struct Clone_Task_Meta { |
| 175 |
/** Index in task array. */ |
| 176 |
uint m_task_index; |
| 177 |
|
| 178 |
/** Current chunk number reserved by the task. */ |
| 179 |
uint m_chunk_num; |
| 180 |
|
| 181 |
/** Current block number that is already transferred. */ |
| 182 |
uint m_block_num; |
| 183 |
}; |
| 184 |
|
| 185 |
/** Map for current block number for unfinished chunks. Used during |
| 186 |
restart from incomplete clone operation. */ |
| 187 |
using Chunk_Map = std::map<uint32_t, uint32_t>; |
| 188 |
|
| 189 |
/** Bitmap for completed chunks in current state */ |
| 190 |
class Chnunk_Bitmap { |
| 191 |
public: |
| 192 |
/** Construct bitmap */ |
| 193 |
Chnunk_Bitmap() : m_bitmap(), m_size(), m_bits() {} |
| 194 |
|
| 195 |
/** Bitmap array index operator implementation */ |
| 196 |
class Bitmap_Operator_Impl { |
| 197 |
public: |
| 198 |
/** Construct bitmap operator |
| 199 |
@param[in] bitmap reference to bitmap buffer |
| 200 |
@param[in] index array operation index */ |
| 201 |
Bitmap_Operator_Impl(uint32_t *&bitmap, uint32_t index) |
| 202 |
|
| 203 |
: m_bitmap_ref(bitmap) { |
| 204 |
/* BYTE position */ |
| 205 |
auto byte_index = index >> 3; |
| 206 |
ut_ad(byte_index == index / 8); |
| 207 |
|
| 208 |
/* MAP array position */ |
| 209 |
m_map_index = byte_index >> 2; |
| 210 |
ut_ad(m_map_index == byte_index / 4); |
| 211 |
|
| 212 |
/* BIT position */ |
| 213 |
auto bit_pos = index & 31; |
| 214 |
ut_ad(bit_pos == index % 32); |
| 215 |
|
| 216 |
m_bit_mask = 1 << bit_pos; |
| 217 |
} |
| 218 |
|
| 219 |
/** Check value at specified index in BITMAP |
| 220 |
@return true if the BIT is set */ |
| 221 |
operator bool() const { |
| 222 |
auto &val = m_bitmap_ref[m_map_index]; |
| 223 |
|
| 224 |
if ((val & m_bit_mask) == 0) { |
| 225 |
return (false); |
| 226 |
} |
| 227 |
|
| 228 |
return (true); |
| 229 |
} |
| 230 |
|
| 231 |
/** Set BIT at specific index |
| 232 |
@param[in] bit bit value to set */ |
| 233 |
void operator=(bool bit) { |
| 234 |
auto &val = m_bitmap_ref[m_map_index]; |
| 235 |
|
| 236 |
if (bit) { |
| 237 |
val |= m_bit_mask; |
| 238 |
} else { |
| 239 |
val &= ~m_bit_mask; |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
private: |
| 244 |
/** Reference to BITMAP array */ |
| 245 |
uint32_t *&m_bitmap_ref; |
| 246 |
|
| 247 |
/** Current array position */ |
| 248 |
uint32_t m_map_index; |
| 249 |
|
| 250 |
/** Mask with current BIT set */ |
| 251 |
uint32_t m_bit_mask; |
| 252 |
}; |
| 253 |
|
| 254 |
/** Array index operator |
| 255 |
@param[in] index bitmap array index |
| 256 |
@return operator implementation object */ |
| 257 |
Bitmap_Operator_Impl operator[](uint32_t index) { |
| 258 |
/* Convert to zero based index */ |
| 259 |
--index; |
| 260 |
|
| 261 |
ut_a(index < m_bits); |
| 262 |
return (Bitmap_Operator_Impl(m_bitmap, index)); |
| 263 |
} |
| 264 |
|
| 265 |
/** Reset bitmap with new size |
| 266 |
@param[in] max_bits number of BITs to hold |
| 267 |
@param[in] heap heap for allocating memory |
| 268 |
@return old buffer pointer */ |
| 269 |
uint32_t *reset(uint32_t max_bits, mem_heap_t *heap); |
| 270 |
|
| 271 |
/** Get minimum BIT position that is not set |
| 272 |
@return BIT position */ |
| 273 |
uint32_t get_min_unset_bit(); |
| 274 |
|
| 275 |
/** Get maximum BIT position that is not set |
| 276 |
@return BIT position */ |
| 277 |
uint32_t get_max_set_bit(); |
| 278 |
|
| 279 |
/** Serialize the descriptor. Caller should pass |
| 280 |
the length if allocated. |
| 281 |
@param[out] desc_chunk serialized chunk info |
| 282 |
@param[in,out] len length of serialized descriptor */ |
| 283 |
void serialize(byte *&desc_chunk, uint &len); |
| 284 |
|
| 285 |
/** Deserialize the descriptor. |
| 286 |
@param[in] desc_chunk serialized chunk info |
| 287 |
@param[in,out] len_left length left in bytes */ |
| 288 |
void deserialize(const byte *desc_chunk, uint &len_left); |
| 289 |
|
| 290 |
/** Get the length of serialized data |
| 291 |
@return length serialized chunk info */ |
| 292 |
size_t get_serialized_length(); |
| 293 |
|
| 294 |
/** Maximum bit capacity |
| 295 |
@return maximum number of BITs it can hold */ |
| 296 |
size_t capacity() const { return (8 * size()); } |
| 297 |
|
| 298 |
/** Size of bitmap in bytes |
| 299 |
@return BITMAP buffer size */ |
| 300 |
size_t size() const { return (m_size * 4); } |
| 301 |
|
| 302 |
/** Size of bitmap in bits |
| 303 |
@return number of BITs stored */ |
| 304 |
uint32_t size_bits() const { return (m_bits); } |
| 305 |
|
| 306 |
private: |
| 307 |
/** BITMAP buffer */ |
| 308 |
uint32_t *m_bitmap; |
| 309 |
|
| 310 |
/** BITMAP buffer size: Number of 4 byte blocks */ |
| 311 |
size_t m_size; |
| 312 |
|
| 313 |
/** Total number of BITs in the MAP */ |
| 314 |
uint32_t m_bits; |
| 315 |
}; |
| 316 |
|
| 317 |
/** Incomplete Chunk information */ |
| 318 |
struct Chunk_Info { |
| 319 |
/** Information about chunks completed */ |
| 320 |
Chnunk_Bitmap m_reserved_chunks; |
| 321 |
|
| 322 |
/** Information about unfinished chunks */ |
| 323 |
Chunk_Map m_incomplete_chunks; |
| 324 |
|
| 325 |
/** Chunks for current state */ |
| 326 |
uint32_t m_total_chunks; |
| 327 |
|
| 328 |
/** Minimum chunk number that is not reserved yet */ |
| 329 |
uint32_t m_min_unres_chunk; |
| 330 |
|
| 331 |
/** Maximum chunk number that is already reserved */ |
| 332 |
uint32_t m_max_res_chunk; |
| 333 |
|
| 334 |
/** Initialize Chunk number ranges */ |
| 335 |
void init_chunk_nums() { |
| 336 |
m_min_unres_chunk = m_reserved_chunks.get_min_unset_bit(); |
| 337 |
ut_ad(m_min_unres_chunk <= m_total_chunks + 1); |
| 338 |
|
| 339 |
m_max_res_chunk = m_reserved_chunks.get_max_set_bit(); |
| 340 |
ut_ad(m_max_res_chunk <= m_total_chunks); |
| 341 |
} |
| 342 |
|
| 343 |
/** Serialize the descriptor. Caller should pass |
| 344 |
the length if allocated. |
| 345 |
@param[out] desc_chunk serialized chunk info |
| 346 |
@param[in,out] len length of serialized descriptor */ |
| 347 |
void serialize(byte *desc_chunk, uint &len); |
| 348 |
|
| 349 |
/** Deserialize the descriptor. |
| 350 |
@param[in] desc_chunk serialized chunk info |
| 351 |
@param[in,out] len_left length left in bytes */ |
| 352 |
void deserialize(const byte *desc_chunk, uint &len_left); |
| 353 |
|
| 354 |
/** Get the length of serialized data |
| 355 |
@param[in] num_tasks number of tasks to include |
| 356 |
@return length serialized chunk info */ |
| 357 |
size_t get_serialized_length(uint32_t num_tasks); |
| 358 |
}; |
| 359 |
|
| 360 |
/** CLONE_DESC_LOCATOR: Descriptor for a task for clone operation. |
| 361 |
A task is used by exactly one thread */ |
| 362 |
struct Clone_Desc_Locator { |
| 363 |
/** Descriptor header */ |
| 364 |
Clone_Desc_Header m_header; |
| 365 |
|
| 366 |
/** Unique identifier for a clone operation. */ |
| 367 |
uint64_t m_clone_id; |
| 368 |
|
| 369 |
/** Unique identifier for a clone snapshot. */ |
| 370 |
uint64_t m_snapshot_id; |
| 371 |
|
| 372 |
/** Index in clone array for fast reference. */ |
| 373 |
uint32_t m_clone_index; |
| 374 |
|
| 375 |
/** Current snapshot State */ |
| 376 |
Snapshot_State m_state; |
| 377 |
|
| 378 |
/** Sub-state information: metadata transferred */ |
| 379 |
bool m_metadata_transferred; |
| 380 |
|
| 381 |
/** Initialize clone locator. |
| 382 |
@param[in] id Clone identifier |
| 383 |
@param[in] snap_id Snapshot identifier |
| 384 |
@param[in] state snapshot state |
| 385 |
@param[in] version Descriptor version |
| 386 |
@param[in] index clone index */ |
| 387 |
void init(uint64_t id, uint64_t snap_id, Snapshot_State state, uint version, |
| 388 |
uint index); |
| 389 |
|
| 390 |
/** Check if the passed locator matches the current one. |
| 391 |
@param[in] other_desc input locator descriptor |
| 392 |
@return true if matches */ |
| 393 |
bool match(Clone_Desc_Locator *other_desc); |
| 394 |
|
| 395 |
/** Serialize the descriptor. Caller should pass |
| 396 |
the length if allocated. |
| 397 |
@param[out] desc_loc serialized descriptor |
| 398 |
@param[in,out] len length of serialized descriptor |
| 399 |
@param[in] chunk_info chunk information to serialize |
| 400 |
@param[in] heap heap for allocating memory */ |
| 401 |
void serialize(byte *&desc_loc, uint &len, Chunk_Info *chunk_info, |
| 402 |
mem_heap_t *heap); |
| 403 |
|
| 404 |
/** Deserialize the descriptor. |
| 405 |
@param[in] desc_loc serialized locator |
| 406 |
@param[in] desc_len locator length |
| 407 |
@param[in,out] chunk_info chunk information */ |
| 408 |
void deserialize(const byte *desc_loc, uint desc_len, Chunk_Info *chunk_info); |
| 409 |
}; |
| 410 |
|
| 411 |
/** CLONE_DESC_TASK_METADATA: Descriptor for a task for clone operation. |
| 412 |
A task is used by exactly one thread */ |
| 413 |
struct Clone_Desc_Task_Meta { |
| 414 |
/** Descriptor header */ |
| 415 |
Clone_Desc_Header m_header; |
| 416 |
|
| 417 |
/** Task information */ |
| 418 |
Clone_Task_Meta m_task_meta; |
| 419 |
|
| 420 |
/** Initialize header |
| 421 |
@param[in] version descriptor version */ |
| 422 |
void init_header(uint version); |
| 423 |
|
| 424 |
/** Serialize the descriptor. Caller should pass |
| 425 |
the length if allocated. |
| 426 |
@param[out] desc_task serialized descriptor |
| 427 |
@param[in,out] len length of serialized descriptor |
| 428 |
@param[in] heap heap for allocating memory */ |
| 429 |
void serialize(byte *&desc_task, uint &len, mem_heap_t *heap); |
| 430 |
|
| 431 |
/** Deserialize the descriptor. |
| 432 |
@param[in] desc_task serialized descriptor |
| 433 |
@param[in] desc_len descriptor length |
| 434 |
@return true, if successful. */ |
| 435 |
bool deserialize(const byte *desc_task, uint desc_len); |
| 436 |
}; |
| 437 |
|
| 438 |
/** CLONE_DESC_STATE: Descriptor for current snapshot state */ |
| 439 |
struct Clone_Desc_State { |
| 440 |
/** Descriptor header */ |
| 441 |
Clone_Desc_Header m_header; |
| 442 |
|
| 443 |
/** Current snapshot State */ |
| 444 |
Snapshot_State m_state; |
| 445 |
|
| 446 |
/** Task identifier */ |
| 447 |
uint m_task_index; |
| 448 |
|
| 449 |
/** Number of chunks in current state */ |
| 450 |
uint m_num_chunks; |
| 451 |
|
| 452 |
/** Number of files in current state */ |
| 453 |
uint m_num_files; |
| 454 |
|
| 455 |
/** Number of estimated bytes to transfer */ |
| 456 |
uint64_t m_estimate; |
| 457 |
|
| 458 |
/** Number of estimated bytes on disk */ |
| 459 |
uint64_t m_estimate_disk; |
| 460 |
|
| 461 |
/** If start processing state */ |
| 462 |
bool m_is_start; |
| 463 |
|
| 464 |
/** State transfer Acknowledgement */ |
| 465 |
bool m_is_ack; |
| 466 |
|
| 467 |
/** Initialize header |
| 468 |
@param[in] version descriptor version */ |
| 469 |
void init_header(uint version); |
| 470 |
|
| 471 |
/** Serialize the descriptor. Caller should pass |
| 472 |
the length if allocated. |
| 473 |
@param[out] desc_state serialized descriptor |
| 474 |
@param[in,out] len length of serialized descriptor |
| 475 |
@param[in] heap heap for allocating memory */ |
| 476 |
void serialize(byte *&desc_state, uint &len, mem_heap_t *heap); |
| 477 |
|
| 478 |
/** Deserialize the descriptor. |
| 479 |
@param[in] desc_state serialized descriptor |
| 480 |
@param[in] desc_len descriptor length |
| 481 |
@return true, if successful. */ |
| 482 |
bool deserialize(const byte *desc_state, uint desc_len); |
| 483 |
}; |
| 484 |
|
| 485 |
/** Clone file information */ |
| 486 |
struct Clone_File_Meta { |
| 487 |
/** Set file as deleted chunk. |
| 488 |
@param[in] chunk chunk number that is found deleted. */ |
| 489 |
inline void set_deleted_chunk(uint32_t chunk) { |
| 490 |
m_begin_chunk = chunk; |
| 491 |
m_end_chunk = 0; |
| 492 |
m_deleted = true; |
| 493 |
} |
| 494 |
|
| 495 |
/** @return true, iff file is deleted. */ |
| 496 |
bool is_deleted() const { return m_deleted; } |
| 497 |
|
| 498 |
/** @return true, iff file is deleted. */ |
| 499 |
bool is_renamed() const { return m_renamed; } |
| 500 |
|
| 501 |
/** @return true, iff file is encrypted. */ |
| 502 |
bool can_encrypt() const { return m_encryption_metadata.can_encrypt(); } |
| 503 |
|
| 504 |
/** Reset DDL state of file metadata. */ |
| 505 |
void reset_ddl() { |
| 506 |
m_renamed = false; |
| 507 |
m_deleted = false; |
| 508 |
} |
| 509 |
|
| 510 |
/* Initialize parameters. */ |
| 511 |
void init(); |
| 512 |
|
| 513 |
/** File size in bytes */ |
| 514 |
uint64_t m_file_size; |
| 515 |
|
| 516 |
/** File allocation size on disk for sparse files. */ |
| 517 |
uint64_t m_alloc_size; |
| 518 |
|
| 519 |
/** Tablespace FSP flags */ |
| 520 |
uint32_t m_fsp_flags; |
| 521 |
|
| 522 |
/** File compression type */ |
| 523 |
Compression::Type m_compress_type; |
| 524 |
|
| 525 |
/** If transparent compression is needed. It is derived information |
| 526 |
and is not transferred. */ |
| 527 |
bool m_punch_hole; |
| 528 |
|
| 529 |
/* Set file metadata as deleted. */ |
| 530 |
bool m_deleted; |
| 531 |
|
| 532 |
/* Set file metadata as renamed. */ |
| 533 |
bool m_renamed; |
| 534 |
|
| 535 |
/* Contains encryption key to be transferred. */ |
| 536 |
bool m_transfer_encryption_key; |
| 537 |
|
| 538 |
/** File system block size. */ |
| 539 |
size_t m_fsblk_size; |
| 540 |
|
| 541 |
/** Tablespace ID for the file */ |
| 542 |
space_id_t m_space_id; |
| 543 |
|
| 544 |
/** File index in clone data file vector */ |
| 545 |
uint m_file_index; |
| 546 |
|
| 547 |
/** Chunk number for the first chunk in file */ |
| 548 |
uint m_begin_chunk; |
| 549 |
|
| 550 |
/** Chunk number for the last chunk in file */ |
| 551 |
uint m_end_chunk; |
| 552 |
|
| 553 |
/** File name length in bytes */ |
| 554 |
size_t m_file_name_len; |
| 555 |
|
| 556 |
/** Allocation length of name buffer. */ |
| 557 |
size_t m_file_name_alloc_len; |
| 558 |
|
| 559 |
/** File name */ |
| 560 |
const char *m_file_name; |
| 561 |
|
| 562 |
/** Encryption metadata. */ |
| 563 |
Encryption_metadata m_encryption_metadata; |
| 564 |
}; |
| 565 |
|
| 566 |
/** CLONE_DESC_FILE_METADATA: Descriptor for file metadata */ |
| 567 |
struct Clone_Desc_File_MetaData { |
| 568 |
/** Descriptor header */ |
| 569 |
Clone_Desc_Header m_header; |
| 570 |
|
| 571 |
/** Current snapshot State */ |
| 572 |
Snapshot_State m_state; |
| 573 |
|
| 574 |
/** File metadata */ |
| 575 |
Clone_File_Meta m_file_meta; |
| 576 |
|
| 577 |
/** Initialize header |
| 578 |
@param[in] version descriptor version */ |
| 579 |
void init_header(uint version); |
| 580 |
|
| 581 |
/** Serialize the descriptor. Caller should pass |
| 582 |
the length if allocated. |
| 583 |
@param[out] desc_file serialized descriptor |
| 584 |
@param[in,out] len length of serialized descriptor |
| 585 |
@param[in] heap heap for allocating memory */ |
| 586 |
void serialize(byte *&desc_file, uint &len, mem_heap_t *heap); |
| 587 |
|
| 588 |
/** Deserialize the descriptor. |
| 589 |
@param[in] desc_file serialized descriptor |
| 590 |
@param[in] desc_len descriptor length |
| 591 |
@return true, if successful. */ |
| 592 |
bool deserialize(const byte *desc_file, uint desc_len); |
| 593 |
}; |
| 594 |
|
| 595 |
/** CLONE_DESC_DATA: Descriptor for data */ |
| 596 |
struct Clone_Desc_Data { |
| 597 |
/** Descriptor header */ |
| 598 |
Clone_Desc_Header m_header; |
| 599 |
|
| 600 |
/** Current snapshot State */ |
| 601 |
Snapshot_State m_state; |
| 602 |
|
| 603 |
/** Task information */ |
| 604 |
Clone_Task_Meta m_task_meta; |
| 605 |
|
| 606 |
/** File identifier */ |
| 607 |
uint32_t m_file_index; |
| 608 |
|
| 609 |
/** Data Length */ |
| 610 |
uint32_t m_data_len; |
| 611 |
|
| 612 |
/** File offset for the data */ |
| 613 |
uint64_t m_file_offset; |
| 614 |
|
| 615 |
/** Updated file size */ |
| 616 |
uint64_t m_file_size; |
| 617 |
|
| 618 |
/** Initialize header |
| 619 |
@param[in] version descriptor version */ |
| 620 |
void init_header(uint version); |
| 621 |
|
| 622 |
/** Serialize the descriptor. Caller should pass |
| 623 |
the length if allocated. |
| 624 |
@param[out] desc_data serialized descriptor |
| 625 |
@param[in,out] len length of serialized descriptor |
| 626 |
@param[in] heap heap for allocating memory */ |
| 627 |
void serialize(byte *&desc_data, uint &len, mem_heap_t *heap); |
| 628 |
|
| 629 |
/** Deserialize the descriptor. |
| 630 |
@param[in] desc_data serialized descriptor |
| 631 |
@param[in] desc_len descriptor length |
| 632 |
@return true, if successful. */ |
| 633 |
bool deserialize(const byte *desc_data, uint desc_len); |
| 634 |
}; |
| 635 |
|
| 636 |
#endif /* CLONE_DESC_INCLUDE */ |