Skip to content

Commit 24bc031

Browse files
author
Jan Lindström
committed
Removed unnecessary memory initialization of page compressed buffer
and added guard against unalligned trim size.
1 parent 2531803 commit 24bc031

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

storage/innobase/os/os0file.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4482,10 +4482,6 @@ os_aio_array_reserve_slot(
44824482

44834483
ut_ad(slot->page_buf);
44844484

4485-
/* Write buffer full of zeros, this is needed for trim,
4486-
can't really avoid this now. */
4487-
memset(slot->page_buf, 0, len);
4488-
44894485
tmp = fil_compress_page(fil_node_get_space_id(slot->message1), (byte *)buf, slot->page_buf, len, page_compression_level, &real_len);
44904486

44914487
/* If compression succeeded, set up the length and buffer */
@@ -6155,6 +6151,8 @@ os_file_trim(
61556151

61566152
#define SECT_SIZE 512
61576153
size_t trim_len = UNIV_PAGE_SIZE - len;
6154+
// len here should be alligned to sector size
6155+
ut_a(trim_len == ((trim_len + SECT_SIZE-1) & ~(SECT_SIZE-1)));
61586156
os_offset_t off = slot->offset + len;
61596157

61606158
// Nothing to do if trim length is zero or if actual write
@@ -6185,7 +6183,6 @@ os_file_trim(
61856183

61866184
#ifdef __linux__
61876185
#if defined(FALLOC_FL_PUNCH_HOLE) && defined (FALLOC_FL_KEEP_SIZE)
6188-
trim_len = (trim_len & ~(SECT_SIZE - 1)) + SECT_SIZE;
61896186
int ret = fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len);
61906187

61916188
if (ret) {

storage/xtradb/os/os0file.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4585,10 +4585,6 @@ os_aio_array_reserve_slot(
45854585

45864586
ut_ad(slot->page_buf);
45874587

4588-
/* Write buffer full of zeros, this is needed for trim,
4589-
can't really avoid this now. */
4590-
memset(slot->page_buf, 0, len);
4591-
45924588
tmp = fil_compress_page(fil_node_get_space_id(slot->message1), (byte *)buf, slot->page_buf, len, page_compression_level, &real_len);
45934589

45944590
/* If compression succeeded, set up the length and buffer */
@@ -6210,6 +6206,8 @@ os_file_trim(
62106206

62116207
#define SECT_SIZE 512
62126208
size_t trim_len = UNIV_PAGE_SIZE - len;
6209+
// len here should be alligned to sector size
6210+
ut_a(trim_len == ((trim_len + SECT_SIZE-1) & ~(SECT_SIZE-1)));
62136211
os_offset_t off = slot->offset + len;
62146212

62156213
// Nothing to do if trim length is zero or if actual write

0 commit comments

Comments
 (0)