Commit d67ea815 authored by Marko Mäkelä's avatar Marko Mäkelä

Rename LOG_HEADER_FORMAT_ to log_t::FORMAT_

parent 8f46e383
...@@ -405,7 +405,7 @@ extern my_bool innodb_log_checksums; ...@@ -405,7 +405,7 @@ extern my_bool innodb_log_checksums;
#define LOG_BLOCK_KEY 4 /* encryption key version #define LOG_BLOCK_KEY 4 /* encryption key version
before LOG_BLOCK_CHECKSUM; before LOG_BLOCK_CHECKSUM;
in LOG_HEADER_FORMAT_ENC_10_4 only */ in log_t::FORMAT_ENC_10_4 only */
#define LOG_BLOCK_CHECKSUM 4 /* 4 byte checksum of the log block #define LOG_BLOCK_CHECKSUM 4 /* 4 byte checksum of the log block
contents; in InnoDB versions contents; in InnoDB versions
< 3.23.52 this did not contain the < 3.23.52 this did not contain the
...@@ -461,23 +461,6 @@ or the MySQL version that created the redo log file. */ ...@@ -461,23 +461,6 @@ or the MySQL version that created the redo log file. */
IB_TO_STR(MYSQL_VERSION_MINOR) "." \ IB_TO_STR(MYSQL_VERSION_MINOR) "." \
IB_TO_STR(MYSQL_VERSION_PATCH) IB_TO_STR(MYSQL_VERSION_PATCH)
/** The original (not version-tagged) InnoDB redo log format */
#define LOG_HEADER_FORMAT_3_23 0
/** The MySQL 5.7.9/MariaDB 10.2.2 log format */
#define LOG_HEADER_FORMAT_10_2 1
/** The MariaDB 10.3.2 log format.
To prevent crash-downgrade to earlier 10.2 due to the inability to
roll back a retroactively introduced TRX_UNDO_RENAME_TABLE undo log record,
MariaDB 10.2.18 and later will use the 10.3 format, but LOG_HEADER_SUBFORMAT
1 instead of 0. MariaDB 10.3 will use subformat 0 (5.7-style TRUNCATE) or 2
(MDEV-13564 backup-friendly TRUNCATE). */
#define LOG_HEADER_FORMAT_10_3 103
#define LOG_HEADER_FORMAT_10_4 104
/** The MariaDB 10.4.0 log format (only with innodb_encrypt_log=ON) */
#define LOG_HEADER_FORMAT_ENC_10_4 (104U | 1U << 31)
/** Encrypted MariaDB redo log */
#define LOG_HEADER_FORMAT_ENCRYPTED (1U<<31)
/* @} */ /* @} */
#define LOG_CHECKPOINT_1 OS_FILE_LOG_BLOCK_SIZE #define LOG_CHECKPOINT_1 OS_FILE_LOG_BLOCK_SIZE
...@@ -502,6 +485,24 @@ typedef ib_mutex_t FlushOrderMutex; ...@@ -502,6 +485,24 @@ typedef ib_mutex_t FlushOrderMutex;
/** Redo log buffer */ /** Redo log buffer */
struct log_t{ struct log_t{
/** The original (not version-tagged) InnoDB redo log format */
static constexpr uint32_t FORMAT_3_23 = 0;
/** The MySQL 5.7.9/MariaDB 10.2.2 log format */
static constexpr uint32_t FORMAT_10_2 = 1;
/** The MariaDB 10.3.2 log format.
To prevent crash-downgrade to earlier 10.2 due to the inability to
roll back a retroactively introduced TRX_UNDO_RENAME_TABLE undo log record,
MariaDB 10.2.18 and later will use the 10.3 format, but LOG_HEADER_SUBFORMAT
1 instead of 0. MariaDB 10.3 will use subformat 0 (5.7-style TRUNCATE) or 2
(MDEV-13564 backup-friendly TRUNCATE). */
static constexpr uint32_t FORMAT_10_3 = 103;
/** The MariaDB 10.4.0 log format. */
static constexpr uint32_t FORMAT_10_4 = 104;
/** Encrypted MariaDB redo log */
static constexpr uint32_t FORMAT_ENCRYPTED = 1U << 31;
/** The MariaDB 10.4.0 log format (only with innodb_encrypt_log=ON) */
static constexpr uint32_t FORMAT_ENC_10_4 = FORMAT_10_4 | FORMAT_ENCRYPTED;
MY_ALIGNED(CACHE_LINE_SIZE) MY_ALIGNED(CACHE_LINE_SIZE)
lsn_t lsn; /*!< log sequence number */ lsn_t lsn; /*!< log sequence number */
ulong buf_free; /*!< first free offset within the log ulong buf_free; /*!< first free offset within the log
...@@ -550,7 +551,7 @@ struct log_t{ ...@@ -550,7 +551,7 @@ struct log_t{
struct files { struct files {
/** number of files */ /** number of files */
ulint n_files; ulint n_files;
/** format of the redo log: e.g., LOG_HEADER_FORMAT_10_4 */ /** format of the redo log: e.g., FORMAT_10_4 */
uint32_t format; uint32_t format;
/** redo log subformat: 0 with separately logged TRUNCATE, /** redo log subformat: 0 with separately logged TRUNCATE,
2 with fully redo-logged TRUNCATE (1 in MariaDB 10.2) */ 2 with fully redo-logged TRUNCATE (1 in MariaDB 10.2) */
...@@ -568,7 +569,7 @@ struct log_t{ ...@@ -568,7 +569,7 @@ struct log_t{
lsn_t scanned_lsn; lsn_t scanned_lsn;
/** @return whether the redo log is encrypted */ /** @return whether the redo log is encrypted */
bool is_encrypted() const { return format & LOG_HEADER_FORMAT_ENCRYPTED; } bool is_encrypted() const { return format & FORMAT_ENCRYPTED; }
/** @return capacity in bytes */ /** @return capacity in bytes */
lsn_t capacity() const{ return (file_size - LOG_FILE_HDR_SIZE) * n_files; } lsn_t capacity() const{ return (file_size - LOG_FILE_HDR_SIZE) * n_files; }
/** Calculate the offset of a log sequence number. /** Calculate the offset of a log sequence number.
...@@ -711,14 +712,14 @@ struct log_t{ ...@@ -711,14 +712,14 @@ struct log_t{
/** @return the log block header + trailer size */ /** @return the log block header + trailer size */
unsigned framing_size() const unsigned framing_size() const
{ {
return log.format == LOG_HEADER_FORMAT_ENC_10_4 return log.format == FORMAT_ENC_10_4
? LOG_BLOCK_HDR_SIZE + LOG_BLOCK_KEY + LOG_BLOCK_CHECKSUM ? LOG_BLOCK_HDR_SIZE + LOG_BLOCK_KEY + LOG_BLOCK_CHECKSUM
: LOG_BLOCK_HDR_SIZE + LOG_BLOCK_CHECKSUM; : LOG_BLOCK_HDR_SIZE + LOG_BLOCK_CHECKSUM;
} }
/** @return the log block payload size */ /** @return the log block payload size */
unsigned payload_size() const unsigned payload_size() const
{ {
return log.format == LOG_HEADER_FORMAT_ENC_10_4 return log.format == FORMAT_ENC_10_4
? OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM - ? OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM -
LOG_BLOCK_KEY LOG_BLOCK_KEY
: OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM; : OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM;
...@@ -726,7 +727,7 @@ struct log_t{ ...@@ -726,7 +727,7 @@ struct log_t{
/** @return the log block trailer offset */ /** @return the log block trailer offset */
unsigned trailer_offset() const unsigned trailer_offset() const
{ {
return log.format == LOG_HEADER_FORMAT_ENC_10_4 return log.format == FORMAT_ENC_10_4
? OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM - LOG_BLOCK_KEY ? OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM - LOG_BLOCK_KEY
: OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM; : OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM;
} }
......
...@@ -173,10 +173,10 @@ bool log_crypt(byte* buf, lsn_t lsn, ulint size, log_crypt_t op) ...@@ -173,10 +173,10 @@ bool log_crypt(byte* buf, lsn_t lsn, ulint size, log_crypt_t op)
byte* key_ver = &buf[OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_KEY byte* key_ver = &buf[OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_KEY
- LOG_BLOCK_CHECKSUM]; - LOG_BLOCK_CHECKSUM];
const uint dst_size const uint dst_size
= log_sys.log.format == LOG_HEADER_FORMAT_ENC_10_4 = log_sys.log.format == log_t::FORMAT_ENC_10_4
? sizeof dst - LOG_BLOCK_KEY ? sizeof dst - LOG_BLOCK_KEY
: sizeof dst; : sizeof dst;
if (log_sys.log.format == LOG_HEADER_FORMAT_ENC_10_4) { if (log_sys.log.format == log_t::FORMAT_ENC_10_4) {
const uint key_version = info.key_version; const uint key_version = info.key_version;
switch (op) { switch (op) {
case LOG_ENCRYPT_ROTATE_KEY: case LOG_ENCRYPT_ROTATE_KEY:
......
...@@ -601,8 +601,7 @@ void log_t::files::create(ulint n_files) ...@@ -601,8 +601,7 @@ void log_t::files::create(ulint n_files)
ut_ad(log_sys.is_initialised()); ut_ad(log_sys.is_initialised());
this->n_files= n_files; this->n_files= n_files;
format= srv_encrypt_log format= srv_encrypt_log ? log_t::FORMAT_ENC_10_4 : log_t::FORMAT_10_4;
? LOG_HEADER_FORMAT_ENC_10_4 : LOG_HEADER_FORMAT_10_4;
subformat= 2; subformat= 2;
file_size= srv_log_file_size; file_size= srv_log_file_size;
lsn= LOG_START_LSN; lsn= LOG_START_LSN;
...@@ -624,8 +623,8 @@ log_file_header_flush( ...@@ -624,8 +623,8 @@ log_file_header_flush(
ut_ad(log_write_mutex_own()); ut_ad(log_write_mutex_own());
ut_ad(!recv_no_log_write); ut_ad(!recv_no_log_write);
ut_a(nth_file < log_sys.log.n_files); ut_a(nth_file < log_sys.log.n_files);
ut_ad(log_sys.log.format == LOG_HEADER_FORMAT_10_4 ut_ad(log_sys.log.format == log_t::FORMAT_10_4
|| log_sys.log.format == LOG_HEADER_FORMAT_ENC_10_4); || log_sys.log.format == log_t::FORMAT_ENC_10_4);
// man 2 open suggests this buffer to be aligned by 512 for O_DIRECT // man 2 open suggests this buffer to be aligned by 512 for O_DIRECT
MY_ALIGNED(OS_FILE_LOG_BLOCK_SIZE) MY_ALIGNED(OS_FILE_LOG_BLOCK_SIZE)
......
...@@ -1221,10 +1221,10 @@ recv_find_max_checkpoint(ulint* max_field) ...@@ -1221,10 +1221,10 @@ recv_find_max_checkpoint(ulint* max_field)
/* Check the header page checksum. There was no /* Check the header page checksum. There was no
checksum in the first redo log format (version 0). */ checksum in the first redo log format (version 0). */
log_sys.log.format = mach_read_from_4(buf + LOG_HEADER_FORMAT); log_sys.log.format = mach_read_from_4(buf + LOG_HEADER_FORMAT);
log_sys.log.subformat = log_sys.log.format != LOG_HEADER_FORMAT_3_23 log_sys.log.subformat = log_sys.log.format != log_t::FORMAT_3_23
? mach_read_from_4(buf + LOG_HEADER_SUBFORMAT) ? mach_read_from_4(buf + LOG_HEADER_SUBFORMAT)
: 0; : 0;
if (log_sys.log.format != LOG_HEADER_FORMAT_3_23 if (log_sys.log.format != log_t::FORMAT_3_23
&& !recv_check_log_header_checksum(buf)) { && !recv_check_log_header_checksum(buf)) {
ib::error() << "Invalid redo log header checksum."; ib::error() << "Invalid redo log header checksum.";
return(DB_CORRUPTION); return(DB_CORRUPTION);
...@@ -1237,14 +1237,14 @@ recv_find_max_checkpoint(ulint* max_field) ...@@ -1237,14 +1237,14 @@ recv_find_max_checkpoint(ulint* max_field)
creator[LOG_HEADER_CREATOR_END - LOG_HEADER_CREATOR] = 0; creator[LOG_HEADER_CREATOR_END - LOG_HEADER_CREATOR] = 0;
switch (log_sys.log.format) { switch (log_sys.log.format) {
case LOG_HEADER_FORMAT_3_23: case log_t::FORMAT_3_23:
return(recv_find_max_checkpoint_0(max_field)); return(recv_find_max_checkpoint_0(max_field));
case LOG_HEADER_FORMAT_10_2: case log_t::FORMAT_10_2:
case LOG_HEADER_FORMAT_10_2 | LOG_HEADER_FORMAT_ENCRYPTED: case log_t::FORMAT_10_2 | log_t::FORMAT_ENCRYPTED:
case LOG_HEADER_FORMAT_10_3: case log_t::FORMAT_10_3:
case LOG_HEADER_FORMAT_10_3 | LOG_HEADER_FORMAT_ENCRYPTED: case log_t::FORMAT_10_3 | log_t::FORMAT_ENCRYPTED:
case LOG_HEADER_FORMAT_10_4: case log_t::FORMAT_10_4:
case LOG_HEADER_FORMAT_10_4 | LOG_HEADER_FORMAT_ENCRYPTED: case log_t::FORMAT_10_4 | log_t::FORMAT_ENCRYPTED:
break; break;
default: default:
ib::error() << "Unsupported redo log format." ib::error() << "Unsupported redo log format."
...@@ -2350,8 +2350,8 @@ void recv_apply_hashed_log_recs(bool last_batch) ...@@ -2350,8 +2350,8 @@ void recv_apply_hashed_log_recs(bool last_batch)
tables whose names start with FTS_ to tables whose names start with FTS_ to
skip the optimization. */ skip the optimization. */
if ((log_sys.log.format if ((log_sys.log.format
& ~LOG_HEADER_FORMAT_ENCRYPTED) & ~log_t::FORMAT_ENCRYPTED)
!= LOG_HEADER_FORMAT_10_4 != log_t::FORMAT_10_4
&& strstr(space->name, "/FTS_")) { && strstr(space->name, "/FTS_")) {
goto do_read; goto do_read;
} }
......
...@@ -1223,8 +1223,8 @@ srv_prepare_to_delete_redo_log_files( ...@@ -1223,8 +1223,8 @@ srv_prepare_to_delete_redo_log_files(
{ {
ib::info info; ib::info info;
if (srv_log_file_size == 0 if (srv_log_file_size == 0
|| (log_sys.log.format & ~LOG_HEADER_FORMAT_ENCRYPTED) || (log_sys.log.format & ~log_t::FORMAT_ENCRYPTED)
!= LOG_HEADER_FORMAT_10_4) { != log_t::FORMAT_10_4) {
info << "Upgrading redo log: "; info << "Upgrading redo log: ";
} else if (n_files != srv_n_log_files } else if (n_files != srv_n_log_files
|| srv_log_file_size || srv_log_file_size
...@@ -2044,8 +2044,8 @@ dberr_t srv_start(bool create_new_db) ...@@ -2044,8 +2044,8 @@ dberr_t srv_start(bool create_new_db)
&& srv_n_log_files_found == srv_n_log_files && srv_n_log_files_found == srv_n_log_files
&& log_sys.log.format && log_sys.log.format
== (srv_encrypt_log == (srv_encrypt_log
? LOG_HEADER_FORMAT_ENC_10_4 ? log_t::FORMAT_ENC_10_4
: LOG_HEADER_FORMAT_10_4) : log_t::FORMAT_10_4)
&& log_sys.log.subformat == 2) { && log_sys.log.subformat == 2) {
/* No need to add or remove encryption, /* No need to add or remove encryption,
upgrade, downgrade, or resize. */ upgrade, downgrade, or resize. */
......
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