~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***********************************************************************
2
2
 
3
 
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
4
 
Copyright (c) 2009, Percona Inc.
 
3
Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
 
4
Copyright (C) 2009, Percona Inc.
5
5
 
6
6
Portions of this file contain modifications contributed and copyrighted
7
7
by Percona Inc.. Those modifications are
76
76
 
77
77
#ifdef __WIN__
78
78
/** File handle */
79
 
#define os_file_t       HANDLE
 
79
# define os_file_t      HANDLE
80
80
/** Convert a C file descriptor to a native file handle
81
81
@param fd       file descriptor
82
82
@return         native file handle */
83
 
#define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
 
83
# define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
84
84
#else
85
85
/** File handle */
86
86
typedef int     os_file_t;
87
87
/** Convert a C file descriptor to a native file handle
88
88
@param fd       file descriptor
89
89
@return         native file handle */
90
 
#define OS_FILE_FROM_FD(fd) fd
 
90
# define OS_FILE_FROM_FD(fd) fd
91
91
#endif
92
92
 
93
93
/** Umask for creating files */
94
94
extern ulint    os_innodb_umask;
95
95
 
96
 
/** If this flag is TRUE, then we will use the native aio of the
97
 
OS (provided we compiled Innobase with it in), otherwise we will
98
 
use simulated aio we build below with threads */
99
 
 
100
 
extern ibool    os_aio_use_native_aio;
101
 
 
102
96
/** The next value should be smaller or equal to the smallest sector size used
103
97
on any disk. A log block is required to be a portion of disk which is written
104
98
so that if the start and the end of a block get written to disk, then the
141
135
#define OS_FILE_SHARING_VIOLATION       76
142
136
#define OS_FILE_ERROR_NOT_SPECIFIED     77
143
137
#define OS_FILE_INSUFFICIENT_RESOURCE   78
144
 
#define OS_FILE_OPERATION_ABORTED       79
 
138
#define OS_FILE_AIO_INTERRUPTED         79
 
139
#define OS_FILE_OPERATION_ABORTED       80
145
140
/* @} */
146
141
 
147
142
/** Types for aio operations @{ */
182
177
#define OS_WIN95        2       /*!< Microsoft Windows 95 */
183
178
#define OS_WINNT        3       /*!< Microsoft Windows NT 3.x */
184
179
#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
 
185
187
 
186
188
extern ulint    os_n_file_reads;
187
189
extern ulint    os_n_file_writes;
188
190
extern ulint    os_n_fsyncs;
189
191
 
 
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
 
190
343
/* File types for directory entry data type */
191
344
 
192
345
enum os_file_type_enum{
222
375
 
223
376
/***********************************************************************//**
224
377
Gets the operating system version. Currently works only on Windows.
225
 
@return OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */
 
378
@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000, OS_WINXP, OS_WINVISTA,
 
379
OS_WIN7. */
226
380
UNIV_INTERN
227
381
ulint
228
382
os_get_os_version(void);
237
391
/***********************************************************************//**
238
392
Creates a temporary file.  This function is like tmpfile(3), but
239
393
the temporary file is created in the MySQL temporary directory.
240
 
On Netware, this function is like tmpfile(3), because the C run-time
241
 
library of Netware does not expose the delete-on-close flag.
242
394
@return temporary file handle, or NULL on error */
243
395
 
244
396
FILE*
296
448
        ibool           fail_if_exists);/*!< in: if TRUE, pre-existing directory
297
449
                                        is treated as an error. */
298
450
/****************************************************************//**
 
451
NOTE! Use the corresponding macro os_file_create_simple(), not directly
 
452
this function!
299
453
A simple function to open or create a file.
300
454
@return own: handle to the file, not defined if error, error number
301
455
can be retrieved with os_file_get_last_error */
302
456
UNIV_INTERN
303
457
os_file_t
304
 
