~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/os0file.h

  • Committer: lbieber
  • Date: 2010-10-05 22:23:12 UTC
  • mfrom: (1813.1.4 build)
  • Revision ID: lbieber@orisndriz08-20101005222312-weuq0ardk3gcryau
Merge Travis - 621861 - convert structs to classes
Merge Billy - 621331 - Replace use of stringstream with boost::lexical_cast
Merge Travis - 621861 = To change C structs to C++ classes in Drizzle
Merge Andrew - fix bug 653300 - Syntax error on inport of a SQL file produced by drizzledump

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
4
 
 
5
This program is free software; you can redistribute it and/or modify it under
 
6
the terms of the GNU General Public License as published by the Free Software
 
7
Foundation; version 2 of the License.
 
8
 
 
9
This program is distributed in the hope that it will be useful, but WITHOUT
 
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
12
 
 
13
You should have received a copy of the GNU General Public License along with
 
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
15
St, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
*****************************************************************************/
1
18
/***********************************************************************
2
19
 
3
 
Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
4
 
Copyright (C) 2009, Percona Inc.
 
20
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
21
Copyright (c) 2009, Percona Inc.
5
22
 
6
23
Portions of this file contain modifications contributed and copyrighted
7
24
by Percona Inc.. Those modifications are
76
93
 
77
94
#ifdef __WIN__
78
95
/** File handle */
79
 
# define os_file_t      HANDLE
 
96
#define os_file_t       HANDLE
80
97
/** Convert a C file descriptor to a native file handle
81
98
@param fd       file descriptor
82
99
@return         native file handle */
83
 
# define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
 
100
#define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
84
101
#else
85
102
/** File handle */
86
103
typedef int     os_file_t;
87
104
/** Convert a C file descriptor to a native file handle
88
105
@param fd       file descriptor
89
106
@return         native file handle */
90
 
# define OS_FILE_FROM_FD(fd) fd
 
107
#define OS_FILE_FROM_FD(fd) fd
91
108
#endif
92
109
 
93
110
/** Umask for creating files */
94
111
extern ulint    os_innodb_umask;
95
112
 
 
113
/** If this flag is TRUE, then we will use the native aio of the
 
114
OS (provided we compiled Innobase with it in), otherwise we will
 
115
use simulated aio we build below with threads */
 
116
 
 
117
extern ibool    os_aio_use_native_aio;
 
118
 
96
119
/** The next value should be smaller or equal to the smallest sector size used
97
120
on any disk. A log block is required to be a portion of disk which is written
98
121
so that if the start and the end of a block get written to disk, then the
134
157
                                                to become available again */
135
158
#define OS_FILE_SHARING_VIOLATION       76
136
159
#define OS_FILE_ERROR_NOT_SPECIFIED     77
137
 
#define OS_FILE_INSUFFICIENT_RESOURCE   78
138
 
#define OS_FILE_AIO_INTERRUPTED         79
139
 
#define OS_FILE_OPERATION_ABORTED       80
140
160
/* @} */
141
161
 
142
162
/** Types for aio operations @{ */
177
197
#define OS_WIN95        2       /*!< Microsoft Windows 95 */
178
198
#define OS_WINNT        3       /*!< Microsoft Windows NT 3.x */
179
199
#define OS_WIN2000      4       /*!< Microsoft Windows 2000 */
180
 
#define OS_WINXP        5       /*!< Microsoft Windows XP
181
 
                                or Windows Server 2003 */
182
 
#define OS_WINVISTA     6       /*!< Microsoft Windows Vista
183
 
                                or Windows Server 2008 */
184
 
#define OS_WIN7         7       /*!< Microsoft Windows 7
185
 
                                or Windows Server 2008 R2 */
186
 
 
187
200
 
188
201
extern ulint    os_n_file_reads;
189
202
extern ulint    os_n_file_writes;
190
203
extern ulint    os_n_fsyncs;
191
204
 
192
 
#ifdef UNIV_PFS_IO
193
 
/* Keys to register InnoDB I/O with performance schema */
194
 
extern mysql_pfs_key_t  innodb_file_data_key;
195
 
extern mysql_pfs_key_t  innodb_file_log_key;
196
 
extern mysql_pfs_key_t  innodb_file_temp_key;
197
 
 
198
 
