88
87
/* When mysqld is run, the default directory "." is the mysqld datadir,
89
88
but in the MySQL Embedded Server Library and ibbackup it is not the default
90
89
directory, and we must set the base file path explicitly */
91
UNIV_INTERN const char* fil_path_to_mysql_datadir = ".";
90
const char* fil_path_to_mysql_datadir = ".";
93
92
/* The number of fsyncs done to the log */
94
UNIV_INTERN ulint fil_n_log_flushes = 0;
93
ulint fil_n_log_flushes = 0;
96
UNIV_INTERN ulint fil_n_pending_log_flushes = 0;
97
UNIV_INTERN ulint fil_n_pending_tablespace_flushes = 0;
95
ulint fil_n_pending_log_flushes = 0;
96
ulint fil_n_pending_tablespace_flushes = 0;
99
98
/* Null file address */
100
UNIV_INTERN fil_addr_t fil_addr_null = {FIL_NULL, 0};
99
fil_addr_t fil_addr_null = {FIL_NULL, 0};
102
101
/* File node of a tablespace or the log data space */
103
102
struct fil_node_struct {
293
290
const char* name); /* in: table name in the standard
294
291
'databasename/tablename' format */
295
/************************************************************************
296
Reads data from a space to a buffer. Remember that the possible incomplete
297
blocks at the end of file are ignored: they are not taken into account when
298
calculating the byte offset within a space. */
303
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
304
if we are trying to do i/o on a tablespace
305
which does not exist */
306
ibool sync, /* in: TRUE if synchronous aio is desired */
307
ulint space_id, /* in: space id */
308
ulint zip_size, /* in: compressed page size in bytes;
309
0 for uncompressed pages */
310
ulint block_offset, /* in: offset in number of blocks */
311
ulint byte_offset, /* in: remainder of offset in bytes; in aio
312
this must be divisible by the OS block size */
313
ulint len, /* in: how many bytes to read; this must not
314
cross a file boundary; in aio this must be a
315
block size multiple */
316
void* buf, /* in/out: buffer where to store data read;
317
in aio this must be appropriately aligned */
318
void* message) /* in: message for aio handler if non-sync
319
aio used, else ignored */
321
return(fil_io(OS_FILE_READ, sync, space_id, zip_size, block_offset,
322
byte_offset, len, buf, message));
325
/************************************************************************
326
Writes data to a space from a buffer. Remember that the possible incomplete
327
blocks at the end of file are ignored: they are not taken into account when
328
calculating the byte offset within a space. */
333
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
334
if we are trying to do i/o on a tablespace
335
which does not exist */
336
ibool sync, /* in: TRUE if synchronous aio is desired */
337
ulint space_id, /* in: space id */
338
ulint zip_size, /* in: compressed page size in bytes;
339
0 for uncompressed pages */
340
ulint block_offset, /* in: offset in number of blocks */
341
ulint byte_offset, /* in: remainder of offset in bytes; in aio
342
this must be divisible by the OS block size */
343
ulint len, /* in: how many bytes to write; this must
344
not cross a file boundary; in aio this must
345
be a block size multiple */
346
void* buf, /* in: buffer from which to write; in aio
347
this must be appropriately aligned */
348
void* message) /* in: message for aio handler if non-sync
349
aio used, else ignored */
351
return(fil_io(OS_FILE_WRITE, sync, space_id, zip_size, block_offset,
352
byte_offset, len, buf, message));
355
/***********************************************************************
356
Returns the table space by a given id, NULL if not found. */
361
ulint id) /* in: space id */
365
ut_ad(mutex_own(&fil_system->mutex));
367
HASH_SEARCH(hash, fil_system->spaces, id,
368
fil_space_t*, space, space->id == id);
373
/***********************************************************************
374
Returns the table space by a given name, NULL if not found. */
377
fil_space_get_by_name(
378
/*==================*/
379
const char* name) /* in: space name */
384
ut_ad(mutex_own(&fil_system->mutex));
386
fold = ut_fold_string(name);
388
HASH_SEARCH(name_hash, fil_system->name_hash, fold,
389
fil_space_t*, space, !strcmp(name, space->name));
394
294
/***********************************************************************
395
295
Returns the version number of a tablespace, -1 if not found. */
398
298
fil_space_get_version(
399
299
/*==================*/
400
300
/* out: version number, -1 if the tablespace does not
692
585
os_file_close(node->handle);
694
if (UNIV_UNLIKELY(space_id != space->id)) {
587
if (space_id == ULINT_UNDEFINED || space_id == 0) {
589
"InnoDB: Error: tablespace id %lu"
590
" in file %s is not sensible\n",
591
(ulong) space_id, node->name);
596
if (space_id != space->id) {
696
598
"InnoDB: Error: tablespace id is %lu"
697
599
" in the data dictionary\n"
698
600
"InnoDB: but in file %s it is %lu!\n",
699
601
space->id, node->name, space_id);
704
if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED
707
"InnoDB: Error: tablespace id %lu"
708
" in file %s is not sensible\n",
709
(ulong) space_id, node->name);
714
if (UNIV_UNLIKELY(space->flags != flags)) {
716
"InnoDB: Error: table flags are %lx"
717
" in the data dictionary\n"
718
"InnoDB: but the flags in file %s are %lx!\n",
719
space->flags, node->name, flags);
724
if (size_bytes >= 1024 * 1024) {
725
/* Truncate the size to whole megabytes. */
726
size_bytes = ut_2pow_round(size_bytes, 1024 * 1024);
729
if (!(flags & DICT_TF_ZSSIZE_MASK)) {
606
if (size_bytes >= FSP_EXTENT_SIZE * UNIV_PAGE_SIZE) {
608
((size_bytes / (1024 * 1024))
609
* ((1024 * 1024) / UNIV_PAGE_SIZE));
730
611
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
734
/ dict_table_flags_to_zip_size(flags));
737
614
space->size += node->size;
1062
938
mutex_exit(&(system->mutex));
1064
#endif /* UNIV_LOG_ARCHIVE */
1066
941
/***********************************************************************
1067
942
Creates a space memory object and puts it to the tablespace memory cache. If
1068
943
there is an error, prints an error message to the .err log. */
1071
946
fil_space_create(
1072
947
/*=============*/
1073
948
/* out: TRUE if success */
1074
949
const char* name, /* in: space name */
1075
950
ulint id, /* in: space id */
1076
ulint flags, /* in: compressed page size
1077
and file format, or 0 */
1078
951
ulint purpose)/* in: FIL_TABLESPACE, or FIL_LOG if log */
1080
953
fil_system_t* system = fil_system;
1081
954
fil_space_t* space;
1083
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
1084
ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
1085
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
1086
format, the tablespace flags should equal table->flags. */
1087
ut_a(flags != DICT_TF_COMPACT);
1091
958
"InnoDB: Adding tablespace %lu of name %s, purpose %lu\n", id, name,
1411
1276
/***********************************************************************
1412
Returns the flags of the space. The tablespace must be cached
1413
in the memory cache. */
1416
fil_space_get_flags(
1417
/*================*/
1418
/* out: flags, ULINT_UNDEFINED if space not found */
1419
ulint id) /* in: space id */
1421
fil_system_t* system = fil_system;
1428
if (UNIV_UNLIKELY(!id)) {
1432
fil_mutex_enter_and_prepare_for_io(id);
1434
space = fil_space_get_by_id(id);
1436
if (space == NULL) {
1437
mutex_exit(&(system->mutex));
1439
return(ULINT_UNDEFINED);
1442
if (space->size == 0 && space->purpose == FIL_TABLESPACE) {
1445
ut_a(1 == UT_LIST_GET_LEN(space->chain));
1447
node = UT_LIST_GET_FIRST(space->chain);
1449
/* It must be a single-table tablespace and we have not opened
1450
the file yet; the following calls will open it and update the
1453
fil_node_prepare_for_io(node, system, space);
1454
fil_node_complete_io(node, system, OS_FILE_READ);
1457
flags = space->flags;
1459
mutex_exit(&(system->mutex));
1464
/***********************************************************************
1465
Returns the compressed page size of the space, or 0 if the space
1466
is not compressed. The tablespace must be cached in the memory cache. */
1469
fil_space_get_zip_size(
1470
/*===================*/
1471
/* out: compressed page size, ULINT_UNDEFINED
1472
if space not found */
1473
ulint id) /* in: space id */
1477
flags = fil_space_get_flags(id);
1479
if (flags && flags != ULINT_UNDEFINED) {
1481
return(dict_table_flags_to_zip_size(flags));
1487
/***********************************************************************
1488
1277
Checks if the pair space, page_no refers to an existing page in a tablespace
1489
1278
file space. The tablespace must be cached in the memory cache. */
1492
1281
fil_check_adress_in_tablespace(
1493
1282
/*===========================*/
1702
1491
/********************************************************************
1703
1492
Writes the flushed lsn and the latest archived log number to the page header
1704
of the first page of a data file of the system tablespace (space 0),
1705
which is uncompressed. */
1493
of the first page of a data file. */
1708
1496
fil_write_lsn_and_arch_no_to_file(
1709
1497
/*==============================*/
1710
ulint sum_of_sizes, /* in: combined size of previous files
1711
in space, in database pages */
1712
ib_uint64_t lsn, /* in: lsn to write */
1713
ulint arch_log_no /* in: archived log number to write */
1498
ulint space_id, /* in: space number */
1499
ulint sum_of_sizes, /* in: combined size of previous files in
1500
space, in database pages */
1501
dulint lsn, /* in: lsn to write */
1502
ulint arch_log_no /* in: archived log number to write */
1714
1503
__attribute__((unused)))
1719
1508
buf1 = mem_alloc(2 * UNIV_PAGE_SIZE);
1720
1509
buf = ut_align(buf1, UNIV_PAGE_SIZE);
1722
fil_read(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1724
mach_write_ull(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn);
1726
fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1511
fil_read(TRUE, space_id, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1513
mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn);
1515
fil_write(TRUE, space_id, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1728
1517
return(DB_SUCCESS);
1788
1577
/***********************************************************************
1789
1578
Reads the flushed lsn and arch no fields from a data file at database
1793
1582
fil_read_flushed_lsn_and_arch_log_no(
1794
1583
/*=================================*/
1795
os_file_t data_file, /* in: open data file */
1796
ibool one_read_already, /* in: TRUE if min and max
1797
parameters below already
1798
contain sensible data */
1584
os_file_t data_file, /* in: open data file */
1585
ibool one_read_already, /* in: TRUE if min and max parameters
1586
below already contain sensible data */
1799
1587
#ifdef UNIV_LOG_ARCHIVE
1800
ulint* min_arch_log_no, /* in/out: */
1801
ulint* max_arch_log_no, /* in/out: */
1588
ulint* min_arch_log_no, /* in/out: */
1589
ulint* max_arch_log_no, /* in/out: */
1802
1590
#endif /* UNIV_LOG_ARCHIVE */
1803
ib_uint64_t* min_flushed_lsn, /* in/out: */
1804
ib_uint64_t* max_flushed_lsn) /* in/out: */
1591
dulint* min_flushed_lsn, /* in/out: */
1592
dulint* max_flushed_lsn) /* in/out: */
1808
ib_uint64_t flushed_lsn;
1810
1598
buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
1811
1599
/* Align the memory for a possible read from a raw device */
2030
1810
not fir completely between ptr and end_ptr */
2031
1811
byte* end_ptr, /* in: buffer end */
2032
1812
ulint type, /* in: the type of this log record */
2033
ulint space_id) /* in: the space id of the tablespace in
2034
question, or 0 if the log record should
2035
only be parsed but not replayed */
1813
ibool do_replay, /* in: TRUE if we want to replay the
1814
operation, and not just parse the log record */
1815
ulint space_id) /* in: if do_replay is TRUE, the space id of
1816
the tablespace in question; otherwise
2037
1819
ulint name_len;
2038
1820
ulint new_name_len;
2039
1821
const char* name;
2040
1822
const char* new_name = NULL;
2043
if (type == MLOG_FILE_CREATE2) {
2044
if (end_ptr < ptr + 4) {
2049
flags = mach_read_from_4(ptr);
2053
1824
if (end_ptr < ptr + 2) {
2723
2481
memset(page, '\0', UNIV_PAGE_SIZE);
2725
fsp_header_init_fields(page, *space_id, flags);
2726
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, *space_id);
2728
if (!(flags & DICT_TF_ZSSIZE_MASK)) {
2729
buf_flush_init_for_writing(page, NULL, 0);
2730
ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
2732
page_zip_des_t page_zip;
2735
zip_size = ((PAGE_ZIP_MIN_SIZE >> 1)
2736
<< ((flags & DICT_TF_ZSSIZE_MASK)
2737
>> DICT_TF_ZSSIZE_SHIFT));
2739
page_zip_set_size(&page_zip, zip_size);
2740
page_zip.data = page + UNIV_PAGE_SIZE;
2743
#endif /* UNIV_DEBUG */
2744
page_zip.m_end = page_zip.m_nonempty =
2745
page_zip.n_blobs = 0;
2746
buf_flush_init_for_writing(page, &page_zip, 0);
2747
ret = os_file_write(path, file, page_zip.data, 0, 0, zip_size);
2483
fsp_header_write_space_id(page, *space_id);
2485
buf_flush_init_for_writing(page, ut_dulint_zero, *space_id, 0);
2487
ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
2876
2612
space_id = fsp_header_get_space_id(page);
2877
zip_size = fsp_header_get_zip_size(page);
2879
2614
ut_print_timestamp(stderr);
2880
2615
fprintf(stderr,
2881
2616
" InnoDB: Flush lsn in the tablespace file %lu"
2882
2617
" to be imported\n"
2883
"InnoDB: is %"PRIu64", which exceeds current"
2884
" system lsn %"PRIu64".\n"
2618
"InnoDB: is %lu %lu, which exceeds current"
2619
" system lsn %lu %lu.\n"
2885
2620
"InnoDB: We reset the lsn's in the file ",
2886
2621
(ulong) space_id,
2887
flush_lsn, current_lsn);
2622
(ulong) ut_dulint_get_high(flush_lsn),
2623
(ulong) ut_dulint_get_low(flush_lsn),
2624
(ulong) ut_dulint_get_high(current_lsn),
2625
(ulong) ut_dulint_get_low(current_lsn));
2888
2626
ut_print_filename(stderr, filepath);
2889
2627
fputs(".\n", stderr);
2891
ut_a(ut_is_2pow(zip_size));
2892
ut_a(zip_size <= UNIV_PAGE_SIZE);
2894
2629
/* Loop through all the pages in the tablespace and reset the lsn and
2895
2630
the page checksum if necessary */
2897
2632
file_size = os_file_get_size_as_iblonglong(file);
2899
for (offset = 0; offset < file_size;
2900
offset += zip_size ? zip_size : UNIV_PAGE_SIZE) {
2634
for (offset = 0; offset < file_size; offset += UNIV_PAGE_SIZE) {
2901
2635
success = os_file_read(file, page,
2902
2636
(ulint)(offset & 0xFFFFFFFFUL),
2903
(ulint)(offset >> 32),
2904
zip_size ? zip_size : UNIV_PAGE_SIZE);
2637
(ulint)(offset >> 32), UNIV_PAGE_SIZE);
2905
2638
if (!success) {
2907
2640
goto func_exit;
2909
if (mach_read_ull(page + FIL_PAGE_LSN) > current_lsn) {
2642
if (ut_dulint_cmp(mach_read_from_8(page + FIL_PAGE_LSN),
2910
2644
/* We have to reset the lsn */
2645
space_id = mach_read_from_4(
2646
page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
2647
page_no = mach_read_from_4(page + FIL_PAGE_OFFSET);
2913
memcpy(page + UNIV_PAGE_SIZE, page, zip_size);
2914
buf_flush_init_for_writing(
2915
page, page + UNIV_PAGE_SIZE,
2918
buf_flush_init_for_writing(
2919
page, NULL, current_lsn);
2649
buf_flush_init_for_writing(page, current_lsn, space_id,
2921
2651
success = os_file_write(filepath, file, page,
2922
2652
(ulint)(offset & 0xFFFFFFFFUL),
2923
2653
(ulint)(offset >> 32),
2927
2655
if (!success) {
2929
2657
goto func_exit;
2940
2668
/* We now update the flush_lsn stamp at the start of the file */
2941
success = os_file_read(file, page, 0, 0,
2942
zip_size ? zip_size : UNIV_PAGE_SIZE);
2669
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
2943
2670
if (!success) {
2945
2672
goto func_exit;
2948
mach_write_ull(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
2675
mach_write_to_8(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
2950
success = os_file_write(filepath, file, page, 0, 0,
2951
zip_size ? zip_size : UNIV_PAGE_SIZE);
2677
success = os_file_write(filepath, file, page, 0, 0, UNIV_PAGE_SIZE);
2952
2678
if (!success) {
2954
2680
goto func_exit;
3050
2768
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
3052
/* We have to read the tablespace id and flags from the file. */
2770
/* We have to read the tablespace id from the file */
3054
2772
space_id = fsp_header_get_space_id(page);
3055
space_flags = fsp_header_get_flags(page);
3059
if (UNIV_UNLIKELY(space_id != id || space_flags != flags)) {
2776
if (space_id != id) {
3060
2777
ut_print_timestamp(stderr);
3062
fputs(" InnoDB: Error: tablespace id and flags in file ",
2779
fputs(" InnoDB: Error: tablespace id in file ", stderr);
3064
2780
ut_print_filename(stderr, filepath);
3065
fprintf(stderr, " are %lu and %lu, but in the InnoDB\n"
3066
"InnoDB: data dictionary they are %lu and %lu.\n"
2781
fprintf(stderr, " is %lu, but in the InnoDB\n"
2782
"InnoDB: data dictionary it is %lu.\n"
3067
2783
"InnoDB: Have you moved InnoDB .ibd files"
3068
2784
" around without using the\n"
3069
2785
"InnoDB: commands DISCARD TABLESPACE and"
3701
3413
/* Look if there is a space with the same id */
3703
space = fil_space_get_by_id(id);
3415
HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
3705
3417
/* Look if there is a space with the same name; the name is the
3706
3418
directory path from the datadir to the file */
3708
namespace = fil_space_get_by_name(path);
3420
HASH_SEARCH(name_hash, system->name_hash,
3421
ut_fold_string(path), namespace,
3422
0 == strcmp(namespace->name, path));
3709
3423
if (space && space == namespace) {
3899
3609
file_start_page_no = space->size - node->size;
3901
3611
/* Extend at most 64 pages at a time */
3902
buf_size = ut_min(64, size_after_extend - start_page_no) * page_size;
3903
buf2 = mem_alloc(buf_size + page_size);
3904
buf = ut_align(buf2, page_size);
3612
buf_size = ut_min(64, size_after_extend - start_page_no)
3614
buf2 = mem_alloc(buf_size + UNIV_PAGE_SIZE);
3615
buf = ut_align(buf2, UNIV_PAGE_SIZE);
3906
3617
memset(buf, 0, buf_size);
3908
3619
while (start_page_no < size_after_extend) {
3909
ulint n_pages = ut_min(buf_size / page_size,
3620
ulint n_pages = ut_min(buf_size / UNIV_PAGE_SIZE,
3910
3621
size_after_extend - start_page_no);
3912
3623
offset_high = (start_page_no - file_start_page_no)
3913
/ (4096 * ((1024 * 1024) / page_size));
3624
/ (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE));
3914
3625
offset_low = ((start_page_no - file_start_page_no)
3915
% (4096 * ((1024 * 1024) / page_size)))
3626
% (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE)))
3917
3628
#ifdef UNIV_HOTBACKUP
3918
3629
success = os_file_write(node->name, node->handle, buf,
3919
3630
offset_low, offset_high,
3920
page_size * n_pages);
3631
UNIV_PAGE_SIZE * n_pages);
3922
3633
success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC,
3923
3634
node->name, node->handle, buf,
3924
3635
offset_low, offset_high,
3925
page_size * n_pages,
3636
UNIV_PAGE_SIZE * n_pages,
4299
4008
type = type & ~OS_AIO_SIMULATED_WAKE_LATER;
4301
4010
ut_ad(byte_offset < UNIV_PAGE_SIZE);
4302
ut_ad(!zip_size || !byte_offset);
4303
ut_ad(ut_is_2pow(zip_size));
4305
4012
ut_ad(len > 0);
4306
#if (1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE
4307
# error "(1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE"
4013
ut_a((1 << UNIV_PAGE_SIZE_SHIFT) == UNIV_PAGE_SIZE);
4309
4014
ut_ad(fil_validate());
4310
4015
#ifndef UNIV_LOG_DEBUG
4311
4016
/* ibuf bitmap pages must be read in the sync aio mode: */
4312
4017
ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
4313
|| !ibuf_bitmap_page(zip_size, block_offset)
4018
|| !ibuf_bitmap_page(block_offset) || sync || is_log);
4315
4019
#ifdef UNIV_SYNC_DEBUG
4316
4020
ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE)
4317
|| ibuf_page(space_id, zip_size, block_offset));
4021
|| ibuf_page(space_id, block_offset));
4321
4025
mode = OS_AIO_SYNC;
4322
4026
} else if (type == OS_FILE_READ && !is_log
4323
&& ibuf_page(space_id, zip_size, block_offset)) {
4027
&& ibuf_page(space_id, block_offset)) {
4324
4028
mode = OS_AIO_IBUF;
4325
4029
} else if (is_log) {
4326
4030
mode = OS_AIO_LOG;
4406
4110
/* Calculate the low 32 bits and the high 32 bits of the file offset */
4409
offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
4410
offset_low = ((block_offset << UNIV_PAGE_SIZE_SHIFT)
4411
& 0xFFFFFFFFUL) + byte_offset;
4112
offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
4113
offset_low = ((block_offset << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL)
4413
ut_a(node->size - block_offset
4414
>= ((byte_offset + len + (UNIV_PAGE_SIZE - 1))
4417
ulint zip_size_shift;
4419
case 1024: zip_size_shift = 10; break;
4420
case 2048: zip_size_shift = 11; break;
4421
case 4096: zip_size_shift = 12; break;
4422
case 8192: zip_size_shift = 13; break;
4423
case 16384: zip_size_shift = 14; break;
4426
offset_high = block_offset >> (32 - zip_size_shift);
4427
offset_low = (block_offset << zip_size_shift & 0xFFFFFFFFUL)
4429
ut_a(node->size - block_offset
4430
>= (len + (zip_size - 1)) / zip_size);
4116
ut_a(node->size - block_offset
4117
>= (byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE);
4467
4153
return(DB_SUCCESS);
4156
/************************************************************************
4157
Reads data from a space to a buffer. Remember that the possible incomplete
4158
blocks at the end of file are ignored: they are not taken into account when
4159
calculating the byte offset within a space. */
4164
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
4165
if we are trying to do i/o on a tablespace
4166
which does not exist */
4167
ibool sync, /* in: TRUE if synchronous aio is desired */
4168
ulint space_id, /* in: space id */
4169
ulint block_offset, /* in: offset in number of blocks */
4170
ulint byte_offset, /* in: remainder of offset in bytes; in aio
4171
this must be divisible by the OS block size */
4172
ulint len, /* in: how many bytes to read; this must not
4173
cross a file boundary; in aio this must be a
4174
block size multiple */
4175
void* buf, /* in/out: buffer where to store data read;
4176
in aio this must be appropriately aligned */
4177
void* message) /* in: message for aio handler if non-sync
4178
aio used, else ignored */
4180
return(fil_io(OS_FILE_READ, sync, space_id, block_offset,
4181
byte_offset, len, buf, message));
4184
/************************************************************************
4185
Writes data to a space from a buffer. Remember that the possible incomplete
4186
blocks at the end of file are ignored: they are not taken into account when
4187
calculating the byte offset within a space. */
4192
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
4193
if we are trying to do i/o on a tablespace
4194
which does not exist */
4195
ibool sync, /* in: TRUE if synchronous aio is desired */
4196
ulint space_id, /* in: space id */
4197
ulint block_offset, /* in: offset in number of blocks */
4198
ulint byte_offset, /* in: remainder of offset in bytes; in aio
4199
this must be divisible by the OS block size */
4200
ulint len, /* in: how many bytes to write; this must
4201
not cross a file boundary; in aio this must
4202
be a block size multiple */
4203
void* buf, /* in: buffer from which to write; in aio
4204
this must be appropriately aligned */
4205
void* message) /* in: message for aio handler if non-sync
4206
aio used, else ignored */
4208
return(fil_io(OS_FILE_WRITE, sync, space_id, block_offset,
4209
byte_offset, len, buf, message));
4470
4212
/**************************************************************************
4471
4213
Waits for an aio operation to complete. This function is used to write the
4472
4214
handler for completed requests. The aio array of pending requests is divided
4473
4215
into segments (see os0file.c for more info). The thread specifies which
4474
4216
segment it wants to wait for. */
4766
4508
/************************************************************************
4767
4509
Returns TRUE if file address is undefined. */
4770
4511
fil_addr_is_null(
4771
4512
/*=============*/
4772
4513
/* out: TRUE if undefined */
4773
4514
fil_addr_t addr) /* in: address */
4775
return(addr.page == FIL_NULL);
4516
if (addr.page == FIL_NULL) {
4778
4524
/************************************************************************
4779
4525
Accessor functions for a file page */
4782
fil_page_get_prev(const byte* page)
4528
fil_page_get_prev(byte* page)
4784
4530
return(mach_read_from_4(page + FIL_PAGE_PREV));
4789
fil_page_get_next(const byte* page)
4534
fil_page_get_next(byte* page)
4791
4536
return(mach_read_from_4(page + FIL_PAGE_NEXT));
4794
4539
/*************************************************************************
4795
4540
Sets the file page type. */
4798
4543
fil_page_set_type(
4799
4544
/*==============*/