Skip to content

Commit

Permalink
InnoDB/XtraDB Encryption cleanup.
Browse files Browse the repository at this point in the history
Step 1:
-- Remove page encryption from dictionary (per table
encryption will be handled by storing crypt_data to page 0)
-- Remove encryption/compression from os0file and all functions
before that (compression will be added to buf0buf.cc)
-- Use same CRYPT_SCHEME_1 for all encryption methods
-- Do some code cleanups to confort InnoDB coding style
  • Loading branch information
Jan Lindström authored and vuvova committed Apr 7, 2015
1 parent 47c344b commit b4a4d82
Show file tree
Hide file tree
Showing 64 changed files with 2,450 additions and 3,957 deletions.
2 changes: 1 addition & 1 deletion extra/innochecksum.cc
Expand Up @@ -52,10 +52,10 @@ The parts not included are excluded by #ifndef UNIV_INNOCHECKSUM. */
#include "ut0ut.h"
#include "ut0byte.h"
#include "mach0data.h"
#include "fsp0types.h"
#include "rem0rec.h"
#include "buf0checksum.h" /* buf_calc_page_*() */
#include "fil0fil.h" /* FIL_* */
#include "fsp0types.h"
#include "page0page.h" /* PAGE_* */
#include "page0zip.h" /* page_zip_*() */
#include "trx0undo.h" /* TRX_* */
Expand Down
8 changes: 4 additions & 4 deletions storage/innobase/buf/buf0buf.cc
Expand Up @@ -40,6 +40,7 @@ Created 11/5/1995 Heikki Tuuri
#include "mem0mem.h"
#include "btr0btr.h"
#include "fil0fil.h"
#include "fil0crypt.h"
#ifndef UNIV_HOTBACKUP
#include "buf0buddy.h"
#include "lock0lock.h"
Expand All @@ -54,7 +55,6 @@ Created 11/5/1995 Heikki Tuuri
#include "page0zip.h"
#include "srv0mon.h"
#include "buf0checksum.h"
#include "fil0pageencryption.h"
#include "fil0pagecompress.h"
#include "ut0byte.h"
#include <new>
Expand Down Expand Up @@ -504,7 +504,7 @@ buf_page_is_corrupted(
ulint zip_size) /*!< in: size of compressed page;
0 for uncompressed pages */
{
ulint page_encrypted = fil_page_is_compressed_encrypted(read_buf) || fil_page_is_encrypted(read_buf);
ulint page_encrypted = fil_page_is_encrypted(read_buf);
ulint checksum_field1;
ulint checksum_field2;
ibool crc32_inited = FALSE;
Expand Down Expand Up @@ -5763,7 +5763,7 @@ buf_page_decrypt_after_read(
unsigned key_version =
mach_read_from_4(src_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);

bool page_compressed_encrypted = fil_page_is_compressed_encrypted(dst_frame);
bool page_compressed = fil_page_is_compressed(dst_frame);

if (key_version == 0) {
/* the page we read is unencrypted */
Expand Down Expand Up @@ -5801,7 +5801,7 @@ buf_page_decrypt_after_read(

/* decompress from dst_frame to comp_buf and then copy to
buffer pool */
if (page_compressed_encrypted) {
if (page_compressed) {
if (bpage->comp_buf_free == NULL) {
bpage->comp_buf_free = (byte *)malloc(UNIV_PAGE_SIZE*2);
// TODO: is 4k aligment enough ?
Expand Down
44 changes: 16 additions & 28 deletions storage/innobase/buf/buf0dblwr.cc
Expand Up @@ -36,6 +36,8 @@ Created 2011/12/19
#include "srv0srv.h"
#include "page0zip.h"
#include "trx0sys.h"
#include "fil0fil.h"
#include "fil0crypt.h"

#ifndef UNIV_HOTBACKUP

Expand Down Expand Up @@ -385,7 +387,7 @@ buf_dblwr_init_or_load_pages(
/* Read the trx sys header to check if we are using the doublewrite
buffer */
off_t trx_sys_page = TRX_SYS_PAGE_NO * UNIV_PAGE_SIZE;
os_file_read(file, read_buf, trx_sys_page, UNIV_PAGE_SIZE, FALSE);
os_file_read(file, read_buf, trx_sys_page, UNIV_PAGE_SIZE);

doublewrite = read_buf + TRX_SYS_DOUBLEWRITE;

Expand Down Expand Up @@ -430,9 +432,9 @@ buf_dblwr_init_or_load_pages(

block_bytes = TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE;

os_file_read(file, buf, block1 * UNIV_PAGE_SIZE, block_bytes, FALSE);
os_file_read(file, buf, block1 * UNIV_PAGE_SIZE, block_bytes);
os_file_read(file, buf + block_bytes, block2 * UNIV_PAGE_SIZE,
block_bytes, FALSE);
block_bytes);

/* Check if any of these pages is half-written in data files, in the
intended position */
Expand Down Expand Up @@ -530,9 +532,7 @@ buf_dblwr_process()
zip_size ? zip_size : UNIV_PAGE_SIZE,
read_buf,
NULL,
0,
0,
false);
0);

if (fil_space_verify_crypt_checksum(read_buf, zip_size)) {
/* page is encrypted and checksum is OK */
Expand Down Expand Up @@ -593,9 +593,7 @@ buf_dblwr_process()
zip_size ? zip_size : UNIV_PAGE_SIZE,
page,
NULL,
0,
0,
false);
0);

ib_logf(IB_LOG_LEVEL_INFO,
"Recovered the page from"
Expand All @@ -620,9 +618,7 @@ buf_dblwr_process()
zip_size ? zip_size : UNIV_PAGE_SIZE,
page,
NULL,
0,
0,
false);
0);
}
}
}
Expand All @@ -644,9 +640,9 @@ buf_dblwr_process()
memset(buf, 0, bytes);

fil_io(OS_FILE_WRITE, true, TRX_SYS_SPACE, 0,
buf_dblwr->block1, 0, bytes, buf, NULL, NULL, 0, false);
buf_dblwr->block1, 0, bytes, buf, NULL, NULL);
fil_io(OS_FILE_WRITE, true, TRX_SYS_SPACE, 0,
buf_dblwr->block2, 0, bytes, buf, NULL, NULL, 0, false);
buf_dblwr->block2, 0, bytes, buf, NULL, NULL);

