~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/os/os0file.c

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
my_umask */
34
34
 
35
35
#ifndef __WIN__
36
 
UNIV_INTERN ulint       os_innodb_umask
37
 
                        = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
 
36
ulint   os_innodb_umask         = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
38
37
#else
39
 
UNIV_INTERN ulint       os_innodb_umask         = 0;
 
38
ulint   os_innodb_umask         = 0;
40
39
#endif
41
40
 
42
41
#ifdef UNIV_DO_FLUSH
43
42
/* If the following is set to TRUE, we do not call os_file_flush in every
44
43
os_file_write. We can set this TRUE when the doublewrite buffer is used. */
45
 
UNIV_INTERN ibool       os_do_not_call_flush_at_each_write      = FALSE;
 
44
ibool   os_do_not_call_flush_at_each_write      = FALSE;
46
45
#else
47
46
/* We do not call os_file_flush in every os_file_write. */
48
47
#endif /* UNIV_DO_FLUSH */
50
49
/* We use these mutexes to protect lseek + file i/o operation, if the
51
50
OS does not provide an atomic pread or pwrite, or similar */
52
51
#define OS_FILE_N_SEEK_MUTEXES  16
53
 
UNIV_INTERN os_mutex_t  os_file_seek_mutexes[OS_FILE_N_SEEK_MUTEXES];
 
52
os_mutex_t      os_file_seek_mutexes[OS_FILE_N_SEEK_MUTEXES];
54
53
 
55
54
/* In simulated aio, merge at most this many consecutive i/os */
56
55
#define OS_AIO_MERGE_N_CONSECUTIVE      64
59
58
OS (provided we compiled Innobase with it in), otherwise we will
60
59
use simulated aio we build below with threads */
61
60
 
62
 
UNIV_INTERN ibool       os_aio_use_native_aio   = FALSE;
 
61
ibool   os_aio_use_native_aio   = FALSE;
63
62
 
64
 
UNIV_INTERN ibool       os_aio_print_debug      = FALSE;
 
63
ibool   os_aio_print_debug      = FALSE;
65
64
 
66
65
/* The aio array slot structure */
67
66
typedef struct os_aio_slot_struct       os_aio_slot_t;
132
131
};
133
132
 
134
133
/* Array of events used in simulated aio */
135
 
static os_event_t*      os_aio_segment_wait_events      = NULL;
 
134
os_event_t*     os_aio_segment_wait_events      = NULL;
136
135
 
137
136
/* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
138
137
are NULL when the module has not yet been initialized. */
148
147
wait until a batch of new read requests have been posted */
149
148
static ibool    os_aio_recommend_sleep_for_read_threads = FALSE;
150
149
 
151
 
UNIV_INTERN ulint       os_n_file_reads         = 0;
152
 
UNIV_INTERN ulint       os_bytes_read_since_printout = 0;
153
 
UNIV_INTERN ulint       os_n_file_writes        = 0;
154
 
UNIV_INTERN ulint       os_n_fsyncs             = 0;
155
 
UNIV_INTERN ulint       os_n_file_reads_old     = 0;
156
 
UNIV_INTERN ulint       os_n_file_writes_old    = 0;
157
 
UNIV_INTERN ulint       os_n_fsyncs_old         = 0;
158
 
UNIV_INTERN time_t      os_last_printout;
 
150
ulint   os_n_file_reads         = 0;
 
151
ulint   os_bytes_read_since_printout = 0;
 
152
ulint   os_n_file_writes        = 0;
 
153
ulint   os_n_fsyncs             = 0;
 
154
ulint   os_n_file_reads_old     = 0;
 
155
ulint   os_n_file_writes_old    = 0;
 
156
ulint   os_n_fsyncs_old         = 0;
 
157
time_t  os_last_printout;
159
158
 
160
 
UNIV_INTERN ibool       os_has_said_disk_full   = FALSE;
 
159
ibool   os_has_said_disk_full   = FALSE;
161
160
 
162
161
/* The mutex protecting the following counts of pending I/O operations */
163
 
static os_mutex_t       os_file_count_mutex;
164
 
UNIV_INTERN ulint       os_file_n_pending_preads  = 0;
165
 
