Skip to content

Commit

Permalink
Removed unnecessary memory initialization of page compressed buffer
Browse files Browse the repository at this point in the history
and added guard against unalligned trim size.
  • Loading branch information
Jan Lindström committed Feb 19, 2014
1 parent 2531803 commit 24bc031
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 2 additions & 5 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4482,10 +4482,6 @@ os_aio_array_reserve_slot(

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);

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

#define SECT_SIZE 512
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;

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

#ifdef __linux__
#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);

if (ret) {
Expand Down
6 changes: 2 additions & 4 deletions storage/xtradb/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4585,10 +4585,6 @@ os_aio_array_reserve_slot(

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);

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

#define SECT_SIZE 512
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;

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

0 comments on commit 24bc031

Please sign in to comment.