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
188
extern ulint os_n_file_reads;
187
189
extern ulint os_n_file_writes;
188
190
extern ulint os_n_fsyncs;
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;
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) \
208
locker = PSI_server->get_thread_file_name_locker( \
209
state, key, op, name, &locker); \
211
PSI_server->start_file_open_wait( \
212
locker, src_file, src_line); \
217
# define register_pfs_file_open_end(locker, file) \
220
PSI_server->end_file_open_wait_and_bind_to_descriptor( \
225
# define register_pfs_file_io_begin(state, locker, file, count, op, \
226
src_file, src_line) \
229
locker = PSI_server->get_thread_file_descriptor_locker( \
232
PSI_server->start_file_wait( \
233
locker, count, src_file, src_line); \
238
# define register_pfs_file_io_end(locker, count) \
241
PSI_server->end_file_wait(locker, count); \
244
#endif /* UNIV_PFS_IO */
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.
251
os_file_create_simple
252
os_file_create_simple_no_error_handling
257
os_file_read_no_error_handling
260
The wrapper functions have the prefix of "innodb_". */
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__)
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__)
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__)
276
# define os_file_close(file) \
277
pfs_os_file_close_func(file, __FILE__, __LINE__)
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, \
285
# define os_file_read(file, buf, offset, offset_high, n) \
286
pfs_os_file_read_func(file, buf, offset, offset_high, n, \
289
# define os_file_read_no_error_handling(file, buf, offset, \
291
pfs_os_file_read_no_error_handling_func(file, buf, offset, \
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__)
299
# define os_file_flush(file) \
300
pfs_os_file_flush_func(file, __FILE__, __LINE__)
302
# define os_file_rename(key, oldpath, newpath) \
303
pfs_os_file_rename_func(key, oldpath, newpath, __FILE__, __LINE__)
304
#else /* UNIV_PFS_IO */
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)
311
# define os_file_create_simple(key, name, create, access, success) \
312
os_file_create_simple_func(name, create_mode, access, success)
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)
319
# define os_file_close(file) os_file_close_func(file)
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,\
326
# define os_file_read(file, buf, offset, offset_high, n) \
327
os_file_read_func(file, buf, offset, offset_high, n)
329
# define os_file_read_no_error_handling(file, buf, offset, \
331
os_file_read_no_error_handling_func(file, buf, offset, offset_high, n)
333
# define os_file_write(name, file, buf, offset, offset_high, n) \
334
os_file_write_func(name, file, buf, offset, offset_high, n)
336
# define os_file_flush(file) os_file_flush_func(file)
338
# define os_file_rename(key, oldpath, newpath) \
339
os_file_rename_func(oldpath, newpath)
341
#endif /* UNIV_PFS_IO */
190
343
/* File types for directory entry data type */
192
345
enum os_file_type_enum{
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
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 */
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
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 */
411
573
os_file_t file); /*!< in, own: handle to a file */
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 */
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 */
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 */
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 */
630
/****************************************************************//**
631
NOTE! Please use the corresponding macro os_file_create(), not directly
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 */
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
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 */
664
/***********************************************************************//**
665
NOTE! Please use the corresponding macro os_file_close(), not directly
667
A performance schema instrumented wrapper function for os_file_close().
668
@return TRUE if success */
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
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 */
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
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 */
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
702
@return TRUE if request was successful, FALSE if fail */
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
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 */
717
/*******************************************************************//**
718
NOTE! Please use the corresponding macro os_aio(), not directly this
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 */
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
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
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
743
void* message2,/*!< in: message for the aio handler
744
(can be used to identify a completed
745
aio operation); ignored if mode is
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
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 */
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
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
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 */
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 */
785
/***********************************************************************//**
786
NOTE! Please use the corresponding macro os_file_rename(), not directly
788
This is the performance schema instrumented wrapper function for
790
@return TRUE if success */
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
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 */
412
803
#ifdef UNIV_HOTBACKUP
413
804
/***********************************************************************//**
414
805
Closes a file handle.