/* Following four macros are instumentations to register
199
 
various file I/O operations with performance schema.
200
 
1) register_pfs_file_open_begin() and register_pfs_file_open_end() are
201
 
used to register file creation, opening, closing and renaming.
202
 
2) register_pfs_file_io_begin() and register_pfs_file_io_end() are
203
 
used to register actual file read, write and flush */
204
 
# define register_pfs_file_open_begin(state, locker, key, op, name,     \
205
 
                                      src_file, src_line)               \
206
 
do {                                                                    \
207
 
        if (PSI_server) {                                               \
208
 
                locker = PSI_server->get_thread_file_name_locker(       \
209
 
                        state, key, op, name, &locker);                 \
210
 
                if (locker) {                                           \
211
 
                        PSI_server->start_file_open_wait(               \
212
 
                                locker, src_file, src_line);            \
213
 
                }                                                       \
214
 
        }                                                               \
215
 
} while (0)
216
 
 
217
 
# define register_pfs_file_open_end(locker, file)                       \
218
 
do {                                                                    \
219
 
        if (locker) {                                                   \
220
 
                PSI_server->end_file_open_wait_and_bind_to_descriptor(  \
221
 
                        locker, file);                                  \
222
 
        }                                                               \
223
 
} while (0)
224
 
 
225
 
# define register_pfs_file_io_begin(state, locker, file, count, op,     \
226
 
                                    src_file, src_line)                 \
227
 
do {                                                                    \
228
 
        if (PSI_server) {                                               \
229
 
                locker = PSI_server->get_thread_file_descriptor_locker( \
230
 
                        state, file, op);                               \
231
 
                if (locker) {                                           \
232
 
                        PSI_server->start_file_wait(                    \
233
 
                                locker, count, src_file, src_line);     \
234
 
                }                                                       \
235
 
        }                                                               \
236
 
} while (0)
237
 
 
238
 
# define register_pfs_file_io_end(locker, count)                        \
239
 
do {                                                                    \
240
 
        if (locker) {                                                   \
241
 
                PSI_server->end_file_wait(locker, count);               \
242
 
        }                                                               \
243
 
} while (0)
244
 
#endif /* UNIV_PFS_IO  */
245
 
 
246
 
/* Following macros/functions are file I/O APIs that would be performance
247
 
schema instrumented if "UNIV_PFS_IO" is defined. They would point to
248
 
wrapper functions with performance schema instrumentation in such case.
249
 
 
250
 
os_file_create
251
 
os_file_create_simple
252
 
os_file_create_simple_no_error_handling
253
 
os_file_close
254
 
os_file_rename
255
 
os_aio
256
 
os_file_read
257
 
os_file_read_no_error_handling
258
 
os_file_write
259
 
 
260
 
The wrapper functions have the prefix of "innodb_". */
261
 
 
262
 
#ifdef UNIV_PFS_IO
263
 
# define os_file_create(key, name, create, purpose, type, success)      \
264
 
        pfs_os_file_create_func(key, name, create, purpose,     type,   \
265
 
                                success, __FILE__, __LINE__)
266
 
 
267
 
# define os_file_create_simple(key, name, create, access, success)      \
268
 
        pfs_os_file_create_simple_func(key, name, create, access,       \
269
 
                                       success, __FILE__, __LINE__)
270
 
 
271
 
# define os_file_create_simple_no_error_handling(                       \
272
 
                key, name, create_mode, access, success)                \
273
 
        pfs_os_file_create_simple_no_error_handling_func(               \
274
 
                key, name, create_mode, access, success, __FILE__, __LINE__)
275
 
 
276
 
# define os_file_close(file)                                            \
277
 
        pfs_os_file_close_func(file, __FILE__, __LINE__)
278
 
 
279
 
# define os_aio(type, mode, name, file, buf, offset, offset_high,       \
280
 
                n, message1, message2)                                  \
281
 
        pfs_os_aio_func(type, mode, name, file, buf, offset,            \
282
 
                        offset_high, n, message1, message2,             \
283
 
                        __FILE__, __LINE__)
284
 
 
285
 
# define os_file_read(file, buf, offset, offset_high, n)                \
286
 
        pfs_os_file_read_func(file, buf, offset, offset_high, n,        \
287
 
                              __FILE__, __LINE__)
288
 
 
289
 
