Commit 24bc0314 authored by Jan Lindström's avatar Jan Lindström

Removed unnecessary memory initialization of page compressed buffer

and added guard against unalligned trim size.
parent 25318038
...@@ -4482,10 +4482,6 @@ found: ...@@ -4482,10 +4482,6 @@ found:
ut_ad(slot->page_buf); ut_ad(slot->page_buf);
/* Write buffer full of zeros, this is needed for trim,
can't really avoid this now. */
memset(slot->page_buf, 0, len);
tmp = fil_compress_page(fil_node_get_space_id(slot->message1), (byte *)buf, slot->page_buf, len, page_compression_level, &real_len); tmp = fil_compress_page(fil_node_get_space_id(slot->message1), (byte *)buf, slot->page_buf, len, page_compression_level, &real_len);
/* If compression succeeded, set up the length and buffer */ /* If compression succeeded, set up the length and buffer */
...@@ -6155,6 +6151,8 @@ os_file_trim( ...@@ -6155,6 +6151,8 @@ os_file_trim(
#define SECT_SIZE 512 #define SECT_SIZE 512
size_t trim_len = UNIV_PAGE_SIZE - len; size_t trim_len = UNIV_PAGE_SIZE - len;
// len here should be alligned to sector size
ut_a(trim_len == ((trim_len + SECT_SIZE-1) & ~(SECT_SIZE-1)));
os_offset_t off = slot->offset + len; os_offset_t off = slot->offset + len;
// Nothing to do if trim length is zero or if actual write // Nothing to do if trim length is zero or if actual write
...@@ -6185,7 +6183,6 @@ os_file_trim( ...@@ -6185,7 +6183,6 @@ os_file_trim(
#ifdef __linux__ #ifdef __linux__
#if defined(FALLOC_FL_PUNCH_HOLE) && defined (FALLOC_FL_KEEP_SIZE) #if defined(FALLOC_FL_PUNCH_HOLE) && defined (FALLOC_FL_KEEP_SIZE)
trim_len = (trim_len & ~(SECT_SIZE - 1)) + SECT_SIZE;
int ret = fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len); int ret = fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len);
if (ret) { if (ret) {
......
...@@ -4585,10 +4585,6 @@ found: ...@@ -4585,10 +4585,6 @@ found:
ut_ad(slot->page_buf); ut_ad(slot->page_buf);
/* Write buffer full of zeros, this is needed for trim,
can't really avoid this now. */
memset(slot->page_buf, 0, len);
tmp = fil_compress_page(fil_node_get_space_id(slot->message1), (byte *)buf, slot->page_buf, len, page_compression_level, &real_len); tmp = fil_compress_page(fil_node_get_space_id(slot->message1), (byte *)buf, slot->page_buf, len, page_compression_level, &real_len);
/* If compression succeeded, set up the length and buffer */ /* If compression succeeded, set up the length and buffer */
...@@ -6210,6 +6206,8 @@ os_file_trim( ...@@ -6210,6 +6206,8 @@ os_file_trim(
#define SECT_SIZE 512 #define SECT_SIZE 512
size_t trim_len = UNIV_PAGE_SIZE - len; size_t trim_len = UNIV_PAGE_SIZE - len;
// len here should be alligned to sector size
ut_a(trim_len == ((trim_len + SECT_SIZE-1) & ~(SECT_SIZE-1)));
os_offset_t off = slot->offset + len; os_offset_t off = slot->offset + len;
// Nothing to do if trim length is zero or if actual write // Nothing to do if trim length is zero or if actual write
......
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