os_file_create_simple(
305
 
/*==================*/
 
458
os_file_create_simple_func(
 
459
/*=======================*/
306
460
        const char*     name,   /*!< in: name of the file or path as a
307
461
                                null-terminated string */
308
462
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file is
316
470
                                OS_FILE_READ_WRITE */
317
471
        ibool*          success);/*!< out: TRUE if succeed, FALSE if error */
318
472
/****************************************************************//**
 
473
NOTE! Use the corresponding macro
 
474
os_file_create_simple_no_error_handling(), not directly this function!
319
475
A simple function to open or create a file.
320
476
@return own: handle to the file, not defined if error, error number
321
477
can be retrieved with os_file_get_last_error */
322
478
UNIV_INTERN
323
479
os_file_t
324
 
os_file_create_simple_no_error_handling(
325
 
/*====================================*/
 
480
os_file_create_simple_no_error_handling_func(
 
481
/*=========================================*/
326
482
        const char*     name,   /*!< in: name of the file or path as a
327
483
                                null-terminated string */
328
484
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
346
502
        const char*     operation_name);/*!< in: "open" or "create"; used in the
347
503
                                        diagnostic message */
348
504
/****************************************************************//**
 
505
NOTE! Use the corresponding macro os_file_create(), not directly
 
506
this function!
349
507
Opens an existing file or creates a new.
350
508
@return own: handle to the file, not defined if error, error number
351
509
can be retrieved with os_file_get_last_error */
352
510
UNIV_INTERN
353
511
os_file_t
354
 
os_file_create(
355
 
/*===========*/
 
512
os_file_create_func(
 
513
/*================*/
356
514
        const char*     name,   /*!< in: name of the file or path as a
357
515
                                null-terminated string */
358
516
        ulint           create_mode,/*!< in: OS_FILE_OPEN if an existing file
390
548
/*=====================*/
391
549
        const char*     name);  /*!< in: file path as a null-terminated string */
392
550
/***********************************************************************//**
 
551
NOTE! Use the corresponding macro os_file_rename(), not directly
 
552
this function!
393
553
Renames a file (can also move it to another directory). It is safest that the
394
554
file is closed before calling this function.
395
555
@return TRUE if success */
396
556
UNIV_INTERN
397
557
ibool
398
 
os_file_rename(
399
 
/*===========*/
 
558
os_file_rename_func(
 
559
/*================*/
400
560
        const char*     oldpath,        /*!< in: old file path as a
401
561
                                        null-terminated string */
402
562
        const char*     newpath);       /*!< in: new file path */
403
563
/***********************************************************************//**
 
564
NOTE! Use the corresponding macro os_file_close(), not directly this
 
565
function!
404
566
Closes a file handle. In case of error, error number can be retrieved with
405
567
os_file_get_last_error.
406
568
@return TRUE if success */
407
569
UNIV_INTERN
408
570
ibool
409
 
os_file_close(
410
 
/*==========*/
 
571
os_file_close_func(
 
572
/*===============*/
411
573
        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
 
412
803
#ifdef UNIV_HOTBACKUP
413
804
/***********************************************************************//**
414
805
Closes a file handle.
460
851
/*============*/
461
852
        FILE*           file);  /*!< in: file to be truncated */
462
853
/***********************************************************************//**
 
854
NOTE! Use the corresponding macro os_file_flush(), not directly this function!
463
855
Flushes the write buffers of a given file to the disk.
464
856
@return TRUE if success */
465
857
UNIV_INTERN
466
858
ibool
467
 
os_file_flush(
468
 
/*==========*/
 
859
os_file_flush_func(
 
860
/*===============*/
469
861
        os_file_t       file);  /*!< in, own: handle to a file */
470
862
/***********************************************************************//**
471
863
Retrieves the last error number if an error occurs in a file io function.
480
872
        ibool   report_all_errors);     /*!< in: TRUE if we want an error message
481
873
                                        printed of all errors */
482
874
/*******************************************************************//**
 
875
NOTE! Use the corresponding macro os_file_read(), not directly this function!
483
876
Requests a synchronous read operation.
484
877
@return TRUE if request was successful, FALSE if fail */
485
878
UNIV_INTERN
486
879
ibool
487
 
os_file_read(
488
 
/*=========*/
 
880
os_file_read_func(
 
881
/*==============*/
489
882
        os_file_t       file,   /*!< in: handle to a file */
490
883
        void*           buf,    /*!< in: buffer where to read */
491
884
        ulint           offset, /*!< in: least significant 32 bits of file
505
898
        char*   str,    /*!< in: buffer where to read */
506
899
        ulint   size);  /*!< in: size of buffer */
507
900
/*******************************************************************//**
 
901
NOTE! Use the corresponding macro os_file_read_no_error_handling(),
 
902
not directly this function!
508
903
Requests a synchronous positioned read operation. This function does not do
509
904
any error handling. In case of error it returns FALSE.
510
905
@return TRUE if request was successful, FALSE if fail */
511
906
UNIV_INTERN
512
907
ibool
513
 
os_file_read_no_error_handling(
514
 
/*===========================*/
 
908
os_file_read_no_error_handling_func(
 
909
/*================================*/
515
910
        os_file_t       file,   /*!< in: handle to a file */
516
911
        void*           buf,    /*!< in: buffer where to read */
517
912
        ulint           offset, /*!< in: least significant 32 bits of file
521
916
        ulint           n);     /*!< in: number of bytes to read */
522
917
 
523
918
/*******************************************************************//**
 
919
NOTE! Use the corresponding macro os_file_write(), not directly this
 
920
function!
524
921
Requests a synchronous write operation.
525
922
@return TRUE if request was successful, FALSE if fail */
526
923
UNIV_INTERN
527
924
ibool
528
 
os_file_write(
529
 
/*==========*/
 
925
os_file_write_func(
 
926
/*===============*/
530
927
        const char*     name,   /*!< in: name of the file or path as a
531
928
                                null-terminated string */
532
929
        os_file_t       file,   /*!< in: handle to a file */
595
992
segment in these arrays. This function also creates the sync array.
596
993
No i/o handler thread needs to be created for that */
597
994
UNIV_INTERN
598
 
void
 
995
ibool
599
996
os_aio_init(
600
997
/*========*/
601
998
        ulint   n_per_seg,      /*<! in: maximum number of pending aio
612
1009
/*=============*/
613
1010
 
614
1011
/*******************************************************************//**
 
1012
NOTE! Use the corresponding macro os_aio(), not directly this function!
615
1013
Requests an asynchronous i/o operation.
616
1014
@return TRUE if request was queued successfully, FALSE if fail */
617
1015
UNIV_INTERN
618
1016
ibool
619
 
os_aio(
620
 
/*===*/
 
1017
os_aio_func(
 
1018
/*========*/
621
1019
        ulint           type,   /*!< in: OS_FILE_READ or OS_FILE_WRITE */
622
1020
        ulint           mode,   /*!< in: OS_AIO_NORMAL, ..., possibly ORed
623
1021
                                to OS_AIO_SIMULATED_WAKE_LATER: the
774
1172
        os_file_stat_t* stat_info);     /*!< information of a file in a
775
1173
                                        directory */
776
1174
 
777
 
#if !defined(UNIV_HOTBACKUP) && !defined(__NETWARE__)
 
1175
#if !defined(UNIV_HOTBACKUP)
778
1176
/*********************************************************************//**
779
1177
Creates a temporary file that will be deleted on close.
780
1178
This function is defined in ha_innodb.cc.
783
1181
int
784
1182
innobase_mysql_tmpfile(void);
785
1183
/*========================*/
786
 
#endif /* !UNIV_HOTBACKUP && !__NETWARE__ */
 
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
787
1217
 
788
1218
#endif