mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Removed unnecessary memory initialization of page compressed buffer
and added guard against unalligned trim size.
This commit is contained in:
@@ -4482,10 +4482,6 @@ found:
|
||||
|
||||
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 */
|
||||
@@ -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
|
||||
@@ -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) {
|
||||
|
||||
@@ -4585,10 +4585,6 @@ found:
|
||||
|
||||
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 */
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user