Skip to content

Commit

Permalink
Fix error on trim operation alligment. Furthermore, make sure that
Browse files Browse the repository at this point in the history
we do not return simulated out of file space on read operation,
that would cause crash.
  • Loading branch information
Jan Lindström committed Nov 4, 2014
1 parent 43f185e commit 251fa7f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
10 changes: 8 additions & 2 deletions storage/innobase/fil/fil0pagecompress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,15 @@ fil_compress_page(

/* Actual write needs to be alligned on block size */
if (write_size % block_size) {
#ifdef UNIV_DEBUG
size_t tmp = write_size;
ut_a(block_size > 0);
write_size = (write_size + block_size-1) & ~(block_size-1);
ut_a((write_size % block_size) == 0);
#endif
write_size = (size_t)ut_uint64_align_up((ib_uint64_t)write_size, block_size);
#ifdef UNIV_DEBUG
ut_a(write_size > 0 && ((write_size % block_size) == 0));
ut_a(write_size >= tmp);
#endif
}

#ifdef UNIV_PAGECOMPRESS_DEBUG
Expand Down
17 changes: 11 additions & 6 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5018,12 +5018,12 @@ os_aio_func(
ret = os_file_write_func(name, file, buf, offset, n);
}

DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
os_has_said_disk_full = FALSE;);
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
ret = 0;);
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
errno = 28;);
if (type == OS_FILE_WRITE) {
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
os_has_said_disk_full = FALSE;
ret = 0;
errno = 28;);
}

return ret;
}
Expand Down Expand Up @@ -6356,6 +6356,11 @@ os_file_trim(
ut_ad((len % bsize) == 0);
ut_ad(bsize != 0);

#ifdef UNIV_TRIM_DEBUG
fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu off %lu\n",
*slot->write_size, trim_len, len, off);
#endif

// Nothing to do if trim length is zero or if actual write
// size is initialized and it is smaller than current write size.
// In first write if we trim we set write_size to actual bytes
Expand Down
10 changes: 8 additions & 2 deletions storage/xtradb/fil/fil0pagecompress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,15 @@ fil_compress_page(

/* Actual write needs to be alligned on block size */
if (write_size % block_size) {
#ifdef UNIV_DEBUG
size_t tmp = write_size;
ut_a(block_size > 0);
write_size = (write_size + block_size-1) & ~(block_size-1);
ut_a((write_size % block_size) == 0);
#endif
write_size = (size_t)ut_uint64_align_up((ib_uint64_t)write_size, block_size);
#ifdef UNIV_DEBUG
ut_a(write_size > 0 && ((write_size % block_size) == 0));
ut_a(write_size >= tmp);
#endif
}

#ifdef UNIV_PAGECOMPRESS_DEBUG
Expand Down
17 changes: 11 additions & 6 deletions storage/xtradb/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5115,12 +5115,12 @@ os_aio_func(
ret = os_file_write(name, file, buf, offset, n);
}

DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
os_has_said_disk_full = FALSE;);
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
ret = 0;);
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
errno = 28;);
if (type == OS_FILE_WRITE) {
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
os_has_said_disk_full = FALSE;
ret = 0;
errno = 28;);
}

if (!ret) {
fprintf(stderr, "FAIL");
Expand Down Expand Up @@ -6459,6 +6459,11 @@ os_file_trim(
ut_ad((len % bsize) == 0);
ut_ad(bsize != 0);

#ifdef UNIV_TRIM_DEBUG
fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu off %lu\n",
*slot->write_size, trim_len, len, off);
#endif

// Nothing to do if trim length is zero or if actual write
// size is initialized and it is smaller than current write size.
// In first write if we trim we set write_size to actual bytes
Expand Down

0 comments on commit 251fa7f

Please sign in to comment.