ut_free(unaligned_buf);
}
Expand Down Expand Up @@ -860,9 +856,7 @@ buf_dblwr_write_block_to_datafile(
buf_page_get_zip_size(bpage),
frame,
(void*) bpage,
0,
bpage->newest_modification,
bpage->encrypt_later);
0);

return;
}
Expand All @@ -881,9 +875,7 @@ buf_dblwr_write_block_to_datafile(
UNIV_PAGE_SIZE,
frame,
(void*) block,
(ulint *)&bpage->write_size,
bpage->newest_modification,
bpage->encrypt_later);
(ulint *)&bpage->write_size);
}

/********************************************************************//**
Expand Down Expand Up @@ -977,7 +969,7 @@ buf_dblwr_flush_buffered_writes(void)

fil_io(OS_FILE_WRITE, true, TRX_SYS_SPACE, 0,
buf_dblwr->block1, 0, len,
(void*) write_buf, NULL, 0, 0, false);
(void*) write_buf, NULL, 0);

if (buf_dblwr->first_free <= TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
/* No unwritten pages in the second block. */
Expand All @@ -993,7 +985,7 @@ buf_dblwr_flush_buffered_writes(void)

fil_io(OS_FILE_WRITE, true, TRX_SYS_SPACE, 0,
buf_dblwr->block2, 0, len,
(void*) write_buf, NULL, 0, 0, false);
(void*) write_buf, NULL, 0);

flush:
/* increment the doublewrite flushed pages counter */
Expand Down Expand Up @@ -1230,9 +1222,7 @@ buf_dblwr_write_single_page(
UNIV_PAGE_SIZE,
(void*) (buf_dblwr->write_buf + UNIV_PAGE_SIZE * i),
NULL,
0,
bpage->newest_modification,
bpage->encrypt_later);
0);
} else {
/* It is a regular page. Write it directly to the
doublewrite buffer */
Expand All @@ -1244,9 +1234,7 @@ buf_dblwr_write_single_page(
UNIV_PAGE_SIZE,
frame,
NULL,
0,
bpage->newest_modification,
bpage->encrypt_later);
0);
}

/* Now flush the doublewrite buffer data to disk */
Expand Down
8 changes: 2 additions & 6 deletions storage/innobase/buf/buf0flu.cc
Expand Up @@ -921,9 +921,7 @@ buf_flush_write_block_low(
zip_size ? zip_size : UNIV_PAGE_SIZE,
frame,
bpage,
&bpage->write_size,
bpage->newest_modification,
bpage->encrypt_later);
&bpage->write_size);
} else {

/* InnoDB uses doublewrite buffer and doublewrite buffer
Expand All @@ -943,9 +941,7 @@ buf_flush_write_block_low(
zip_size ? zip_size : UNIV_PAGE_SIZE,
frame,
bpage,
&bpage->write_size,
bpage->newest_modification,
bpage->encrypt_later);
&bpage->write_size);
} else if (flush_type == BUF_FLUSH_SINGLE_PAGE) {
buf_dblwr_write_single_page(bpage, sync);
} else {
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/buf/buf0rea.cc
Expand Up @@ -186,15 +186,15 @@ buf_read_page_low(
*err = fil_io(OS_FILE_READ | wake_later
| ignore_nonexistent_pages,
sync, space, zip_size, offset, 0, zip_size,
frame, bpage, &bpage->write_size, 0, false);
frame, bpage, &bpage->write_size);
} else {
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);

*err = fil_io(OS_FILE_READ | wake_later
| ignore_nonexistent_pages,
sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
frame, bpage,
&bpage->write_size, 0, false);
&bpage->write_size);
}

if (sync) {
Expand Down

0 comments on commit b4a4d82

Please sign in to comment.