UNIV_INTERN ulint       os_file_n_pending_pwrites = 0;
166
 
UNIV_INTERN ulint       os_n_pending_writes = 0;
167
 
UNIV_INTERN ulint       os_n_pending_reads = 0;
 
162
static os_mutex_t os_file_count_mutex;
 
163
ulint   os_file_n_pending_preads  = 0;
 
164
ulint   os_file_n_pending_pwrites = 0;
 
165
ulint   os_n_pending_writes = 0;
 
166
ulint   os_n_pending_reads = 0;
168
167
 
169
168
/***************************************************************************
170
169
Gets the operating system version. Currently works only on Windows. */
171
 
UNIV_INTERN
 
170
 
172
171
ulint
173
172
os_get_os_version(void)
174
173
/*===================*/
207
206
The number should be retrieved before any other OS calls (because they may
208
207
overwrite the error number). If the number is not known to this program,
209
208
the OS error number + 100 is returned. */
210
 
UNIV_INTERN
 
209
 
211
210
ulint
212
211
os_file_get_last_error(
213
212
/*===================*/
351
350
Does error handling when a file operation fails.
352
351
Conditionally exits (calling exit(3)) based on should_exit value and the
353
352
error type */
 
353
 
354
354
static
355
355
ibool
356
356
os_file_handle_error_cond_exit(
454
454
 
455
455
#undef USE_FILE_LOCK
456
456
#define USE_FILE_LOCK
457
 
#if defined(UNIV_HOTBACKUP) || defined(__WIN__) || defined(__NETWARE__)
 
457
#if defined(UNIV_HOTBACKUP) || defined(__WIN__) 
458
458
/* InnoDB Hot Backup does not lock the data files.
459
459
 * On Windows, mandatory locking is used.
460
460
 */
496
496
 
497
497
/********************************************************************
498
498
Creates the seek mutexes used in positioned reads and writes. */
499
 
UNIV_INTERN
 
499
 
500
500
void
501
501
os_io_init_simple(void)
502
502
/*===================*/
510
510
        }
511
511
}
512
512
 
 
513
#if !defined(UNIV_HOTBACKUP) 
 
514
/*************************************************************************
 
515
Creates a temporary file that will be deleted on close.
 
516
This function is defined in ha_innodb.cc. */
 
517
 
 
518
int
 
519
innobase_mysql_tmpfile(void);
 
520
/*========================*/
 
521
                        /* out: temporary file descriptor, or < 0 on error */
 
522
#endif /* !UNIV_HOTBACKUP */
 
523
 
513
524
/***************************************************************************
514
525
Creates a temporary file.  This function is like tmpfile(3), but
515
526
the temporary file is created in the MySQL temporary directory.
516
527
On Netware, this function is like tmpfile(3), because the C run-time
517
528
library of Netware does not expose the delete-on-close flag. */
518
 
UNIV_INTERN
 
529
 
519
530
FILE*
520
531
os_file_create_tmpfile(void)
521
532
/*========================*/
526
537
 
527
538
        return(NULL);
528
539
#else
529
 
# ifdef __NETWARE__
530
 
        FILE*   file    = tmpfile();
531
 
# else /* __NETWARE__ */
532
540
        FILE*   file    = NULL;
533
541
        int     fd      = innobase_mysql_tmpfile();
534
542
 
535
543
        if (fd >= 0) {
536
544
                file = fdopen(fd, "w+b");
537
545
        }
538
 
# endif /* __NETWARE__ */
539
546
 
540
547
        if (!file) {
541
548
                ut_print_timestamp(stderr);
542
549
                fprintf(stderr,
543
550
                        "  InnoDB: Error: unable to create temporary file;"
544
551
                        " errno: %d\n", errno);
545
 
# ifndef __NETWARE__
546
552
                if (fd >= 0) {
547
553
                        close(fd);
548
554
                }
549
 
# endif /* !__NETWARE__ */
550
555
        }
551
556
 
552
557
        return(file);
558
563
directory named by the dirname argument. The directory stream is positioned
559
564
at the first entry. In both Unix and Windows we automatically skip the '.'
560
565
and '..' items at the start of the directory listing. */
561
 
UNIV_INTERN
 
566
 