# define os_file_read_no_error_handling(file, buf, offset,              \
290
 
                                        offset_high, n)                 \
291
 
        pfs_os_file_read_no_error_handling_func(file, buf, offset,      \
292
 
                                                offset_high, n,         \
293
 
                                                __FILE__, __LINE__)
294
 
 
295
 
# define os_file_write(name, file, buf, offset, offset_high, n)         \
296
 
        pfs_os_file_write_func(name, file, buf, offset, offset_high,    \
297
 
                               n, __FILE__, __LINE__)
298
 
 
299
 
# define os_file_flush(file)                                            \
300
 
        pfs_os_file_flush_func(file, __FILE__, __LINE__)
301
 
 
302
 
# define os_file_rename(key, oldpath, newpath)                          \
303
 
        pfs_os_file_rename_func(key, oldpath, newpath, __FILE__, __LINE__)
304
 
#else /* UNIV_PFS_IO */
305
 
 
306
 
/* If UNIV_PFS_IO is not defined, these I/O APIs point
307
 
to original un-instrumented file I/O APIs */
308
 
# define os_file_create(key, name, create, purpose, type, success)      \
309
 
        os_file_create_func(name, create, purpose, type, success)
310
 
 
311
 
# define os_file_create_simple(key, name, create, access, success)      \
312
 
        os_file_create_simple_func(name, create_mode, access, success)
313
 
 
314
 
# define os_file_create_simple_no_error_handling(                       \
315
 
                key, name, create_mode, access, success)                \
316
 
        os_file_create_simple_no_error_handling_func(                   \
317
 
                name, create_mode, access, success)
318
 
 
319
 
# define os_file_close(file)    os_file_close_func(file)
320
 
 
321
 
# define os_aio(type, mode, name, file, buf, offset, offset_high,       \
322
 
               n, message1, message2)                                   \
323
 
        os_aio_func(type, mode, name, file, buf, offset, offset_high, n,\
324
 
                    message1, message2)
325
 
 
326
 
# define os_file_read(file, buf, offset, offset_high, n)                \
327
 
        os_file_read_func(file, buf, offset, offset_high, n)
328
 
 
329
 
# define os_file_read_no_error_handling(file, buf, offset,              \
330
 
                                       offset_high, n)                  \
331
 
        os_file_read_no_error_handling_func(file, buf, offset, offset_high, n)
332
 
 
333
 
# define os_file_write(name, file, buf, offset, offset_high, n)         \
334
 
        os_file_write_func(name, file, buf, offset, offset_high, n)
335
 
 
336
 
# define os_file_flush(file)    os_file_flush_func(file)
337
 
 
338
 
# define os_file_rename(key, oldpath, newpath)                          \
339
 
        os_file_rename_func(oldpath, newpath)
340
 
 
341
 
#endif /* UNIV_PFS_IO */
342
 
 
343
205
/* File types for directory entry data type */
344
206
 
345
207
enum os_file_type_enum{
375
237
 
376
238
/***********************************************************************//**
377
239
Gets the operating system version. Currently works only on Windows.
378
 
@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000, OS_WINXP, OS_WINVISTA,
379
 
OS_WIN7. */
 
240
@return OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */
380
241
UNIV_INTERN
381
242
ulint
382
243
os_get_os_version(void);
391
252
/***********************************************************************//**
392
253
Creates a temporary file.  This function is like tmpfile(3), but
393
254
the temporary file is created in the MySQL temporary directory.
 
255
On Netware, this function is like tmpfile(3), because the C run-time
 
256
library of Netware does not expose the delete-on-close flag.
394
257
@return temporary file handle, or NULL on error */
395
258
 
396
259
FILE*
448
311
        ibool           fail_if_exists);/*!< in: if TRUE, pre-existing directory
449
312
                                        is treated as an error. */
450
313
/****************************************************************//**
451
 
NOTE! Use the corresponding macro os_file_create_simple(), not directly
452
 
this function!
453
314
A simple function to open or create a file.
454
315
@return own: handle to the file, not defined if error, error number
455
316
can be retrieved with os_file_get_last_error */
456
317
UNIV_INTERN
457
318
os_file_t
458
 
