87
88
/* When mysqld is run, the default directory "." is the mysqld datadir,
88
89
but in the MySQL Embedded Server Library and ibbackup it is not the default
89
90
directory, and we must set the base file path explicitly */
90
const char* fil_path_to_mysql_datadir = ".";
91
UNIV_INTERN const char* fil_path_to_mysql_datadir = ".";
92
93
/* The number of fsyncs done to the log */
93
ulint fil_n_log_flushes = 0;
94
UNIV_INTERN ulint fil_n_log_flushes = 0;
95
ulint fil_n_pending_log_flushes = 0;
96
ulint fil_n_pending_tablespace_flushes = 0;
96
UNIV_INTERN ulint fil_n_pending_log_flushes = 0;
97
UNIV_INTERN ulint fil_n_pending_tablespace_flushes = 0;
98
99
/* Null file address */
99
fil_addr_t fil_addr_null = {FIL_NULL, 0};
100
UNIV_INTERN fil_addr_t fil_addr_null = {FIL_NULL, 0};
101
102
/* File node of a tablespace or the log data space */
102
103
struct fil_node_struct {
290
293
const char* name); /* in: table name in the standard
291
294
'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));
294
394
/***********************************************************************
295
395
Returns the version number of a tablespace, -1 if not found. */
298
398
fil_space_get_version(
299
399
/*==================*/
300
400
/* out: version number, -1 if the tablespace does not
585
692
os_file_close(node->handle);
587
if (space_id == ULINT_UNDEFINED || space_id == 0) {
694
if (UNIV_UNLIKELY(space_id != space->id)) {
696
"InnoDB: Error: tablespace id is %lu"
697
" in the data dictionary\n"
698
"InnoDB: but in file %s it is %lu!\n",
699
space->id, node->name, space_id);
704
if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED
589
707
"InnoDB: Error: tablespace id %lu"
590
708
" in file %s is not sensible\n",
591
709
(ulong) space_id, node->name);
596
if (space_id != space->id) {
714
if (UNIV_UNLIKELY(space->flags != flags)) {
598
"InnoDB: Error: tablespace id is %lu"
716
"InnoDB: Error: table flags are %lx"
599
717
" in the data dictionary\n"
600
"InnoDB: but in file %s it is %lu!\n",
601
space->id, node->name, space_id);
606
if (size_bytes >= FSP_EXTENT_SIZE * UNIV_PAGE_SIZE) {
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)) {
730
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
607
732
node->size = (ulint)
608
((size_bytes / (1024 * 1024))
609
* ((1024 * 1024) / UNIV_PAGE_SIZE));
611
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
734
/ dict_table_flags_to_zip_size(flags));
614
737
space->size += node->size;
938
1062
mutex_exit(&(system->mutex));
1064
#endif /* UNIV_LOG_ARCHIVE */
941
1066
/***********************************************************************
942
1067
Creates a space memory object and puts it to the tablespace memory cache. If
943
1068
there is an error, prints an error message to the .err log. */
946
1071
fil_space_create(
947
1072
/*=============*/
948
1073
/* out: TRUE if success */
949
1074
const char* name, /* in: space name */
950
1075
ulint id, /* in: space id */
1076
ulint flags, /* in: compressed page size
1077
and file format, or 0 */
951
1078
ulint purpose)/* in: FIL_TABLESPACE, or FIL_LOG if log */
953
1080
fil_system_t* system = fil_system;
954
1081
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);
958
1091
"InnoDB: Adding tablespace %lu of name %s, purpose %lu\n", id, name,
1276
1411
/***********************************************************************
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
/***********************************************************************
1277
1488
Checks if the pair space, page_no refers to an existing page in a tablespace
1278
1489
file space. The tablespace must be cached in the memory cache. */
1281
1492
fil_check_adress_in_tablespace(
1282
1493
/*===========================*/
1491
1702
/********************************************************************
1492
1703
Writes the flushed lsn and the latest archived log number to the page header
1493
of the first page of a data file. */
1704
of the first page of a data file of the system tablespace (space 0),
1705
which is uncompressed. */
1496
1708
fil_write_lsn_and_arch_no_to_file(
1497
1709
/*==============================*/
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 */
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 */
1503
1714
__attribute__((unused)))
1508
1719
buf1 = mem_alloc(2 * UNIV_PAGE_SIZE);
1509
1720
buf = ut_align(buf1, UNIV_PAGE_SIZE);
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);
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);
1517
1728
return(DB_SUCCESS);
1577
1788
/***********************************************************************
1578
1789
Reads the flushed lsn and arch no fields from a data file at database
1582
1793
fil_read_flushed_lsn_and_arch_log_no(
1583
1794
/*=================================*/
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 */
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 */
1587
1799
#ifdef UNIV_LOG_ARCHIVE
1588
ulint* min_arch_log_no, /* in/out: */
1589
ulint* max_arch_log_no, /* in/out: */
1800
ulint* min_arch_log_no, /* in/out: */
1801
ulint* max_arch_log_no, /* in/out: */
1590
1802
#endif /* UNIV_LOG_ARCHIVE */
1591
dulint* min_flushed_lsn, /* in/out: */
1592
dulint* max_flushed_lsn) /* in/out: */
1803
ib_uint64_t* min_flushed_lsn, /* in/out: */
1804
ib_uint64_t* max_flushed_lsn) /* in/out: */
1808
ib_uint64_t flushed_lsn;
1598
1810
buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
1599
1811
/* Align the memory for a possible read from a raw device */
1810
2030
not fir completely between ptr and end_ptr */
1811
2031
byte* end_ptr, /* in: buffer end */
1812
2032
ulint type, /* in: the type of this log record */
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
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 */
1819
2037
ulint name_len;
1820
2038
ulint new_name_len;
1821
2039
const char* name;
1822
2040
const char* new_name = NULL;
2043
if (type == MLOG_FILE_CREATE2) {
2044
if (end_ptr < ptr + 4) {
2049
flags = mach_read_from_4(ptr);
1824
2053
if (end_ptr < ptr + 2) {
2481
2723
memset(page, '\0', UNIV_PAGE_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);
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);
2612
2876
space_id = fsp_header_get_space_id(page);
2877
zip_size = fsp_header_get_zip_size(page);
2614
2879
ut_print_timestamp(stderr);
2615
2880
fprintf(stderr,
2616
2881
" InnoDB: Flush lsn in the tablespace file %lu"
2617
2882
" to be imported\n"
2618
"InnoDB: is %lu %lu, which exceeds current"
2619
" system lsn %lu %lu.\n"
2883
"InnoDB: is %"PRIu64", which exceeds current"
2884
" system lsn %"PRIu64".\n"
2620
2885
"InnoDB: We reset the lsn's in the file ",
2621
2886
(ulong) space_id,
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));
2887
flush_lsn, current_lsn);
2626
2888
ut_print_filename(stderr, filepath);
2627
2889
fputs(".\n", stderr);
2891
ut_a(ut_is_2pow(zip_size));
2892
ut_a(zip_size <= UNIV_PAGE_SIZE);
2629
2894
/* Loop through all the pages in the tablespace and reset the lsn and
2630
2895
the page checksum if necessary */
2632
2897
file_size = os_file_get_size_as_iblonglong(file);
2634
for (offset = 0; offset < file_size; offset += UNIV_PAGE_SIZE) {
2899
for (offset = 0; offset < file_size;
2900
offset += zip_size ? zip_size : UNIV_PAGE_SIZE) {
2635
2901
success = os_file_read(file, page,
2636
2902
(ulint)(offset & 0xFFFFFFFFUL),
2637
(ulint)(offset >> 32), UNIV_PAGE_SIZE);
2903
(ulint)(offset >> 32),
2904
zip_size ? zip_size : UNIV_PAGE_SIZE);
2638
2905
if (!success) {
2640
2907
goto func_exit;
2642
if (ut_dulint_cmp(mach_read_from_8(page + FIL_PAGE_LSN),
2909
if (mach_read_ull(page + FIL_PAGE_LSN) > current_lsn) {
2644
2910
/* 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);
2649
buf_flush_init_for_writing(page, current_lsn, space_id,
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);
2651
2921
success = os_file_write(filepath, file, page,
2652
2922
(ulint)(offset & 0xFFFFFFFFUL),
2653
2923
(ulint)(offset >> 32),
2655
2927
if (!success) {
2657
2929
goto func_exit;
2668
2940
/* We now update the flush_lsn stamp at the start of the file */
2669
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
2941
success = os_file_read(file, page, 0, 0,
2942
zip_size ? zip_size : UNIV_PAGE_SIZE);
2670
2943
if (!success) {
2672
2945
goto func_exit;
2675
mach_write_to_8(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
2948
mach_write_ull(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
2677
success = os_file_write(filepath, file, page, 0, 0, UNIV_PAGE_SIZE);
2950
success = os_file_write(filepath, file, page, 0, 0,
2951
zip_size ? zip_size : UNIV_PAGE_SIZE);
2678
2952
if (!success) {
2680
2954
goto func_exit;
2768
3050
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
2770
/* We have to read the tablespace id from the file */
3052
/* We have to read the tablespace id and flags from the file. */
2772
3054
space_id = fsp_header_get_space_id(page);
3055
space_flags = fsp_header_get_flags(page);
2776
if (space_id != id) {
3059
if (UNIV_UNLIKELY(space_id != id || space_flags != flags)) {
2777
3060
ut_print_timestamp(stderr);
2779
fputs(" InnoDB: Error: tablespace id in file ", stderr);
3062
fputs(" InnoDB: Error: tablespace id and flags in file ",
2780
3064
ut_print_filename(stderr, filepath);
2781
fprintf(stderr, " is %lu, but in the InnoDB\n"
2782
"InnoDB: data dictionary it is %lu.\n"
3065
fprintf(stderr, " are %lu and %lu, but in the InnoDB\n"
3066
"InnoDB: data dictionary they are %lu and %lu.\n"
2783
3067
"InnoDB: Have you moved InnoDB .ibd files"
2784
3068
" around without using the\n"
2785
3069
"InnoDB: commands DISCARD TABLESPACE and"
3413
3701
/* Look if there is a space with the same id */
3415
HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
3703
space = fil_space_get_by_id(id);
3417
3705
/* Look if there is a space with the same name; the name is the
3418
3706
directory path from the datadir to the file */
3420
HASH_SEARCH(name_hash, system->name_hash,
3421
ut_fold_string(path), namespace,
3422
0 == strcmp(namespace->name, path));
3708
namespace = fil_space_get_by_name(path);
3423
3709
if (space && space == namespace) {
3609
3899
file_start_page_no = space->size - node->size;
3611
3901
/* Extend at most 64 pages at a time */
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);
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);
3617
3906
memset(buf, 0, buf_size);
3619
3908
while (start_page_no < size_after_extend) {
3620
ulint n_pages = ut_min(buf_size / UNIV_PAGE_SIZE,
3909
ulint n_pages = ut_min(buf_size / page_size,
3621
3910
size_after_extend - start_page_no);
3623
3912
offset_high = (start_page_no - file_start_page_no)
3624
/ (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE));
3913
/ (4096 * ((1024 * 1024) / page_size));
3625
3914
offset_low = ((start_page_no - file_start_page_no)
3626
% (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE)))
3915
% (4096 * ((1024 * 1024) / page_size)))
3628
3917
#ifdef UNIV_HOTBACKUP
3629
3918
success = os_file_write(node->name, node->handle, buf,
3630
3919
offset_low, offset_high,
3631
UNIV_PAGE_SIZE * n_pages);
3920
page_size * n_pages);
3633
3922
success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC,
3634
3923
node->name, node->handle, buf,
3635
3924
offset_low, offset_high,
3636
UNIV_PAGE_SIZE * n_pages,
3925
page_size * n_pages,
4008
4299
type = type & ~OS_AIO_SIMULATED_WAKE_LATER;
4010
4301
ut_ad(byte_offset < UNIV_PAGE_SIZE);
4302
ut_ad(!zip_size || !byte_offset);
4303
ut_ad(ut_is_2pow(zip_size));
4012
4305
ut_ad(len > 0);
4013
ut_a((1 << UNIV_PAGE_SIZE_SHIFT) == UNIV_PAGE_SIZE);
4306
#if (1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE
4307
# error "(1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE"
4014
4309
ut_ad(fil_validate());
4015
4310
#ifndef UNIV_LOG_DEBUG
4016
4311
/* ibuf bitmap pages must be read in the sync aio mode: */
4017
4312
ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
4018
|| !ibuf_bitmap_page(block_offset) || sync || is_log);
4313
|| !ibuf_bitmap_page(zip_size, block_offset)
4019
4315
#ifdef UNIV_SYNC_DEBUG
4020
4316
ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE)
4021
|| ibuf_page(space_id, block_offset));
4317
|| ibuf_page(space_id, zip_size, block_offset));
4025
4321
mode = OS_AIO_SYNC;
4026
4322
} else if (type == OS_FILE_READ && !is_log
4027
&& ibuf_page(space_id, block_offset)) {
4323
&& ibuf_page(space_id, zip_size, block_offset)) {
4028
4324
mode = OS_AIO_IBUF;
4029
4325
} else if (is_log) {
4030
4326
mode = OS_AIO_LOG;
4110
4406
/* Calculate the low 32 bits and the high 32 bits of the file offset */
4112
offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
4113
offset_low = ((block_offset << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL)
4409
offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
4410
offset_low = ((block_offset << UNIV_PAGE_SIZE_SHIFT)
4411
& 0xFFFFFFFFUL) + byte_offset;
4116
ut_a(node->size - block_offset
4117
>= (byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE);
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);
4153
4467
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));
4212
4470
/**************************************************************************
4213
4471
Waits for an aio operation to complete. This function is used to write the
4214
4472
handler for completed requests. The aio array of pending requests is divided
4215
4473
into segments (see os0file.c for more info). The thread specifies which
4216
4474
segment it wants to wait for. */
4508
4766
/************************************************************************
4509
4767
Returns TRUE if file address is undefined. */
4511
4770
fil_addr_is_null(
4512
4771
/*=============*/
4513
4772
/* out: TRUE if undefined */
4514
4773
fil_addr_t addr) /* in: address */
4516
if (addr.page == FIL_NULL) {
4775
return(addr.page == FIL_NULL);
4524
4778
/************************************************************************
4525
4779
Accessor functions for a file page */
4528
fil_page_get_prev(byte* page)
4782
fil_page_get_prev(const byte* page)
4530
4784
return(mach_read_from_4(page + FIL_PAGE_PREV));
4534
fil_page_get_next(byte* page)
4789
fil_page_get_next(const byte* page)
4536
4791
return(mach_read_from_4(page + FIL_PAGE_NEXT));
4539
4794
/*************************************************************************
4540
4795
Sets the file page type. */
4543
4798
fil_page_set_type(
4544
4799
/*==============*/