Skip to content

Commit

Permalink
Rename LOG_HEADER_FORMAT_ to log_t::FORMAT_
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Oct 28, 2019
1 parent 8f46e38 commit d67ea81
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
47 changes: 24 additions & 23 deletions storage/innobase/include/log0log.h
Expand Up @@ -405,7 +405,7 @@ extern my_bool innodb_log_checksums;

#define LOG_BLOCK_KEY 4 /* encryption key version
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
contents; in InnoDB versions
< 3.23.52 this did not contain the
Expand Down Expand Up @@ -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_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
Expand All @@ -502,6 +485,24 @@ typedef ib_mutex_t FlushOrderMutex;

/** Redo log buffer */
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)
lsn_t lsn; /*!< log sequence number */
ulong buf_free; /*!< first free offset within the log
Expand Down Expand Up @@ -550,7 +551,7 @@ struct log_t{
struct files {
/** number of 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;
/** redo log subformat: 0 with separately logged TRUNCATE,
2 with fully redo-logged TRUNCATE (1 in MariaDB 10.2) */
Expand All @@ -568,7 +569,7 @@ struct log_t{
lsn_t scanned_lsn;

/** @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 */
lsn_t capacity() const{ return (file_size - LOG_FILE_HDR_SIZE) * n_files; }
/** Calculate the offset of a log sequence number.
Expand Down Expand Up @@ -711,22 +712,22 @@ struct log_t{
/** @return the log block header + trailer size */
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_CHECKSUM;
}
/** @return the log block payload size */
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 -
LOG_BLOCK_KEY
: OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM;
}
/** @return the log block trailer offset */
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;
}
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/log/log0crypt.cc
Expand Up @@ -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
- LOG_BLOCK_CHECKSUM];
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;
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;
switch (op) {
case LOG_ENCRYPT_ROTATE_KEY:
Expand Down
7 changes: 3 additions & 4 deletions storage/innobase/log/log0log.cc
Expand Up @@ -601,8 +601,7 @@ void log_t::files::create(ulint n_files)
ut_ad(log_sys.is_initialised());

this->n_files= n_files;
format= srv_encrypt_log
? LOG_HEADER_FORMAT_ENC_10_4 : LOG_HEADER_FORMAT_10_4;
format= srv_encrypt_log ? log_t::FORMAT_ENC_10_4 : log_t::FORMAT_10_4;
subformat= 2;
file_size= srv_log_file_size;
lsn= LOG_START_LSN;
Expand All @@ -624,8 +623,8 @@ log_file_header_flush(
ut_ad(log_write_mutex_own());
ut_ad(!recv_no_log_write);
ut_a(nth_file < log_sys.log.n_files);
ut_ad(log_sys.log.format == LOG_HEADER_FORMAT_10_4
|| log_sys.log.format == LOG_HEADER_FORMAT_ENC_10_4);
ut_ad(log_sys.log.format == log_t::FORMAT_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
MY_ALIGNED(OS_FILE_LOG_BLOCK_SIZE)
Expand Down
22 changes: 11 additions & 11 deletions storage/innobase/log/log0recv.cc
Expand Up @@ -1221,10 +1221,10 @@ recv_find_max_checkpoint(ulint* max_field)
/* Check the header page checksum. There was no
checksum in the first redo log format (version 0). */
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)
: 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)) {
ib::error() << "Invalid redo log header checksum.";
return(DB_CORRUPTION);
Expand All @@ -1237,14 +1237,14 @@ recv_find_max_checkpoint(ulint* max_field)
creator[LOG_HEADER_CREATOR_END - LOG_HEADER_CREATOR] = 0;

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));
case LOG_HEADER_FORMAT_10_2:
case LOG_HEADER_FORMAT_10_2 | LOG_HEADER_FORMAT_ENCRYPTED:
case LOG_HEADER_FORMAT_10_3:
case LOG_HEADER_FORMAT_10_3 | LOG_HEADER_FORMAT_ENCRYPTED:
case LOG_HEADER_FORMAT_10_4:
case LOG_HEADER_FORMAT_10_4 | LOG_HEADER_FORMAT_ENCRYPTED:
case log_t::FORMAT_10_2:
case log_t::FORMAT_10_2 | log_t::FORMAT_ENCRYPTED:
case log_t::FORMAT_10_3:
case log_t::FORMAT_10_3 | log_t::FORMAT_ENCRYPTED:
case log_t::FORMAT_10_4:
case log_t::FORMAT_10_4 | log_t::FORMAT_ENCRYPTED:
break;
default:
ib::error() << "Unsupported redo log format."
Expand Down Expand Up @@ -2350,8 +2350,8 @@ void recv_apply_hashed_log_recs(bool last_batch)
tables whose names start with FTS_ to
skip the optimization. */
if ((log_sys.log.format
& ~LOG_HEADER_FORMAT_ENCRYPTED)
!= LOG_HEADER_FORMAT_10_4
& ~log_t::FORMAT_ENCRYPTED)
!= log_t::FORMAT_10_4
&& strstr(space->name, "/FTS_")) {
goto do_read;
}
Expand Down
8 changes: 4 additions & 4 deletions storage/innobase/srv/srv0start.cc
Expand Up @@ -1223,8 +1223,8 @@ srv_prepare_to_delete_redo_log_files(
{
ib::info info;
if (srv_log_file_size == 0
|| (log_sys.log.format & ~LOG_HEADER_FORMAT_ENCRYPTED)
!= LOG_HEADER_FORMAT_10_4) {
|| (log_sys.log.format & ~log_t::FORMAT_ENCRYPTED)
!= log_t::FORMAT_10_4) {
info << "Upgrading redo log: ";
} else if (n_files != srv_n_log_files
|| srv_log_file_size
Expand Down Expand Up @@ -2044,8 +2044,8 @@ dberr_t srv_start(bool create_new_db)
&& srv_n_log_files_found == srv_n_log_files
&& log_sys.log.format
== (srv_encrypt_log
? LOG_HEADER_FORMAT_ENC_10_4
: LOG_HEADER_FORMAT_10_4)
? log_t::FORMAT_ENC_10_4
: log_t::FORMAT_10_4)
&& log_sys.log.subformat == 2) {
/* No need to add or remove encryption,
upgrade, downgrade, or resize. */
Expand Down

0 comments on commit d67ea81

Please sign in to comment.