187
182
extern ulint os_n_file_writes;
188
183
extern ulint os_n_fsyncs;
186
/* Keys to register InnoDB I/O with performance schema */
187
extern mysql_pfs_key_t innodb_file_data_key;
188
extern mysql_pfs_key_t innodb_file_log_key;
189
extern mysql_pfs_key_t innodb_file_temp_key;
191
/* Following four macros are instumentations to register
192
various file I/O operations with performance schema.
193
1) register_pfs_file_open_begin() and register_pfs_file_open_end() are
194
used to register file creation, opening, closing and renaming.
195
2) register_pfs_file_io_begin() and register_pfs_file_io_end() are
196
used to register actual file read, write and flush */
197
# define register_pfs_file_open_begin(locker, key, op, name, \
198
src_file, src_line) \
201
locker = PSI_server->get_thread_file_name_locker( \
202
key, op, name, &locker); \
204
PSI_server->start_file_open_wait( \
205
locker, src_file, src_line); \
210
# define register_pfs_file_open_end(locker, file) \
213
PSI_server->end_file_open_wait_and_bind_to_descriptor( \
218
# define register_pfs_file_io_begin(locker, file, count, op, \
219
src_file, src_line) \
222
locker = PSI_server->get_thread_file_descriptor_locker( \
225
PSI_server->start_file_wait( \
226
locker, count, src_file, src_line); \
231
# define register_pfs_file_io_end(locker, count) \
234
PSI_server->end_file_wait(locker, count); \
237
#endif /* UNIV_PFS_IO */
239
/* Following macros/functions are file I/O APIs that would be performance
240
schema instrumented if "UNIV_PFS_IO" is defined. They would point to
241
wrapper functions with performance schema instrumentation in such case.
244
os_file_create_simple
245
os_file_create_simple_no_error_handling
250
os_file_read_no_error_handling
253
The wrapper functions have the prefix of "innodb_". */
256
# define os_file_create(key, name, create, purpose, type, success) \
257
pfs_os_file_create_func(key, name, create, purpose, type, \
258
success, __FILE__, __LINE__)
260
# define os_file_create_simple(key, name, create, access, success) \
261
pfs_os_file_create_simple_func(key, name, create, access, \
262
success, __FILE__, __LINE__)
264
# define os_file_create_simple_no_error_handling( \
265
key, name, create_mode, access, success) \
266
pfs_os_file_create_simple_no_error_handling_func( \
267
key, name, create_mode, access, success, __FILE__, __LINE__)
269
# define os_file_close(file) \
270
pfs_os_file_close_func(file, __FILE__, __LINE__)
272
# define os_aio(type, mode, name, file, buf, offset, offset_high, \
273
n, message1, message2) \
274
pfs_os_aio_func(type, mode, name, file, buf, offset, \
275
offset_high, n, message1, message2, \
278
# define os_file_read(file, buf, offset, offset_high, n) \
279
pfs_os_file_read_func(file, buf, offset, offset_high, n, \
282
# define os_file_read_no_error_handling(file, buf, offset, \
284
pfs_os_file_read_no_error_handling_func(file, buf, offset, \
288
# define os_file_write(name, file, buf, offset, offset_high, n) \
289
pfs_os_file_write_func(name, file, buf, offset, offset_high, \
290
n, __FILE__, __LINE__)
292
# define os_file_flush(file) \
293
pfs_os_file_flush_func(file, __FILE__, __LINE__)
295
# define os_file_rename(key, oldpath, newpath) \
296
pfs_os_file_rename_func(key, oldpath, newpath, __FILE__, __LINE__)
297
#else /* UNIV_PFS_IO */
299
/* If UNIV_PFS_IO is not defined, these I/O APIs point
300
to original un-instrumented file I/O APIs */
301
# define os_file_create(key, name, create, purpose, type, success) \
302
os_file_create_func(name, create, purpose, type, success)
304
# define os_file_create_simple(key, name, create, access, success) \
305
os_file_create_simple_func(name, create_mode, access, success)
307
# define os_file_create_simple_no_error_handling( \
308
key, name, create_mode, access, success) \
309
os_file_create_simple_no_error_handling_func( \
310
name, create_mode, access, success)
312
# define os_file_close(file) os_file_close_func(file)
314
# define os_aio(type, mode, name, file, buf, offset, offset_high, \
315
n, message1, message2) \
316
os_aio_func(type, mode, name, file, buf, offset, offset_high, n,\
319
# define os_file_read(file, buf, offset, offset_high, n) \
320
os_file_read_func(file, buf, offset, offset_high, n)
322
# define os_file_read_no_error_handling(file, buf, offset, \
324
os_file_read_no_error_handling_func(file, buf, offset, offset_high, n)
326
# define os_file_write(name, file, buf, offset, offset_high, n) \
327
os_file_write_func(name, file, buf, offset, offset_high, n)
329
# define os_file_flush(file) os_file_flush_func(file)
331
# define os_file_rename(key, oldpath, newpath) \
332
os_file_rename_func(oldpath, newpath)
334
#endif /* UNIV_PFS_IO */
190
336
/* File types for directory entry data type */
192
338
enum os_file_type_enum{
390
542
/*=====================*/
391
543
const char* name); /*!< in: file path as a null-terminated string */
392
544
/***********************************************************************//**
545
NOTE! Use the corresponding macro os_file_rename(), not directly
393
547
Renames a file (can also move it to another directory). It is safest that the
394
548
file is closed before calling this function.
395
549
@return TRUE if success */
400
554
const char* oldpath, /*!< in: old file path as a
401
555
null-terminated string */
402
556
const char* newpath); /*!< in: new file path */
403
557
/***********************************************************************//**
558
NOTE! Use the corresponding macro os_file_close(), not directly this
404
560
Closes a file handle. In case of error, error number can be retrieved with
405
561
os_file_get_last_error.
406
562
@return TRUE if success */
411
567
os_file_t file); /*!< in, own: handle to a file */
570
/****************************************************************//**
571
NOTE! Please use the corresponding macro os_file_create_simple(),
572
not directly this function!
573
A performance schema instrumented wrapper function for
574
os_file_create_simple() which opens or creates a file.
575
@return own: handle to the file, not defined if error, error number
576
can be retrieved with os_file_get_last_error */
579
pfs_os_file_create_simple_func(
580
/*===========================*/
581
mysql_pfs_key_t key, /*!< in: Performance Schema Key */
582
const char* name, /*!< in: name of the file or path as a
583
null-terminated string */
584
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file is
585
opened (if does not exist, error), or
586
OS_FILE_CREATE if a new file is created
587
(if exists, error), or
588
OS_FILE_CREATE_PATH if new file
589
(if exists, error) and subdirectories along
590
its path are created (if needed)*/
591
ulint access_type,/*!< in: OS_FILE_READ_ONLY or
592
OS_FILE_READ_WRITE */
593
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
594
const char* src_file,/*!< in: file name where func invoked */
595
ulint src_line);/*!< in: line where the func invoked */
597
/****************************************************************//**
598
NOTE! Please use the corresponding macro
599
os_file_create_simple_no_error_handling(), not directly this function!
600
A performance schema instrumented wrapper function for
601
os_file_create_simple_no_error_handling(). Add instrumentation to
602
monitor file creation/open.
603
@return own: handle to the file, not defined if error, error number
604
can be retrieved with os_file_get_last_error */
607
pfs_os_file_create_simple_no_error_handling_func(
608
/*=============================================*/
609
mysql_pfs_key_t key, /*!< in: Performance Schema Key */
610
const char* name, /*!< in: name of the file or path as a
611
null-terminated string */
612
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file
613
is opened (if does not exist, error), or
614
OS_FILE_CREATE if a new file is created
615
(if exists, error) */
616
ulint access_type,/*!< in: OS_FILE_READ_ONLY,
617
OS_FILE_READ_WRITE, or
618
OS_FILE_READ_ALLOW_DELETE; the last option is
619
used by a backup program reading the file */
620
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
621
const char* src_file,/*!< in: file name where func invoked */
622
ulint src_line);/*!< in: line where the func invoked */
624
/****************************************************************//**
625
NOTE! Please use the corresponding macro os_file_create(), not directly
627
A performance schema wrapper function for os_file_create().
628
Add instrumentation to monitor file creation/open.
629
@return own: handle to the file, not defined if error, error number
630
can be retrieved with os_file_get_last_error */
633
pfs_os_file_create_func(
634
/*====================*/
635
mysql_pfs_key_t key, /*!< in: Performance Schema Key */
636
const char* name, /*!< in: name of the file or path as a
637
null-terminated string */
638
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file
639
is opened (if does not exist, error), or
640
OS_FILE_CREATE if a new file is created
642
OS_FILE_OVERWRITE if a new file is created
643
or an old overwritten;
644
OS_FILE_OPEN_RAW, if a raw device or disk
645
partition should be opened */
646
ulint purpose,/*!< in: OS_FILE_AIO, if asynchronous,
647
non-buffered i/o is desired,
648
OS_FILE_NORMAL, if any normal file;
649
NOTE that it also depends on type, os_aio_..
650
and srv_.. variables whether we really use
651
async i/o or unbuffered i/o: look in the
652
function source code for the exact rules */
653
ulint type, /*!< in: OS_DATA_FILE or OS_LOG_FILE */
654
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
655
const char* src_file,/*!< in: file name where func invoked */
656
ulint src_line);/*!< in: line where the func invoked */
658
/***********************************************************************//**
659
NOTE! Please use the corresponding macro os_file_close(), not directly
661
A performance schema instrumented wrapper function for os_file_close().
662
@return TRUE if success */
665
pfs_os_file_close_func(
666
/*===================*/
667
os_file_t file, /*!< in, own: handle to a file */
668
const char* src_file,/*!< in: file name where func invoked */
669
ulint src_line);/*!< in: line where the func invoked */
670
/*******************************************************************//**
671
NOTE! Please use the corresponding macro os_file_read(), not directly
673
This is the performance schema instrumented wrapper function for
674
os_file_read() which requests a synchronous read operation.
675
@return TRUE if request was successful, FALSE if fail */
678
pfs_os_file_read_func(
679
/*==================*/
680
os_file_t file, /*!< in: handle to a file */
681
void* buf, /*!< in: buffer where to read */
682
ulint offset, /*!< in: least significant 32 bits of file
683
offset where to read */
684
ulint offset_high,/*!< in: most significant 32 bits of
686
ulint n, /*!< in: number of bytes to read */
687
const char* src_file,/*!< in: file name where func invoked */
688
ulint src_line);/*!< in: line where the func invoked */
690
/*******************************************************************//**
691
NOTE! Please use the corresponding macro os_file_read_no_error_handling(),
692
not directly this function!
693
This is the performance schema instrumented wrapper function for
694
os_file_read_no_error_handling_func() which requests a synchronous
696
@return TRUE if request was successful, FALSE if fail */
699
pfs_os_file_read_no_error_handling_func(
700
/*====================================*/
701
os_file_t file, /*!< in: handle to a file */
702
void* buf, /*!< in: buffer where to read */
703
ulint offset, /*!< in: least significant 32 bits of file
704
offset where to read */
705
ulint offset_high,/*!< in: most significant 32 bits of
707
ulint n, /*!< in: number of bytes to read */
708
const char* src_file,/*!< in: file name where func invoked */
709
ulint src_line);/*!< in: line where the func invoked */
711
/*******************************************************************//**
712
NOTE! Please use the corresponding macro os_aio(), not directly this
714
Performance schema wrapper function of os_aio() which requests
715
an asynchronous i/o operation.
716
@return TRUE if request was queued successfully, FALSE if fail */
721
ulint type, /*!< in: OS_FILE_READ or OS_FILE_WRITE */
722
ulint mode, /*!< in: OS_AIO_NORMAL etc. I/O mode */
723
const char* name, /*!< in: name of the file or path as a
724
null-terminated string */
725
os_file_t file, /*!< in: handle to a file */
726
void* buf, /*!< in: buffer where to read or from which
728
ulint offset, /*!< in: least significant 32 bits of file
729
offset where to read or write */
730
ulint offset_high,/*!< in: most significant 32 bits of
732
ulint n, /*!< in: number of bytes to read or write */
733
fil_node_t* message1,/*!< in: message for the aio handler
734
(can be used to identify a completed
735
aio operation); ignored if mode is
737
void* message2,/*!< in: message for the aio handler
738
(can be used to identify a completed
739
aio operation); ignored if mode is
741
const char* src_file,/*!< in: file name where func invoked */
742
ulint src_line);/*!< in: line where the func invoked */
743
/*******************************************************************//**
744
NOTE! Please use the corresponding macro os_file_write(), not directly
746
This is the performance schema instrumented wrapper function for
747
os_file_write() which requests a synchronous write operation.
748
@return TRUE if request was successful, FALSE if fail */
751
pfs_os_file_write_func(
752
/*===================*/
753
const char* name, /*!< in: name of the file or path as a
754
null-terminated string */
755
os_file_t file, /*!< in: handle to a file */
756
const void* buf, /*!< in: buffer from which to write */
757
ulint offset, /*!< in: least significant 32 bits of file
758
offset where to write */
759
ulint offset_high,/*!< in: most significant 32 bits of
761
ulint n, /*!< in: number of bytes to write */
762
const char* src_file,/*!< in: file name where func invoked */
763
ulint src_line);/*!< in: line where the func invoked */
764
/***********************************************************************//**
765
NOTE! Please use the corresponding macro os_file_flush(), not directly
767
This is the performance schema instrumented wrapper function for
768
os_file_flush() which flushes the write buffers of a given file to the disk.
769
Flushes the write buffers of a given file to the disk.
770
@return TRUE if success */
773
pfs_os_file_flush_func(
774
/*===================*/
775
os_file_t file, /*!< in, own: handle to a file */
776
const char* src_file,/*!< in: file name where func invoked */
777
ulint src_line);/*!< in: line where the func invoked */
779
/***********************************************************************//**
780
NOTE! Please use the corresponding macro os_file_rename(), not directly
782
This is the performance schema instrumented wrapper function for
784
@return TRUE if success */
787
pfs_os_file_rename_func(
788
/*====================*/
789
mysql_pfs_key_t key, /*!< in: Performance Schema Key */
790
const char* oldpath,/*!< in: old file path as a null-terminated
792
const char* newpath,/*!< in: new file path */
793
const char* src_file,/*!< in: file name where func invoked */
794
ulint src_line);/*!< in: line where the func invoked */
795
#endif /* UNIV_PFS_IO */
412
797
#ifdef UNIV_HOTBACKUP
413
798
/***********************************************************************//**
414
799
Closes a file handle.