summaryrefslogtreecommitdiff
path: root/storage/innobase/include/os0file.h
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/os0file.h')
-rw-r--r--storage/innobase/include/os0file.h106
1 files changed, 72 insertions, 34 deletions
diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h
index e3396a4b7f7..b3a70edf8be 100644
--- a/storage/innobase/include/os0file.h
+++ b/storage/innobase/include/os0file.h
@@ -1,6 +1,6 @@
/***********************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2017, MariaDB Corporation.
@@ -90,6 +90,30 @@ typedef int os_file_t;
static const os_file_t OS_FILE_CLOSED = os_file_t(~0);
+/** File descriptor with optional PERFORMANCE_SCHEMA instrumentation */
+struct pfs_os_file_t
+{
+ /** Default constructor */
+ pfs_os_file_t(os_file_t file = OS_FILE_CLOSED) : m_file(file)
+#ifdef UNIV_PFS_IO
+ , m_psi(NULL)
+#endif
+ {}
+
+ /** The wrapped file handle */
+ os_file_t m_file;
+#ifdef UNIV_PFS_IO
+ /** PERFORMANCE_SCHEMA descriptor */
+ struct PSI_file *m_psi;
+#endif
+ /** Implicit type conversion.
+ @return the wrapped file handle */
+ operator os_file_t() const { return m_file; }
+ /** Assignment operator.
+ @param[in] file file handle to be assigned */
+ void operator=(os_file_t file) { m_file = file; }
+};
+
/** The next value should be smaller or equal to the smallest sector size used
on any disk. A log block is required to be a portion of disk which is written
so that if the start and the end of a block get written to disk, then the
@@ -585,7 +609,7 @@ A simple function to open or create a file.
@param[out] success true if succeed, false if error
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
-os_file_t
+pfs_os_file_t
os_file_create_simple_func(
const char* name,
ulint create_mode,
@@ -605,7 +629,7 @@ A simple function to open or create a file.
@param[out] success true if succeeded
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
-os_file_t
+pfs_os_file_t
os_file_create_simple_no_error_handling_func(
const char* name,
ulint create_mode,
@@ -643,7 +667,7 @@ Opens an existing file or creates a new.
@param[in] success true if succeeded
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
-os_file_t
+pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
@@ -696,6 +720,8 @@ extern mysql_pfs_key_t innodb_temp_file_key;
various file I/O operations with performance schema.
1) register_pfs_file_open_begin() and register_pfs_file_open_end() are
used to register file creation, opening, closing and renaming.
+2) register_pfs_file_rename_begin() and register_pfs_file_rename_end()
+are used to register file renaming
2) register_pfs_file_io_begin() and register_pfs_file_io_end() are
used to register actual file read, write and flush
3) register_pfs_file_close_begin() and register_pfs_file_close_end()
@@ -711,11 +737,23 @@ do { \
} \
} while (0)
-# define register_pfs_file_open_end(locker, file) \
+# define register_pfs_file_open_end(locker, file, result) \
do { \
if (locker != NULL) { \
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(\
- locker, file); \
+ file.m_psi = PSI_FILE_CALL(end_file_open_wait)( \
+ locker, result); \
+ } \
+} while (0)
+
+# define register_pfs_file_rename_begin(state, locker, key, op, name, \
+ src_file, src_line) \
+ register_pfs_file_open_begin(state, locker, key, op, name, \
+ src_file, src_line) \
+
+# define register_pfs_file_rename_end(locker, result) \
+do { \
+ if (locker != NULL) { \
+ PSI_FILE_CALL(end_file_open_wait)(locker, result); \
} \
} while (0)
@@ -741,8 +779,8 @@ do { \
# define register_pfs_file_io_begin(state, locker, file, count, op, \
src_file, src_line) \
do { \
- locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)( \
- state, file, op); \
+ locker = PSI_FILE_CALL(get_thread_file_stream_locker)( \
+ state, file.m_psi, op); \
if (locker != NULL) { \
PSI_FILE_CALL(start_file_wait)( \
locker, count, src_file, src_line); \
@@ -768,7 +806,9 @@ os_file_rename
os_aio
os_file_read
os_file_read_no_error_handling
+os_file_read_no_error_handling_int_fd
os_file_write
+os_file_write_int_fd
The wrapper functions have the prefix of "innodb_". */
@@ -804,11 +844,19 @@ The wrapper functions have the prefix of "innodb_". */
pfs_os_file_read_no_error_handling_func( \
type, file, buf, offset, n, o, __FILE__, __LINE__)
+# define os_file_read_no_error_handling_int_fd(type, file, buf, offset, n) \
+ pfs_os_file_read_no_error_handling_int_fd_func( \
+ type, file, buf, offset, n, __FILE__, __LINE__)
+
# define os_file_write(type, name, file, buf, offset, n) \
pfs_os_file_write_func(type, name, file, buf, offset, \
- n,__FILE__, __LINE__)
+ n, __FILE__, __LINE__)
+
+# define os_file_write_int_fd(type, name, file, buf, offset, n) \
+ pfs_os_file_write_int_fd_func(type, name, file, buf, offset, \
+ n, __FILE__, __LINE__)
-# define os_file_flush(file) \
+# define os_file_flush(file) \
pfs_os_file_flush_func(file, __FILE__, __LINE__)
# define os_file_rename(key, oldpath, newpath) \
@@ -836,7 +884,7 @@ os_file_create_simple() which opens or creates a file.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_simple_func(
mysql_pfs_key_t key,
const char* name,
@@ -867,7 +915,7 @@ monitor file creation/open.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_simple_no_error_handling_func(
mysql_pfs_key_t key,
const char* name,
@@ -900,7 +948,7 @@ Add instrumentation to monitor file creation/open.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
@@ -923,7 +971,7 @@ A performance schema instrumented wrapper function for os_file_close().
UNIV_INLINE
bool
pfs_os_file_close_func(
- os_file_t file,
+ pfs_os_file_t file,
const char* src_file,
uint src_line);
@@ -943,7 +991,7 @@ UNIV_INLINE
dberr_t
pfs_os_file_read_func(
IORequest& type,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -968,7 +1016,7 @@ UNIV_INLINE
dberr_t
pfs_os_file_read_no_error_handling_func(
IORequest& type,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -1004,7 +1052,7 @@ pfs_os_aio_func(
IORequest& type,
ulint mode,
const char* name,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -1033,7 +1081,7 @@ dberr_t
pfs_os_file_write_func(
IORequest& type,
const char* name,
- os_file_t file,
+ pfs_os_file_t file,
const void* buf,
os_offset_t offset,
ulint n,
@@ -1052,7 +1100,7 @@ Flushes the write buffers of a given file to the disk.
UNIV_INLINE
bool
pfs_os_file_flush_func(
- os_file_t file,
+ pfs_os_file_t file,
const char* src_file,
uint src_line);
@@ -1144,9 +1192,12 @@ to original un-instrumented file I/O APIs */
# define os_file_read_no_error_handling(type, file, buf, offset, n, o) \
os_file_read_no_error_handling_func(type, file, buf, offset, n, o)
+# define os_file_read_no_error_handling_int_fd(type, file, buf, offset, n) \
+ os_file_read_no_error_handling_func(type, file, buf, offset, n, NULL)
# define os_file_write(type, name, file, buf, offset, n) \
os_file_write_func(type, name, file, buf, offset, n)
+# define os_file_write_int_fd os_file_write_func
# define os_file_flush(file) os_file_flush_func(file)
@@ -1402,7 +1453,7 @@ os_aio_func(
IORequest& type,
ulint mode,
const char* name,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -1538,19 +1589,6 @@ os_is_sparse_file_supported(
@return DB_SUCCESS or error code */
dberr_t
os_file_punch_hole(
- IORequest& type,
- os_file_t fh,
- os_offset_t off,
- os_offset_t len)
- MY_ATTRIBUTE((warn_unused_result));
-
-/** Free storage space associated with a section of the file.
-@param[in] fh Open file handle
-@param[in] off Starting offset (SEEK_SET)
-@param[in] len Size of the hole
-@return DB_SUCCESS or error code */
-dberr_t
-os_file_punch_hole(
os_file_t fh,
os_offset_t off,
os_offset_t len)