562
567
os_file_dir_t
563
568
os_file_opendir(
564
569
/*============*/
615
620
 
616
621
/***************************************************************************
617
622
Closes a directory stream. */
618
 
UNIV_INTERN
 
623
 
619
624
int
620
625
os_file_closedir(
621
626
/*=============*/
650
655
/***************************************************************************
651
656
This function returns information of the next file in the directory. We jump
652
657
over the '.' and '..' entries in the directory. */
653
 
UNIV_INTERN
 
658
 
654
659
int
655
660
os_file_readdir_next_file(
656
661
/*======================*/
680
685
 
681
686
                strcpy(info->name, (char *) lpFindFileData->cFileName);
682
687
 
683
 
                info->size = (ib_int64_t)(lpFindFileData->nFileSizeLow)
684
 
                        + (((ib_int64_t)(lpFindFileData->nFileSizeHigh))
 
688
                info->size = (ib_longlong)(lpFindFileData->nFileSizeLow)
 
689
                        + (((ib_longlong)(lpFindFileData->nFileSizeHigh))
685
690
                           << 32);
686
691
 
687
692
                if (lpFindFileData->dwFileAttributes
781
786
                return(-1);
782
787
        }
783
788
 
784
 
        info->size = (ib_int64_t)statinfo.st_size;
 
789
        info->size = (ib_longlong)statinfo.st_size;
785
790
 
786
791
        if (S_ISDIR(statinfo.st_mode)) {
787
792
                info->type = OS_FILE_TYPE_DIR;
804
809
gets default permissions. On Unix the permissions are (0770 & ~umask). If the
805
810
directory exists already, nothing is done and the call succeeds, unless the
806
811
fail_if_exists arguments is true. */
807
 
UNIV_INTERN
 
812
 
808
813
ibool
809
814
os_file_create_directory(
810
815
/*=====================*/
847
852
 
848
853
/********************************************************************
849
854
A simple function to open or create a file. */
850
 
UNIV_INTERN
 
855
 
851
856
os_file_t
852
857
os_file_create_simple(
853
858
/*==================*/
989
994
 
990
995
/********************************************************************
991
996
A simple function to open or create a file. */
992
 
UNIV_INTERN
 
997
 
993
998
os_file_t
994
999
os_file_create_simple_no_error_handling(
995
1000
/*====================================*/
1102
1107
 
1103
1108
/********************************************************************
1104
1109
Tries to disable OS caching on an opened file descriptor. */
1105
 
UNIV_INTERN
1106
 
void
 
1110
 
 
1111
static void
1107
1112
os_file_set_nocache(
1108
1113
/*================*/
1109
 
        int             fd,             /* in: file descriptor to alter */
1110
 
        const char*     file_name,      /* in: file name, used in the
1111
 
                                        diagnostic message */
1112
 
        const char*     operation_name) /* in: "open" or "create"; used in the
1113
 
                                        diagnostic message */
 
1114
        int             fd,/* in: file descriptor to alter */
 
1115
        const char*     file_name,/* in: used in the diagnostic
 
1116
                                        message */
 
1117
        const char*     operation_name)/* in: used in the
 
1118
                                        diagnostic message,
 
1119
                                        we call os_file_set_nocache()
 
1120
                                        immediately after opening or creating
 
1121
                                        a file, so this is either "open" or
 
1122
                                        "create" */
1114
1123
{
1115
1124
        /* some versions of Solaris may not have DIRECTIO_ON */
1116
1125
#if defined(UNIV_SOLARIS) && defined(DIRECTIO_ON)
1140
1149
                                "see MySQL Bug#26662\n");
1141
1150
                }
1142
1151
        }
1143
 
#else /* Required for OSX */
1144
 
        (void)fd;
1145
 
        (void)file_name;
1146
 
        (void)operation_name;
 
1152
#else
 
1153
  (void)fd;
 
1154
  (void)file_name;
 
1155
  (void)operation_name;
1147
1156
#endif
1148
1157
}
1149
1158
 
1150
1159
/********************************************************************
1151
1160
Opens an existing file or creates a new. */
1152
 
UNIV_INTERN
 
1161
 
1153
1162
os_file_t
1154
1163
os_file_create(
1155
1164
/*===========*/
1388
1397
 
1389
1398
/***************************************************************************
1390
1399
Deletes a file if it exists. The file has to be closed before calling this. */
1391
 
UNIV_INTERN
 
1400
 
1392
1401
ibool
1393
1402
os_file_delete_if_exists(
1394
1403
/*=====================*/
1436
1445
#else
1437
1446
        int     ret;
1438
1447
 
1439
 
        ret = unlink(name);
 
1448
        ret = unlink((const char*)name);
1440
1449
 
1441
1450
        if (ret != 0 && errno != ENOENT) {
1442
1451
                os_file_handle_error_no_exit(name, "delete");
1450
1459
 
1451
1460
/***************************************************************************
1452
1461
Deletes a file. The file has to be closed before calling this. */
1453
 
UNIV_INTERN
 
1462
 
1454
1463
ibool
1455
1464
os_file_delete(
1456
1465
/*===========*/
1499
1508
#else
1500
1509
        int     ret;
1501
1510
 
1502
 
        ret = unlink(name);
 
1511
        ret = unlink((const char*)name);
1503
1512
 
1504
1513
        if (ret != 0) {
1505
1514
                os_file_handle_error_no_exit(name, "delete");
1514
1523
/***************************************************************************
1515
1524
Renames a file (can also move it to another directory). It is safest that the
1516
1525
file is closed before calling this function. */
1517
 
UNIV_INTERN
 
1526
 
1518
1527
ibool
1519
1528
os_file_rename(
1520
1529
/*===========*/
1538
1547
#else
1539
1548
        int     ret;
1540
1549
 
1541
 
        ret = rename(oldpath, newpath);
 
1550
        ret = rename((const char*)oldpath, (const char*)newpath);
1542
1551
 
1543
1552
        if (ret != 0) {
1544
1553
                os_file_handle_error_no_exit(oldpath, "rename");
1553
1562
/***************************************************************************
1554
1563
Closes a file handle. In case of error, error number can be retrieved with
1555
1564
os_file_get_last_error. */
1556
 
UNIV_INTERN
 
1565
 
1557
1566
ibool
1558
1567
os_file_close(
1559
1568
/*==========*/
1591
1600
 
1592
1601
/***************************************************************************
1593
1602
Closes a file handle. */
1594
 
UNIV_INTERN
 
1603
 
1595
1604
ibool
1596
1605
os_file_close_no_error_handling(
1597
1606
/*============================*/
1626
1635
 
1627
1636
/***************************************************************************
1628
1637
Gets a file size. */
1629
 
UNIV_INTERN
 
1638
 
1630
1639
ibool
1631
1640
os_file_get_size(
1632
1641
/*=============*/
1673
1682
}
1674
1683
 
1675
1684
/***************************************************************************
1676
 
Gets file size as a 64-bit integer ib_int64_t. */
1677
 
UNIV_INTERN
1678
 
ib_int64_t
 
1685
Gets file size as a 64-bit integer ib_longlong. */
 
1686
 
 
1687
ib_longlong
1679
1688
os_file_get_size_as_iblonglong(
1680
1689
/*===========================*/
1681
1690
                                /* out: size in bytes, -1 if error */
1692
1701
                return(-1);
1693
1702
        }
1694
1703
 
1695
 
        return((((ib_int64_t)size_high) << 32) + (ib_int64_t)size);
 
1704
        return((((ib_longlong)size_high) << 32) + (ib_longlong)size);
1696
1705
}
1697
1706
 
1698
1707
/***************************************************************************
1699
1708
Write the specified number of zeros to a newly created file. */
1700
 
UNIV_INTERN
 
1709
 
1701
1710
ibool
1702
1711
os_file_set_size(
1703
1712
/*=============*/
1709
1718
                                size */
1710
1719
        ulint           size_high)/* in: most significant 32 bits of size */
1711
1720
{
1712
 
        ib_int64_t      current_size;
1713
 
        ib_int64_t      desired_size;
 
1721
        ib_longlong     current_size;
 
1722
        ib_longlong     desired_size;
1714
1723
        ibool           ret;
1715
1724
        byte*           buf;
1716
1725
        byte*           buf2;
1719
1728
        ut_a(size == (size & 0xFFFFFFFF));
1720
1729
 
1721
1730
        current_size = 0;
1722
 
        desired_size = (ib_int64_t)size + (((ib_int64_t)size_high) << 32);
 
1731
        desired_size = (ib_longlong)size + (((ib_longlong)size_high) << 32);
1723
1732
 
1724
1733
        /* Write up to 1 megabyte at a time. */
1725
1734
        buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE))
1732
1741
        /* Write buffer full of zeros */
1733
1742
        memset(buf, 0, buf_size);
1734
1743
 
1735
 
        if (desired_size >= (ib_int64_t)(100 * 1024 * 1024)) {
 
1744
        if (desired_size >= (ib_longlong)(100 * 1024 * 1024)) {
1736
1745
 
1737
1746
                fprintf(stderr, "InnoDB: Progress in MB:");
1738
1747
        }
1740
1749
        while (current_size < desired_size) {
1741
1750
                ulint   n_bytes;
1742
1751
 
1743
 
                if (desired_size - current_size < (ib_int64_t) buf_size) {
 
1752
                if (desired_size - current_size < (ib_longlong) buf_size) {
1744
1753
                        n_bytes = (ulint) (desired_size - current_size);
1745
1754
                } else {
1746
1755
                        n_bytes = buf_size;
1756
1765
                }
1757
1766
 
1758
1767
                /* Print about progress for each 100 MB written */
1759
 
                if ((ib_int64_t) (current_size + n_bytes) / (ib_int64_t)(100 * 1024 * 1024)
1760
 
                    != current_size / (ib_int64_t)(100 * 1024 * 1024)) {
 
1768
                if ((ib_longlong) (current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024)
 
1769
                    != current_size / (ib_longlong)(100 * 1024 * 1024)) {
1761
1770
 
1762
1771
                        fprintf(stderr, " %lu00",
1763
1772
                                (ulong) ((current_size + n_bytes)
1764
 
                                         / (ib_int64_t)(100 * 1024 * 1024)));
 
1773
                                         / (ib_longlong)(100 * 1024 * 1024)));
1765
1774
                }
1766
1775
 
1767
1776
                current_size += n_bytes;
1768
1777
        }
1769
1778
 
1770
 
        if (desired_size >= (ib_int64_t)(100 * 1024 * 1024)) {
 
1779
        if (desired_size >= (ib_longlong)(100 * 1024 * 1024)) {
1771
1780
 
1772
1781
                fprintf(stderr, "\n");
1773
1782
        }
1786
1795
 
1787
1796
/***************************************************************************
1788
1797
Truncates a file at its current position. */
1789
 
UNIV_INTERN
 
1798
 
1790
1799
ibool
1791
1800
os_file_set_eof(
1792
1801
/*============*/
1852
1861
 
1853
1862
/***************************************************************************
1854
1863
Flushes the write buffers of a given file to the disk. */
1855
 
UNIV_INTERN
 
1864
 
1856
1865
ibool
1857
1866
os_file_flush(
1858
1867
/*==========*/
2150
2159
 
2151
2160
/***********************************************************************
2152
2161
Requests a synchronous positioned read operation. */
2153
 
UNIV_INTERN
 
2162
 
2154
2163
ibool
2155
2164
os_file_read(
2156
2165
/*=========*/
2267
2276
/***********************************************************************
2268
2277
Requests a synchronous positioned read operation. This function does not do
2269
2278
any error handling. In case of error it returns FALSE. */
2270
 
UNIV_INTERN
 
2279
 
2271
2280
ibool
2272
2281
os_file_read_no_error_handling(
2273
2282
/*===========================*/
2366
2375
Rewind file to its start, read at most size - 1 bytes from it to str, and
2367
2376
NUL-terminate str. All errors are silently ignored. This function is
2368
2377
mostly meant to be used with temporary files. */
2369
 
UNIV_INTERN
 
2378
 
2370
2379
void
2371
2380
os_file_read_string(
2372
2381
/*================*/
2387
2396
 
2388
2397
/***********************************************************************
2389
2398
Requests a synchronous write operation. */
2390
 
UNIV_INTERN
 
2399
 
2391
2400
ibool
2392
2401
os_file_write(
2393
2402
/*==========*/
2580
2589
 
2581
2590
/***********************************************************************
2582
2591
Check the existence and type of the given file. */
2583
 
UNIV_INTERN
 
2592
 
2584
2593
ibool
2585
2594
os_file_status(
2586
2595
/*===========*/
2652
2661
 
2653
2662
/***********************************************************************
2654
2663
This function returns information about the specified file */
2655
 
UNIV_INTERN
 
2664
 
2656
2665
ibool
2657
2666
os_file_get_status(
2658
2667
/*===============*/
2763
2772
       "."            "."            "."
2764
2773
       ".."           "."            ".."
2765
2774
*/
2766
 
UNIV_INTERN
 
2775
 
2767
2776
char*
2768
2777
os_file_dirname(
2769
2778
/*============*/
2794
2803
 
2795
2804
/********************************************************************
2796
2805
Creates all missing subdirectories along the given path. */
2797
 
UNIV_INTERN
 
2806
 
2798
2807
ibool
2799
2808
os_file_create_subdirs_if_needed(
2800
2809
/*=============================*/
2911
2920
in the three first aio arrays is the parameter n_segments given to the
2912
2921
function. The caller must create an i/o handler thread for each segment in
2913
2922
the four first arrays, but not for the sync aio array. */
2914
 
UNIV_INTERN
 
2923
 
2915
2924
void
2916
2925
os_aio_init(
2917
2926
/*========*/
3019
3028
/****************************************************************************
3020
3029
Wakes up all async i/o threads so that they know to exit themselves in
3021
3030
shutdown. */
3022
 
UNIV_INTERN
 
3031
 
3023
3032
void
3024
3033
os_aio_wake_all_threads_at_shutdown(void)
3025
3034
/*=====================================*/
3044
3053
/****************************************************************************
3045
3054
Waits until there are no pending writes in os_aio_write_array. There can
3046
3055
be other, synchronous, pending writes. */
3047
 
UNIV_INTERN
 
3056
 
3048
3057
void
3049
3058
os_aio_wait_until_no_pending_writes(void)
3050
3059
/*=====================================*/
3380
3389
 
3381
3390
/**************************************************************************
3382
3391
Wakes up simulated aio i/o-handler threads if they have something to do. */
3383
 
UNIV_INTERN
 
3392
 
3384
3393
void
3385
3394
os_aio_simulated_wake_handler_threads(void)
3386
3395
/*=======================================*/
3405
3414
prefers an i/o-handler thread to handle them all at once later. You must
3406
3415
call os_aio_simulated_wake_handler_threads later to ensure the threads
3407
3416
are not left sleeping! */
3408
 
UNIV_INTERN
 
3417
 
3409
3418
void
3410
3419
os_aio_simulated_put_read_threads_to_sleep(void)
3411
3420
/*============================================*/
3427
3436
 
3428
3437
/***********************************************************************
3429
3438
Requests an asynchronous i/o operation. */
3430
 
UNIV_INTERN
 
3439
 
3431
3440
ibool
3432
3441
os_aio(
3433
3442
/*===*/
3632
3641
into segments. The thread specifies which segment or slot it wants to wait
3633
3642
for. NOTE: this function will also take care of freeing the aio slot,
3634
3643
therefore no other thread is allowed to do the freeing! */
3635
 
UNIV_INTERN
 
3644
 
3636
3645
ibool
3637
3646
os_aio_windows_handle(
3638
3647
/*==================*/
3735
3744
/**************************************************************************
3736
3745
This function is only used in Posix asynchronous i/o. Waits for an aio
3737
3746
operation to complete. */
3738
 
UNIV_INTERN
 
3747
 
3739
3748
ibool
3740
3749
os_aio_posix_handle(
3741
3750
/*================*/
3812
3821
#endif
3813
3822
 
3814
3823
/**************************************************************************
 
3824
Do a 'last millisecond' check that the page end is sensible;
 
3825
reported page checksum errors from Linux seem to wipe over the page end. */
 
3826
static
 
3827
void
 
3828
os_file_check_page_trailers(
 
3829
/*========================*/
 
3830
        byte*   combined_buf,   /* in: combined write buffer */
 
3831
        ulint   total_len)      /* in: size of combined_buf, in bytes
 
3832
                                (a multiple of UNIV_PAGE_SIZE) */
 
3833
{
 
3834
        ulint   len;
 
3835
 
 
3836
        for (len = 0; len + UNIV_PAGE_SIZE <= total_len;
 
3837
             len += UNIV_PAGE_SIZE) {
 
3838
                byte*   buf = combined_buf + len;
 
3839
 
 
3840
                if (UNIV_UNLIKELY
 
3841
                    (memcmp(buf + (FIL_PAGE_LSN + 4),
 
3842
                            buf + (UNIV_PAGE_SIZE
 
3843
                                   - FIL_PAGE_END_LSN_OLD_CHKSUM + 4), 4))) {
 
3844
                        ut_print_timestamp(stderr);
 
3845
                        fprintf(stderr,
 
3846
                                "  InnoDB: ERROR: The page to be written"
 
3847
                                " seems corrupt!\n"
 
3848
                                "InnoDB: Writing a block of %lu bytes,"
 
3849
                                " currently at offset %lu\n",
 
3850
                                (ulong)total_len, (ulong)len);
 
3851
                        buf_page_print(buf);
 
3852
                        fprintf(stderr,
 
3853
                                "InnoDB: ERROR: The page to be written"
 
3854
                                " seems corrupt!\n");
 
3855
                }
 
3856
        }
 
3857
}
 
3858
 
 
3859
/**************************************************************************
3815
3860
Does simulated aio. This function should be called by an i/o-handler
3816
3861
thread. */
3817
 
UNIV_INTERN
 
3862
 
3818
3863
ibool
3819
3864
os_aio_simulated_handle(
3820
3865
/*====================*/
4047
4092
 
4048
4093
        /* Do the i/o with ordinary, synchronous i/o functions: */
4049
4094
        if (slot->type == OS_FILE_WRITE) {
 
4095
                if (array == os_aio_write_array) {
 
4096
                        if ((total_len % UNIV_PAGE_SIZE != 0)
 
4097
                            || (slot->offset % UNIV_PAGE_SIZE != 0)) {
 
4098
                                fprintf(stderr,
 
4099
                                        "InnoDB: Error: trying a displaced"
 
4100
                                        " write to %s %lu %lu, len %lu\n",
 
4101
                                        slot->name, (ulong) slot->offset_high,
 
4102
                                        (ulong) slot->offset,
 
4103
                                        (ulong) total_len);
 
4104
                                ut_error;
 
4105
                        }
 
4106
 
 
4107
                        os_file_check_page_trailers(combined_buf, total_len);
 
4108
                }
 
4109
 
4050
4110
                ret = os_file_write(slot->name, slot->file, combined_buf,
4051
4111
                                    slot->offset, slot->offset_high,
4052
4112
                                    total_len);
 
4113
 
 
4114
                if (array == os_aio_write_array) {
 
4115
                        os_file_check_page_trailers(combined_buf, total_len);
 
4116
                }
4053
4117
        } else {
4054
4118
                ret = os_file_read(slot->file, combined_buf,
4055
4119
                                   slot->offset, slot->offset_high, total_len);
4170
4234
 
4171
4235
/**************************************************************************
4172
4236
Validates the consistency the aio system. */
4173
 
UNIV_INTERN
 
4237
 
4174
4238
ibool
4175
4239
os_aio_validate(void)
4176
4240
/*=================*/
4187
4251
 
4188
4252
/**************************************************************************
4189
4253
Prints info of the aio arrays. */
4190
 
UNIV_INTERN
 
4254
 
4191
4255
void
4192
4256
os_aio_print(
4193
4257
/*=========*/
4324
4388
 
4325
4389
/**************************************************************************
4326
4390
Refreshes the statistics used to print per-second averages. */
4327
 
UNIV_INTERN
 
4391
 
4328
4392
void
4329
4393
os_aio_refresh_stats(void)
4330
4394
/*======================*/
4341
4405
/**************************************************************************
4342
4406
Checks that all slots in the system have been freed, that is, there are
4343
4407
no pending io operations. */
4344
 
UNIV_INTERN
 
4408
 
4345
4409
ibool
4346
4410
os_aio_all_slots_free(void)
4347
4411
/*=======================*/