Skip to content

Commit 251fa7f

Browse files
author
Jan Lindström
committed
Fix error on trim operation alligment. Furthermore, make sure that
we do not return simulated out of file space on read operation, that would cause crash.
1 parent 43f185e commit 251fa7f

File tree

4 files changed

+38
-16
lines changed

4 files changed

+38
-16
lines changed

storage/innobase/fil/fil0pagecompress.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,15 @@ fil_compress_page(
456456

457457
/* Actual write needs to be alligned on block size */
458458
if (write_size % block_size) {
459+
#ifdef UNIV_DEBUG
460+
size_t tmp = write_size;
459461
ut_a(block_size > 0);
460-
write_size = (write_size + block_size-1) & ~(block_size-1);
461-
ut_a((write_size % block_size) == 0);
462+
#endif
463+
write_size = (size_t)ut_uint64_align_up((ib_uint64_t)write_size, block_size);
464+
#ifdef UNIV_DEBUG
465+
ut_a(write_size > 0 && ((write_size % block_size) == 0));
466+
ut_a(write_size >= tmp);
467+
#endif
462468
}
463469

464470
#ifdef UNIV_PAGECOMPRESS_DEBUG

storage/innobase/os/os0file.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5018,12 +5018,12 @@ os_aio_func(
50185018
ret = os_file_write_func(name, file, buf, offset, n);
50195019
}
50205020

5021-
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
5022-
os_has_said_disk_full = FALSE;);
5023-
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
5024-
ret = 0;);
5025-
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
5026-
errno = 28;);
5021+
if (type == OS_FILE_WRITE) {
5022+
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
5023+
os_has_said_disk_full = FALSE;
5024+
ret = 0;
5025+
errno = 28;);
5026+
}
50275027

50285028
return ret;
50295029
}
@@ -6356,6 +6356,11 @@ os_file_trim(
63566356
ut_ad((len % bsize) == 0);
63576357
ut_ad(bsize != 0);
63586358

6359+
#ifdef UNIV_TRIM_DEBUG
6360+
fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu off %lu\n",
6361+
*slot->write_size, trim_len, len, off);
6362+
#endif
6363+
63596364
// Nothing to do if trim length is zero or if actual write
63606365
// size is initialized and it is smaller than current write size.
63616366
// In first write if we trim we set write_size to actual bytes

storage/xtradb/fil/fil0pagecompress.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,15 @@ fil_compress_page(
453453

454454
/* Actual write needs to be alligned on block size */
455455
if (write_size % block_size) {
456+
#ifdef UNIV_DEBUG
457+
size_t tmp = write_size;
456458
ut_a(block_size > 0);
457-
write_size = (write_size + block_size-1) & ~(block_size-1);
458-
ut_a((write_size % block_size) == 0);
459+
#endif
460+
write_size = (size_t)ut_uint64_align_up((ib_uint64_t)write_size, block_size);
461+
#ifdef UNIV_DEBUG
462+
ut_a(write_size > 0 && ((write_size % block_size) == 0));
463+
ut_a(write_size >= tmp);
464+
#endif
459465
}
460466

461467
#ifdef UNIV_PAGECOMPRESS_DEBUG

storage/xtradb/os/os0file.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5115,12 +5115,12 @@ os_aio_func(
51155115
ret = os_file_write(name, file, buf, offset, n);
51165116
}
51175117

5118-
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
5119-
os_has_said_disk_full = FALSE;);
5120-
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
5121-
ret = 0;);
5122-
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
5123-
errno = 28;);
5118+
if (type == OS_FILE_WRITE) {
5119+
DBUG_EXECUTE_IF("ib_os_aio_func_io_failure_28",
5120+
os_has_said_disk_full = FALSE;
5121+
ret = 0;
5122+
errno = 28;);
5123+
}
51245124

51255125
if (!ret) {
51265126
fprintf(stderr, "FAIL");
@@ -6459,6 +6459,11 @@ os_file_trim(
64596459
ut_ad((len % bsize) == 0);
64606460
ut_ad(bsize != 0);
64616461

6462+
#ifdef UNIV_TRIM_DEBUG
6463+
fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu off %lu\n",
6464+
*slot->write_size, trim_len, len, off);
6465+
#endif
6466+
64626467
// Nothing to do if trim length is zero or if actual write
64636468
// size is initialized and it is smaller than current write size.
64646469
// In first write if we trim we set write_size to actual bytes

0 commit comments

Comments
 (0)