os_file_create_simple_func(
459
 
/*=======================*/
 
319
os_file_create_simple(
 
320
/*==================*/
460
321
        const char*     name,   /*!< in: name of the file or path as a
461
322
                                null-terminated string */
462
323
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file is
470
331
                                OS_FILE_READ_WRITE */
471
332
        ibool*          success);/*!< out: TRUE if succeed, FALSE if error */
472
333
/****************************************************************//**
473
 
NOTE! Use the corresponding macro
474
 
os_file_create_simple_no_error_handling(), not directly this function!
475
334
A simple function to open or create a file.
476
335
@return own: handle to the file, not defined if error, error number
477
336
can be retrieved with os_file_get_last_error */
478
337
UNIV_INTERN
479
338
os_file_t
480
 
os_file_create_simple_no_error_handling_func(
481
 
/*=========================================*/
 
339
os_file_create_simple_no_error_handling(
 
340
/*====================================*/
482
341
        const char*     name,   /*!< in: name of the file or path as a
483
342
                                null-terminated string */
484
343
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
502
361
        const char*     operation_name);/*!< in: "open" or "create"; used in the
503
362
                                        diagnostic message */
504
363
/****************************************************************//**
505
 
NOTE! Use the corresponding macro os_file_create(), not directly
506
 
this function!
507
364
Opens an existing file or creates a new.
508
365
@return own: handle to the file, not defined if error, error number
509
366
can be retrieved with os_file_get_last_error */
510
367
UNIV_INTERN
511
368
os_file_t
512
 
os_file_create_func(
513
 
/*================*/
 
369
os_file_create(
 
370
/*===========*/
514
371
        const char*     name,   /*!< in: name of the file or path as a
515
372
                                null-terminated string */
516
373
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
548
405
/*=====================*/
549
406
        const char*     name);  /*!< in: file path as a null-terminated string */
550
407
/***********************************************************************//**
551
 
NOTE! Use the corresponding macro os_file_rename(), not directly
552
 
this function!
553
408
Renames a file (can also move it to another directory). It is safest that the
554
409
file is closed before calling this function.
555
410
@return TRUE if success */
556
411
UNIV_INTERN
557
412
ibool
558
 
os_file_rename_func(
559
 
/*================*/
 
413
os_file_rename(
 
414
/*===========*/
560
415
        const char*     oldpath,        /*!< in: old file path as a
561
416
                                        null-terminated string */
562
417
        const char*     newpath);       /*!< in: new file path */
563
418
/***********************************************************************//**
564
 
NOTE! Use the corresponding macro os_file_close(), not directly this
565
 
function!
566
419
Closes a file handle. In case of error, error number can be retrieved with
567
420
os_file_get_last_error.
568
421
@return TRUE if success */
569
422
UNIV_INTERN
570
423
ibool
571
 
os_file_close_func(
572
 
/*===============*/
 
424
os_file_close(
 
425
/*==========*/
573
426
        os_file_t       file);  /*!< in, own: handle to a file */
574
 
 
575
 
#ifdef UNIV_PFS_IO
576
 
/****************************************************************//**
577
 
NOTE! Please use the corresponding macro os_file_create_simple(),
578
 
not directly this function!
579
 
A performance schema instrumented wrapper function for
580
 
os_file_create_simple() which opens or creates a file.
581
 
@return own: handle to the file, not defined if error, error number
582
 
can be retrieved with os_file_get_last_error */
583
 
UNIV_INLINE
584
 
os_file_t
585
 
pfs_os_file_create_simple_func(
586
 
/*===========================*/
587
 
        mysql_pfs_key_t key,    /*!< in: Performance Schema Key */
588
 
        const char*     name,   /*!< in: name of the file or path as a
589
 
                                null-terminated string */
590
 
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file is
591
 
                                opened (if does not exist, error), or
592
 
                                OS_FILE_CREATE if a new file is created
593
 
                                (if exists, error), or
594
 
                                OS_FILE_CREATE_PATH if new file
595
 
                                (if exists, error) and subdirectories along
596
 
                                its path are created (if needed)*/
597
 
        ulint           access_type,/*!< in: OS_FILE_READ_ONLY or
598
 
                                OS_FILE_READ_WRITE */
599
 
        ibool*          success,/*!< out: TRUE if succeed, FALSE if error */
600
 
        const char*     src_file,/*!< in: file name where func invoked */
601
 
        ulint           src_line);/*!< in: line where the func invoked */
602
 
 
603
 
/****************************************************************//**
604
 
NOTE! Please use the corresponding macro
605
 
os_file_create_simple_no_error_handling(), not directly this function!
606
 
A performance schema instrumented wrapper function for
607
 
os_file_create_simple_no_error_handling(). Add instrumentation to
608
 
monitor file creation/open.
609
 
@return own: handle to the file, not defined if error, error number
610
 
can be retrieved with os_file_get_last_error */
611
 
UNIV_INLINE
612
 
os_file_t
613
 
pfs_os_file_create_simple_no_error_handling_func(
614
 
/*=============================================*/
615
 
        mysql_pfs_key_t key,    /*!< in: Performance Schema Key */
616
 
        const char*     name,   /*!< in: name of the file or path as a
617
 
                                null-terminated string */
618
 
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
619
 
                                is opened (if does not exist, error), or
620
 
                                OS_FILE_CREATE if a new file is created
621
 
                                (if exists, error) */
622
 
        ulint           access_type,/*!< in: OS_FILE_READ_ONLY,
623
 
                                OS_FILE_READ_WRITE, or
624
 
                                OS_FILE_READ_ALLOW_DELETE; the last option is
625
 
                                used by a backup program reading the file */
626
 
        ibool*          success,/*!< out: TRUE if succeed, FALSE if error */
627
 
        const char*     src_file,/*!< in: file name where func invoked */
628
 
        ulint           src_line);/*!< in: line where the func invoked */
629
 
 
630
 
/****************************************************************//**
631
 
NOTE! Please use the corresponding macro os_file_create(), not directly
632
 
this function!
633
 
A performance schema wrapper function for os_file_create().
634
 
Add instrumentation to monitor file creation/open.
635
 
@return own: handle to the file, not defined if error, error number
636
 
can be retrieved with os_file_get_last_error */
637
 
UNIV_INLINE
638
 
os_file_t
639
 
pfs_os_file_create_func(
640
 
/*====================*/
641
 
        mysql_pfs_key_t key,    /*!< in: Performance Schema Key */
642
 
        const char*     name,   /*!< in: name of the file or path as a
643
 
                                null-terminated string */
644
 
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
645
 
                                is opened (if does not exist, error), or
646
 
                                OS_FILE_CREATE if a new file is created
647
 
                                (if exists, error),
648
 
                                OS_FILE_OVERWRITE if a new file is created
649
 
                                or an old overwritten;
650
 
                                OS_FILE_OPEN_RAW, if a raw device or disk
651
 
                                partition should be opened */
652
 
        ulint           purpose,/*!< in: OS_FILE_AIO, if asynchronous,
653
 
                                non-buffered i/o is desired,
654
 
                                OS_FILE_NORMAL, if any normal file;
655
 
                                NOTE that it also depends on type, os_aio_..
656
 
                                and srv_.. variables whether we really use
657
 
                                async i/o or unbuffered i/o: look in the
658
 
                                function source code for the exact rules */
659
 
        ulint           type,   /*!< in: OS_DATA_FILE or OS_LOG_FILE */
660
 
        ibool*          success,/*!< out: TRUE if succeed, FALSE if error */
661
 
        const char*     src_file,/*!< in: file name where func invoked */
662
 
        ulint           src_line);/*!< in: line where the func invoked */
663
 
 
664
 
/***********************************************************************//**
665
 
NOTE! Please use the corresponding macro os_file_close(), not directly
666
 
this function!
667
 
A performance schema instrumented wrapper function for os_file_close().
668
 
@return TRUE if success */
669
 
UNIV_INLINE
670
 
ibool
671
 
pfs_os_file_close_func(
672
 
/*===================*/
673
 
        os_file_t       file,   /*!< in, own: handle to a file */
674
 
        const char*     src_file,/*!< in: file name where func invoked */
675
 
        ulint           src_line);/*!< in: line where the func invoked */
676
 
/*******************************************************************//**
677
 
NOTE! Please use the corresponding macro os_file_read(), not directly
678
 
this function!
679
 
This is the performance schema instrumented wrapper function for
680
 
os_file_read() which requests a synchronous read operation.
681
 
@return TRUE if request was successful, FALSE if fail */
682
 
UNIV_INLINE
683
 
ibool
684
 
pfs_os_file_read_func(
685
 
/*==================*/
686
 
        os_file_t       file,   /*!< in: handle to a file */
687
 
        void*           buf,    /*!< in: buffer where to read */
688
 
        ulint           offset, /*!< in: least significant 32 bits of file
689
 
                                offset where to read */
690
 
        ulint           offset_high,/*!< in: most significant 32 bits of
691
 
                                offset */
692
 
        ulint           n,      /*!< in: number of bytes to read */
693
 
        const char*     src_file,/*!< in: file name where func invoked */
694
 
        ulint           src_line);/*!< in: line where the func invoked */
695
 
 
696
 
/*******************************************************************//**
697
 
NOTE! Please use the corresponding macro os_file_read_no_error_handling(),
698
 
not directly this function!
699
 
This is the performance schema instrumented wrapper function for
700
 
os_file_read_no_error_handling_func() which requests a synchronous
701
 
read operation.
702
 
@return TRUE if request was successful, FALSE if fail */
703
 
UNIV_INLINE
704
 
ibool
705
 
pfs_os_file_read_no_error_handling_func(
706
 
/*====================================*/
707
 
        os_file_t       file,   /*!< in: handle to a file */
708
 
        void*           buf,    /*!< in: buffer where to read */
709
 
        ulint           offset, /*!< in: least significant 32 bits of file
710
 
                                offset where to read */
711
 
        ulint           offset_high,/*!< in: most significant 32 bits of
712
 
                                offset */
713
 
        ulint           n,      /*!< in: number of bytes to read */
714
 
        const char*     src_file,/*!< in: file name where func invoked */
715
 
        ulint           src_line);/*!< in: line where the func invoked */
716
 
 
717
 
/*******************************************************************//**
718
 
NOTE! Please use the corresponding macro os_aio(), not directly this
719
 
function!
720
 
Performance schema wrapper function of os_aio() which requests
721
 
an asynchronous i/o operation.
722
 
@return TRUE if request was queued successfully, FALSE if fail */
723
 
UNIV_INLINE
724
 
ibool
725
 
pfs_os_aio_func(
726
 
/*============*/
727
 
        ulint           type,   /*!< in: OS_FILE_READ or OS_FILE_WRITE */
728
 
        ulint           mode,   /*!< in: OS_AIO_NORMAL etc. I/O mode */
729
 
        const char*     name,   /*!< in: name of the file or path as a
730
 
                                null-terminated string */
731
 
        os_file_t       file,   /*!< in: handle to a file */
732
 
        void*           buf,    /*!< in: buffer where to read or from which
733
 
                                to write */
734
 
        ulint           offset, /*!< in: least significant 32 bits of file
735
 
                                offset where to read or write */
736
 
        ulint           offset_high,/*!< in: most significant 32 bits of
737
 
                                offset */
738
 
        ulint           n,      /*!< in: number of bytes to read or write */
739
 
        fil_node_t*     message1,/*!< in: message for the aio handler
740
 
                                (can be used to identify a completed
741
 
                                aio operation); ignored if mode is
742
 
                                OS_AIO_SYNC */
743
 
        void*           message2,/*!< in: message for the aio handler
744
 
                                (can be used to identify a completed
745
 
                                aio operation); ignored if mode is
746
 
                                OS_AIO_SYNC */
747
 
        const char*     src_file,/*!< in: file name where func invoked */
748
 
        ulint           src_line);/*!< in: line where the func invoked */
749
 
/*******************************************************************//**
750
 
NOTE! Please use the corresponding macro os_file_write(), not directly
751
 
this function!
752
 
This is the performance schema instrumented wrapper function for
753
 
os_file_write() which requests a synchronous write operation.
754
 
@return TRUE if request was successful, FALSE if fail */
755
 
UNIV_INLINE
756
 
ibool
757
 
pfs_os_file_write_func(
758
 
/*===================*/
759
 
        const char*     name,   /*!< in: name of the file or path as a
760
 
                                null-terminated string */
761
 
        os_file_t       file,   /*!< in: handle to a file */
762
 
        const void*     buf,    /*!< in: buffer from which to write */
763
 
        ulint           offset, /*!< in: least significant 32 bits of file
764
 
                                offset where to write */
765
 
        ulint           offset_high,/*!< in: most significant 32 bits of
766
 
                                offset */
767
 
        ulint           n,      /*!< in: number of bytes to write */
768
 
        const char*     src_file,/*!< in: file name where func invoked */
769
 
        ulint           src_line);/*!< in: line where the func invoked */
770
 
/***********************************************************************//**
771
 
NOTE! Please use the corresponding macro os_file_flush(), not directly
772
 
this function!
773
 
This is the performance schema instrumented wrapper function for
774
 
os_file_flush() which flushes the write buffers of a given file to the disk.
775
 
Flushes the write buffers of a given file to the disk.
776
 
@return TRUE if success */
777
 
UNIV_INLINE
778
 
ibool
779
 
pfs_os_file_flush_func(
780
 
/*===================*/
781
 
        os_file_t       file,   /*!< in, own: handle to a file */
782
 
        const char*     src_file,/*!< in: file name where func invoked */
783
 
        ulint           src_line);/*!< in: line where the func invoked */
784
 
 
785
 
/***********************************************************************//**
786
 
NOTE! Please use the corresponding macro os_file_rename(), not directly
787
 
this function!
788
 
This is the performance schema instrumented wrapper function for
789
 
os_file_rename()
790
 
@return TRUE if success */
791
 
UNIV_INLINE
792
 
ibool
793
 
pfs_os_file_rename_func(
794
 
/*====================*/
795
 
        mysql_pfs_key_t key,    /*!< in: Performance Schema Key */
796
 
        const char*     oldpath,/*!< in: old file path as a null-terminated
797
 
                                string */
798
 
        const char*     newpath,/*!< in: new file path */
799
 
        const char*     src_file,/*!< in: file name where func invoked */
800
 
        ulint           src_line);/*!< in: line where the func invoked */
801
 
#endif  /* UNIV_PFS_IO */
802
 
 
803
427
#ifdef UNIV_HOTBACKUP
804
428
/***********************************************************************//**
805
429
Closes a file handle.
851
475
/*============*/
852
476
        FILE*           file);  /*!< in: file to be truncated */
853
477
/***********************************************************************//**
854
 
NOTE! Use the corresponding macro os_file_flush(), not directly this function!
855
478
Flushes the write buffers of a given file to the disk.
856
479
@return TRUE if success */
857
480
UNIV_INTERN
858
481
ibool
859
 
os_file_flush_func(
860
 
/*===============*/
 
482
os_file_flush(
 
483
/*==========*/
861
484
        os_file_t       file);  /*!< in, own: handle to a file */
862
485
/***********************************************************************//**
863
486
Retrieves the last error number if an error occurs in a file io function.
872
495
        ibool   report_all_errors);     /*!< in: TRUE if we want an error message
873
496
                                        printed of all errors */
874
497
/*******************************************************************//**
875
 
NOTE! Use the corresponding macro os_file_read(), not directly this function!
876
498
Requests a synchronous read operation.
877
499
@return TRUE if request was successful, FALSE if fail */
878
500
UNIV_INTERN
879
501
ibool
880
 
os_file_read_func(
881
 
/*==============*/
 
502
os_file_read(
 
503
/*=========*/
882
504
        os_file_t       file,   /*!< in: handle to a file */
883
505
        void*           buf,    /*!< in: buffer where to read */
884
506
        ulint           offset, /*!< in: least significant 32 bits of file
898
520
        char*   str,    /*!< in: buffer where to read */
899
521
        ulint   size);  /*!< in: size of buffer */
900
522
/*******************************************************************//**
901
 
NOTE! Use the corresponding macro os_file_read_no_error_handling(),
902
 
not directly this function!
903
523
Requests a synchronous positioned read operation. This function does not do
904
524
any error handling. In case of error it returns FALSE.
905
525
@return TRUE if request was successful, FALSE if fail */
906
526
UNIV_INTERN
907
527
ibool
908
 
os_file_read_no_error_handling_func(
909
 
/*================================*/
 
528
os_file_read_no_error_handling(
 
529
/*===========================*/
910
530
        os_file_t       file,   /*!< in: handle to a file */
911
531
        void*           buf,    /*!< in: buffer where to read */
912
532
        ulint           offset, /*!< in: least significant 32 bits of file
916
536
        ulint           n);     /*!< in: number of bytes to read */
917
537
 
918
538
/*******************************************************************//**
919
 
NOTE! Use the corresponding macro os_file_write(), not directly this
920
 
function!
921
539
Requests a synchronous write operation.
922
540
@return TRUE if request was successful, FALSE if fail */
923
541
UNIV_INTERN
924
542
ibool
925
 
os_file_write_func(
926
 
/*===============*/
 
543
os_file_write(
 
544
/*==========*/
927
545
        const char*     name,   /*!< in: name of the file or path as a
928
546
                                null-terminated string */
929
547
        os_file_t       file,   /*!< in: handle to a file */
992
610
segment in these arrays. This function also creates the sync array.
993
611
No i/o handler thread needs to be created for that */
994
612
UNIV_INTERN
995
 
ibool
 
613
void
996
614
os_aio_init(
997
615
/*========*/
998
616
        ulint   n_per_seg,      /*<! in: maximum number of pending aio
1001
619
        ulint   n_write_segs,   /*<! in: number of writer threads */
1002
620
        ulint   n_slots_sync);  /*<! in: number of slots in the sync aio
1003
621
                                array */
1004
 
/***********************************************************************
1005
 
Frees the asynchronous io system. */
1006
 
UNIV_INTERN
1007
 
void
1008
 
os_aio_free(void);
1009
 
/*=============*/
1010
 
 
1011
622
/*******************************************************************//**
1012
 
NOTE! Use the corresponding macro os_aio(), not directly this function!
1013
623
Requests an asynchronous i/o operation.
1014
624
@return TRUE if request was queued successfully, FALSE if fail */
1015
625
UNIV_INTERN
1016
626
ibool
1017
 
os_aio_func(
1018
 
/*========*/
 
627
os_aio(
 
628
/*===*/
1019
629
        ulint           type,   /*!< in: OS_FILE_READ or OS_FILE_WRITE */
1020
630
        ulint           mode,   /*!< in: OS_AIO_NORMAL, ..., possibly ORed
1021
631
                                to OS_AIO_SIMULATED_WAKE_LATER: the
1172
782
        os_file_stat_t* stat_info);     /*!< information of a file in a
1173
783
                                        directory */
1174
784
 
1175
 
#if !defined(UNIV_HOTBACKUP)
 
785
#if !defined(UNIV_HOTBACKUP) && !defined(__NETWARE__)
1176
786
/*********************************************************************//**
1177
787
Creates a temporary file that will be deleted on close.
1178
788
This function is defined in ha_innodb.cc.
1181
791
int
1182
792
innobase_mysql_tmpfile(void);
1183
793
/*========================*/
1184
 
#endif /* !UNIV_HOTBACKUP */
1185
 
 
1186
 
 
1187
 
#if defined(LINUX_NATIVE_AIO)
1188
 
/**************************************************************************
1189
 
This function is only used in Linux native asynchronous i/o.
1190
 
Waits for an aio operation to complete. This function is used to wait the
1191
 
for completed requests. The aio array of pending requests is divided
1192
 
into segments. The thread specifies which segment or slot it wants to wait
1193
 
for. NOTE: this function will also take care of freeing the aio slot,
1194
 
therefore no other thread is allowed to do the freeing!
1195
 
@return TRUE if the IO was successful */
1196
 
UNIV_INTERN
1197
 
ibool
1198
 
os_aio_linux_handle(
1199
 
/*================*/
1200
 
        ulint   global_seg,     /*!< in: segment number in the aio array
1201
 
                                to wait for; segment 0 is the ibuf
1202
 
                                i/o thread, segment 1 is log i/o thread,
1203
 
                                then follow the non-ibuf read threads,
1204
 
                                and the last are the non-ibuf write
1205
 
                                threads. */
1206
 
        fil_node_t**message1,   /*!< out: the messages passed with the */
1207
 
        void**  message2,       /*!< aio request; note that in case the
1208
 
                                aio operation failed, these output
1209
 
                                parameters are valid and can be used to
1210
 
                                restart the operation. */
1211
 
        ulint*  type);          /*!< out: OS_FILE_WRITE or ..._READ */
1212
 
#endif /* LINUX_NATIVE_AIO */
1213
 
 
1214
 
#ifndef UNIV_NONINL
1215
 
#include "os0file.ic"
1216
 
#endif
 
794
#endif /* !UNIV_HOTBACKUP && !__NETWARE__ */
1217
795
 
1218
796
#endif