2009-09-07 12:22:53 +02:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
|
2010-08-03 12:54:05 +02:00
|
|
|
|
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
|
2009-09-07 12:22:53 +02:00
|
|
|
|
Copyright (c) 2009, Percona Inc.
|
|
|
|
|
|
|
|
|
|
Portions of this file contain modifications contributed and copyrighted
|
|
|
|
|
by Percona Inc.. Those modifications are
|
|
|
|
|
gratefully acknowledged and are described briefly in the InnoDB
|
|
|
|
|
documentation. The contributions by Percona Inc. are incorporated with
|
|
|
|
|
their permission, and subject to the conditions contained in the file
|
|
|
|
|
COPYING.Percona.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
|
Free Software Foundation; version 2 of the License.
|
2009-03-26 07:11:11 +01:00
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
|
Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
|
|
/**************************************************//**
|
|
|
|
|
@file include/os0file.h
|
2008-12-01 07:10:29 +01:00
|
|
|
|
The interface to the operating system file io
|
|
|
|
|
|
|
|
|
|
Created 10/21/1995 Heikki Tuuri
|
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef os0file_h
|
|
|
|
|
#define os0file_h
|
|
|
|
|
|
|
|
|
|
#include "univ.i"
|
2009-11-04 21:11:12 +01:00
|
|
|
|
#include "trx0types.h"
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
|
|
|
|
#ifndef __WIN__
|
|
|
|
|
#include <dirent.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** File node of a tablespace or the log data space */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
typedef struct fil_node_struct fil_node_t;
|
|
|
|
|
|
|
|
|
|
#ifdef UNIV_DO_FLUSH
|
|
|
|
|
extern ibool os_do_not_call_flush_at_each_write;
|
|
|
|
|
#endif /* UNIV_DO_FLUSH */
|
|
|
|
|
extern ibool os_has_said_disk_full;
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Flag: enable debug printout for asynchronous i/o */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
extern ibool os_aio_print_debug;
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Number of pending os_file_pread() operations */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
extern ulint os_file_n_pending_preads;
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Number of pending os_file_pwrite() operations */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
extern ulint os_file_n_pending_pwrites;
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Number of pending read operations */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
extern ulint os_n_pending_reads;
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Number of pending write operations */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
extern ulint os_n_pending_writes;
|
|
|
|
|
|
|
|
|
|
#ifdef __WIN__
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** We define always WIN_ASYNC_IO, and check at run-time whether
|
2008-12-01 07:10:29 +01:00
|
|
|
|
the OS actually supports it: Win 95 does not, NT does. */
|
|
|
|
|
#define WIN_ASYNC_IO
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Use unbuffered I/O */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#define UNIV_NON_BUFFERED_IO
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef __WIN__
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** File handle */
|
2011-07-14 21:22:41 +02:00
|
|
|
|
# define os_file_t HANDLE
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Convert a C file descriptor to a native file handle
|
|
|
|
|
@param fd file descriptor
|
|
|
|
|
@return native file handle */
|
2011-07-14 21:22:41 +02:00
|
|
|
|
# define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#else
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** File handle */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
typedef int os_file_t;
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Convert a C file descriptor to a native file handle
|
|
|
|
|
@param fd file descriptor
|
|
|
|
|
@return native file handle */
|
2011-07-14 21:22:41 +02:00
|
|
|
|
# define OS_FILE_FROM_FD(fd) fd
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Umask for creating files */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
extern ulint os_innodb_umask;
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** The next value should be smaller or equal to the smallest sector size used
|
2008-12-01 07:10:29 +01:00
|
|
|
|
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
|
|
|
|
|
whole block gets written. This should be true even in most cases of a crash:
|
|
|
|
|
if this fails for a log block, then it is equivalent to a media failure in the
|
|
|
|
|
log. */
|
|
|
|
|
|
2011-02-04 11:25:08 +01:00
|
|
|
|
#define OS_FILE_LOG_BLOCK_SIZE srv_log_block_size
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Options for file_create @{ */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#define OS_FILE_OPEN 51
|
|
|
|
|
#define OS_FILE_CREATE 52
|
|
|
|
|
#define OS_FILE_OVERWRITE 53
|
|
|
|
|
#define OS_FILE_OPEN_RAW 54
|
|
|
|
|
#define OS_FILE_CREATE_PATH 55
|
|
|
|
|
#define OS_FILE_OPEN_RETRY 56 /* for os_file_create() on
|
|
|
|
|
the first ibdata file */
|
|
|
|
|
|
|
|
|
|
#define OS_FILE_READ_ONLY 333
|
|
|
|
|
#define OS_FILE_READ_WRITE 444
|
|
|
|
|
#define OS_FILE_READ_ALLOW_DELETE 555 /* for ibbackup */
|
|
|
|
|
|
|
|
|
|
/* Options for file_create */
|
|
|
|
|
#define OS_FILE_AIO 61
|
|
|
|
|
#define OS_FILE_NORMAL 62
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/* @} */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Types for file create @{ */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#define OS_DATA_FILE 100
|
|
|
|
|
#define OS_LOG_FILE 101
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/* @} */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Error codes from os_file_get_last_error @{ */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#define OS_FILE_NOT_FOUND 71
|
|
|
|
|
#define OS_FILE_DISK_FULL 72
|
|
|
|
|
#define OS_FILE_ALREADY_EXISTS 73
|
|
|
|
|
#define OS_FILE_PATH_ERROR 74
|
|
|
|
|
#define OS_FILE_AIO_RESOURCES_RESERVED 75 /* wait for OS aio resources
|
|
|
|
|
to become available again */
|
|
|
|
|
#define OS_FILE_SHARING_VIOLATION 76
|
|
|
|
|
#define OS_FILE_ERROR_NOT_SPECIFIED 77
|
2010-01-06 13:00:14 +01:00
|
|
|
|
#define OS_FILE_INSUFFICIENT_RESOURCE 78
|
2011-07-14 21:22:41 +02:00
|
|
|
|
#define OS_FILE_AIO_INTERRUPTED 79
|
|
|
|
|
#define OS_FILE_OPERATION_ABORTED 80
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/* @} */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Types for aio operations @{ */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#define OS_FILE_READ 10
|
|
|
|
|
#define OS_FILE_WRITE 11
|
|
|
|
|
|
|
|
|
|
#define OS_FILE_LOG 256 /* This can be ORed to type */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/* @} */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
#define OS_AIO_N_PENDING_IOS_PER_THREAD 32 /*!< Win NT does not allow more
|
2008-12-01 07:10:29 +01:00
|
|
|
|
than 64 */
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/** Modes for aio operations @{ */
|
|
|
|
|
#define OS_AIO_NORMAL 21 /*!< Normal asynchronous i/o not for ibuf
|
2008-12-01 07:10:29 +01:00
|
|
|
|
pages or ibuf bitmap pages */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
#define OS_AIO_IBUF 22 /*!< Asynchronous i/o for ibuf pages or ibuf
|
2008-12-01 07:10:29 +01:00
|
|
|
|
bitmap pages */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
#define OS_AIO_LOG 23 /*!< Asynchronous i/o for the log */
|
|
|
|
|
#define OS_AIO_SYNC 24 /*!< Asynchronous i/o where the calling thread
|
2008-12-01 07:10:29 +01:00
|
|
|
|
will itself wait for the i/o to complete,
|
|
|
|
|
doing also the job of the i/o-handler thread;
|
|
|
|
|
can be used for any pages, ibuf or non-ibuf.
|
|
|
|
|
This is used to save CPU time, as we can do
|
|
|
|
|
with fewer thread switches. Plain synchronous
|
|
|
|
|
i/o is not as good, because it must serialize
|
|
|
|
|
the file seek and read or write, causing a
|
|
|
|
|
bottleneck for parallelism. */
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
#define OS_AIO_SIMULATED_WAKE_LATER 512 /*!< This can be ORed to mode
|
2008-12-01 07:10:29 +01:00
|
|
|
|
in the call of os_aio(...),
|
|
|
|
|
if the caller wants to post several i/o
|
|
|
|
|
requests in a batch, and only after that
|
|
|
|
|
wake the i/o-handler thread; this has
|
|
|
|
|
effect only in simulated aio */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/* @} */
|
|
|
|
|
|
|
|
|
|
#define OS_WIN31 1 /*!< Microsoft Windows 3.x */
|
|
|
|
|
#define OS_WIN95 2 /*!< Microsoft Windows 95 */
|
|
|
|
|
#define OS_WINNT 3 /*!< Microsoft Windows NT 3.x */
|
|
|
|
|
#define OS_WIN2000 4 /*!< Microsoft Windows 2000 */
|
2011-07-14 21:22:41 +02:00
|
|
|
|
#define OS_WINXP 5 /*!< Microsoft Windows XP
|
|
|
|
|
or Windows Server 2003 */
|
|
|
|
|
#define OS_WINVISTA 6 /*!< Microsoft Windows Vista
|
|
|
|
|
or Windows Server 2008 */
|
|
|
|
|
#define OS_WIN7 7 /*!< Microsoft Windows 7
|
|
|
|
|
or Windows Server 2008 R2 */
|
|
|
|
|
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
|
|
|
|
extern ulint os_n_file_reads;
|
|
|
|
|
extern ulint os_n_file_writes;
|
|
|
|
|
extern ulint os_n_fsyncs;
|
|
|
|
|
|
2011-02-04 11:25:08 +01:00
|
|
|
|
extern ulint srv_log_block_size;
|
|
|
|
|
|
2011-07-14 21:22:41 +02:00
|
|
|
|
#ifdef UNIV_PFS_IO
|
|
|
|
|
/* Keys to register InnoDB I/O with performance schema */
|
|
|
|
|
extern mysql_pfs_key_t innodb_file_data_key;
|
|
|
|
|
extern mysql_pfs_key_t innodb_file_log_key;
|
|
|
|
|
extern mysql_pfs_key_t innodb_file_temp_key;
|
|
|
|
|
|
|
|
|
|
/* Following four macros are instumentations to register
|
|
|
|
|
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_io_begin() and register_pfs_file_io_end() are
|
|
|
|
|
used to register actual file read, write and flush */
|
|
|
|
|
# define register_pfs_file_open_begin(state, locker, key, op, name, \
|
|
|
|
|
src_file, src_line) \
|
|
|
|
|
do { \
|
|
|
|
|
if (PSI_server) { \
|
|
|
|
|
locker = PSI_server->get_thread_file_name_locker( \
|
|
|
|
|
state, key, op, name, &locker); \
|
|
|
|
|
if (locker) { \
|
|
|
|
|
PSI_server->start_file_open_wait( \
|
|
|
|
|
locker, src_file, src_line); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
# define register_pfs_file_open_end(locker, file) \
|
|
|
|
|
do { \
|
|
|
|
|
if (locker) { \
|
|
|
|
|
PSI_server->end_file_open_wait_and_bind_to_descriptor( \
|
|
|
|
|
locker, file); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
# define register_pfs_file_io_begin(state, locker, file, count, op, \
|
|
|
|
|
src_file, src_line) \
|
|
|
|
|
do { \
|
|
|
|
|
if (PSI_server) { \
|
|
|
|
|
locker = PSI_server->get_thread_file_descriptor_locker( \
|
|
|
|
|
state, file, op); \
|
|
|
|
|
if (locker) { \
|
|
|
|
|
PSI_server->start_file_wait( \
|
|
|
|
|
locker, count, src_file, src_line); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
# define register_pfs_file_io_end(locker, count) \
|
|
|
|
|
do { \
|
|
|
|
|
if (locker) { \
|
|
|
|
|
PSI_server->end_file_wait(locker, count); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
#endif /* UNIV_PFS_IO */
|
|
|
|
|
|
|
|
|
|
/* Following macros/functions are file I/O APIs that would be performance
|
|
|
|
|
schema instrumented if "UNIV_PFS_IO" is defined. They would point to
|
|
|
|
|
wrapper functions with performance schema instrumentation in such case.
|
|
|
|
|
|
|
|
|
|
os_file_create
|
|
|
|
|
os_file_create_simple
|
|
|
|
|
os_file_create_simple_no_error_handling
|
|
|
|
|
os_file_close
|
|
|
|
|
os_file_rename
|
|
|
|
|
os_aio
|
|
|
|
|
os_file_read
|
|
|
|
|
os_file_read_no_error_handling
|
|
|
|
|
os_file_write
|
|
|
|
|
|
|
|
|
|
The wrapper functions have the prefix of "innodb_". */
|
|
|
|
|
|
|
|
|
|
#ifdef UNIV_PFS_IO
|
|
|
|
|
# define os_file_create(key, name, create, purpose, type, success) \
|
|
|
|
|
pfs_os_file_create_func(key, name, create, purpose, type, \
|
|
|
|
|
success, __FILE__, __LINE__)
|
|
|
|
|
|
|
|
|
|
# define os_file_create_simple(key, name, create, access, success) \
|
|
|
|
|
pfs_os_file_create_simple_func(key, name, create, access, \
|
|
|
|
|
success, __FILE__, __LINE__)
|
|
|
|
|
|
|
|
|
|
# define os_file_create_simple_no_error_handling( \
|
|
|
|
|
key, name, create_mode, access, success) \
|
|
|
|
|
pfs_os_file_create_simple_no_error_handling_func( \
|
|
|
|
|
key, name, create_mode, access, success, __FILE__, __LINE__)
|
|
|
|
|
|
|
|
|
|
# define os_file_close(file) \
|
|
|
|
|
pfs_os_file_close_func(file, __FILE__, __LINE__)
|
|
|
|
|
|
|
|
|
|
# define os_aio(type, mode, name, file, buf, offset, offset_high, \
|
|
|
|
|
n, message1, message2, space_id, trx) \
|
|
|
|
|
pfs_os_aio_func(type, mode, name, file, buf, offset, \
|
|
|
|
|
offset_high, n, message1, message2, space_id, trx,\
|
|
|
|
|
__FILE__, __LINE__)
|
|
|
|
|
|
|
|
|
|
# define os_file_read(file, buf, offset, offset_high, n) \
|
|
|
|
|
pfs_os_file_read_func(file, buf, offset, offset_high, n, NULL, \
|
|
|
|
|
__FILE__, __LINE__)
|
|
|
|
|
|
|
|
|
|
# define os_file_read_trx(file, buf, offset, offset_high, n, trx) \
|
2011-12-14 14:58:22 +01:00
|
|
|
|
pfs_os_file_read_func(file, buf, offset, offset_high, n, trx, \
|
|
|
|
|
__FILE__, __LINE__)
|
2011-07-14 21:22:41 +02:00
|
|
|
|
|
|
|
|
|
# define os_file_read_no_error_handling(file, buf, offset, \
|
|
|
|
|
offset_high, n) \
|
|
|
|
|
pfs_os_file_read_no_error_handling_func(file, buf, offset, \
|
|
|
|
|
offset_high, n, \
|
|
|
|
|
__FILE__, __LINE__)
|
|
|
|
|
|
|
|
|
|
# define os_file_write(name, file, buf, offset, offset_high, n) \
|
|
|
|
|
pfs_os_file_write_func(name, file, buf, offset, offset_high, \
|
|
|
|
|
n, __FILE__, __LINE__)
|
|
|
|
|
|
2011-07-17 11:28:48 +02:00
|
|
|
|
# define os_file_flush(file, metadata) \
|
|
|
|
|
pfs_os_file_flush_func(file, metadata, __FILE__, __LINE__)
|
2011-07-14 21:22:41 +02:00
|
|
|
|
|
|
|
|
|
# define os_file_rename(key, oldpath, newpath) \
|
|
|
|
|
pfs_os_file_rename_func(key, oldpath, newpath, __FILE__, __LINE__)
|
|
|
|
|
#else /* UNIV_PFS_IO */
|
|
|
|
|
|
|
|
|
|
/* If UNIV_PFS_IO is not defined, these I/O APIs point
|
|
|
|
|
to original un-instrumented file I/O APIs */
|
|
|
|
|
# define os_file_create(key, name, create, purpose, type, success) \
|
|
|
|
|
os_file_create_func(name, create, purpose, type, success)
|
|
|
|
|
|
|
|
|
|
# define os_file_create_simple(key, name, create, access, success) \
|
|
|
|
|
os_file_create_simple_func(name, create_mode, access, success)
|
|
|
|
|
|
|
|
|
|
# define os_file_create_simple_no_error_handling( \
|
|
|
|
|
key, name, create_mode, access, success) \
|
|
|
|
|
os_file_create_simple_no_error_handling_func( \
|
|
|
|
|
name, create_mode, access, success)
|
|
|
|
|
|
|
|
|
|
# define os_file_close(file) os_file_close_func(file)
|
|
|
|
|
|
|
|
|
|
# define os_aio(type, mode, name, file, buf, offset, offset_high, \
|
|
|
|
|
n, message1, message2, space_id, trx) \
|
|
|
|
|
os_aio_func(type, mode, name, file, buf, offset, offset_high, n,\
|
|
|
|
|
message1, message2, space_id, trx)
|
|
|
|
|
|
|
|
|
|
# define os_file_read(file, buf, offset, offset_high, n) \
|
|
|
|
|
os_file_read_func(file, buf, offset, offset_high, n, NULL)
|
|
|
|
|
|
|
|
|
|
# define os_file_read_trx(file, buf, offset, offset_high, n, trx) \
|
|
|
|
|
os_file_read_func(file, buf, offset, offset_high, n, trx)
|
|
|
|
|
|
|
|
|
|
# define os_file_read_no_error_handling(file, buf, offset, \
|
|
|
|
|
offset_high, n) \
|
|
|
|
|
os_file_read_no_error_handling_func(file, buf, offset, offset_high, n)
|
|
|
|
|
|
|
|
|
|
# define os_file_write(name, file, buf, offset, offset_high, n) \
|
|
|
|
|
os_file_write_func(name, file, buf, offset, offset_high, n)
|
|
|
|
|
|
2011-07-17 11:28:48 +02:00
|
|
|
|
# define os_file_flush(file, metadata) os_file_flush_func(file, metadata)
|
2011-07-14 21:22:41 +02:00
|
|
|
|
|
|
|
|
|
# define os_file_rename(key, oldpath, newpath) \
|
|
|
|
|
os_file_rename_func(oldpath, newpath)
|
|
|
|
|
|
|
|
|
|
#endif /* UNIV_PFS_IO */
|
|
|
|
|
|
2008-12-01 07:10:29 +01:00
|
|
|
|
/* File types for directory entry data type */
|
|
|
|
|
|
|
|
|
|
enum os_file_type_enum{
|
|
|
|
|
OS_FILE_TYPE_UNKNOWN = 0,
|
|
|
|
|
OS_FILE_TYPE_FILE, /* regular file */
|
|
|
|
|
OS_FILE_TYPE_DIR, /* directory */
|
|
|
|
|
OS_FILE_TYPE_LINK /* symbolic link */
|
|
|
|
|
};
|
|
|
|
|
typedef enum os_file_type_enum os_file_type_t;
|
|
|
|
|
|
|
|
|
|
/* Maximum path string length in bytes when referring to tables with in the
|
|
|
|
|
'./databasename/tablename.ibd' path format; we can allocate at least 2 buffers
|
|
|
|
|
of this size from the thread stack; that is why this should not be made much
|
|
|
|
|
bigger than 4000 bytes */
|
|
|
|
|
#define OS_FILE_MAX_PATH 4000
|
|
|
|
|
|
|
|
|
|
/* Struct used in fetching information of a file in a directory */
|
|
|
|
|
struct os_file_stat_struct{
|
2009-09-07 12:22:53 +02:00
|
|
|
|
char name[OS_FILE_MAX_PATH]; /*!< path to a file */
|
|
|
|
|
os_file_type_t type; /*!< file type */
|
|
|
|
|
ib_int64_t size; /*!< file size */
|
|
|
|
|
time_t ctime; /*!< creation time */
|
|
|
|
|
time_t mtime; /*!< modification time */
|
|
|
|
|
time_t atime; /*!< access time */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
};
|
|
|
|
|
typedef struct os_file_stat_struct os_file_stat_t;
|
|
|
|
|
|
|
|
|
|
#ifdef __WIN__
|
2009-09-07 12:22:53 +02:00
|
|
|
|
typedef HANDLE os_file_dir_t; /*!< directory stream */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#else
|
2009-09-07 12:22:53 +02:00
|
|
|
|
typedef DIR* os_file_dir_t; /*!< directory stream */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-07-14 21:22:41 +02:00
|
|
|
|
#ifdef __WIN__
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Gets the operating system version. Currently works only on Windows.
|
2011-07-14 21:22:41 +02:00
|
|
|
|
@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000, OS_WINXP, OS_WINVISTA,
|
|
|
|
|
OS_WIN7. */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ulint
|
|
|
|
|
os_get_os_version(void);
|
|
|
|
|
/*===================*/
|
2011-07-14 21:22:41 +02:00
|
|
|
|
#endif /* __WIN__ */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
|
/****************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Creates the seek mutexes used in positioned reads and writes. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_io_init_simple(void);
|
|
|
|
|
/*===================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/***********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Creates a temporary file. This function is like tmpfile(3), but
|
|
|
|
|
the temporary file is created in the MySQL temporary directory.
|
2009-09-07 12:22:53 +02:00
|
|
|
|
@return temporary file handle, or NULL on error */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
|
|
|
|
FILE*
|
|
|
|
|
os_file_create_tmpfile(void);
|
|
|
|
|
/*========================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
/***********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
The os_file_opendir() function opens a directory stream corresponding to the
|
|
|
|
|
directory named by the dirname argument. The directory stream is positioned
|
|
|
|
|
at the first entry. In both Unix and Windows we automatically skip the '.'
|
2009-09-07 12:22:53 +02:00
|
|
|
|
and '..' items at the start of the directory listing.
|
|
|
|
|
@return directory stream, NULL if error */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
os_file_dir_t
|
|
|
|
|
os_file_opendir(
|
|
|
|
|
/*============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* dirname, /*!< in: directory name; it must not
|
2008-12-01 07:10:29 +01:00
|
|
|
|
contain a trailing '\' or '/' */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ibool error_is_fatal);/*!< in: TRUE if we should treat an
|
2008-12-01 07:10:29 +01:00
|
|
|
|
error as a fatal error; if we try to
|
|
|
|
|
open symlinks then we do not wish a
|
|
|
|
|
fatal error if it happens not to be
|
|
|
|
|
a directory */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Closes a directory stream.
|
|
|
|
|
@return 0 if success, -1 if failure */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
int
|
|
|
|
|
os_file_closedir(
|
|
|
|
|
/*=============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_dir_t dir); /*!< in: directory stream */
|
|
|
|
|
/***********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
This function returns information of the next file in the directory. We jump
|
2009-09-07 12:22:53 +02:00
|
|
|
|
over the '.' and '..' entries in the directory.
|
|
|
|
|
@return 0 if ok, -1 if error, 1 if at the end of the directory */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
int
|
|
|
|
|
os_file_readdir_next_file(
|
|
|
|
|
/*======================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* dirname,/*!< in: directory name or path */
|
|
|
|
|
os_file_dir_t dir, /*!< in: directory stream */
|
|
|
|
|
os_file_stat_t* info); /*!< in/out: buffer where the info is returned */
|
|
|
|
|
/*****************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
This function attempts to create a directory named pathname. The new directory
|
|
|
|
|
gets default permissions. On Unix, the permissions are (0770 & ~umask). If the
|
|
|
|
|
directory exists already, nothing is done and the call succeeds, unless the
|
2009-09-07 12:22:53 +02:00
|
|
|
|
fail_if_exists arguments is true.
|
|
|
|
|
@return TRUE if call succeeds, FALSE on error */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_create_directory(
|
|
|
|
|
/*=====================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* pathname, /*!< in: directory name as
|
2008-12-01 07:10:29 +01:00
|
|
|
|
null-terminated string */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ibool fail_if_exists);/*!< in: if TRUE, pre-existing directory
|
2008-12-01 07:10:29 +01:00
|
|
|
|
is treated as an error. */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/****************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_file_create_simple(), not directly
|
|
|
|
|
this function!
|
2009-09-07 12:22:53 +02:00
|
|
|
|
A simple function to open or create a file.
|
|
|
|
|
@return own: handle to the file, not defined if error, error number
|
|
|
|
|
can be retrieved with os_file_get_last_error */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
os_file_t
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_create_simple_func(
|
|
|
|
|
/*=======================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
2008-12-01 07:10:29 +01:00
|
|
|
|
null-terminated string */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file is
|
2008-12-01 07:10:29 +01:00
|
|
|
|
opened (if does not exist, error), or
|
|
|
|
|
OS_FILE_CREATE if a new file is created
|
|
|
|
|
(if exists, error), or
|
|
|
|
|
OS_FILE_CREATE_PATH if new file
|
|
|
|
|
(if exists, error) and subdirectories along
|
|
|
|
|
its path are created (if needed)*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint access_type,/*!< in: OS_FILE_READ_ONLY or
|
2008-12-01 07:10:29 +01:00
|
|
|
|
OS_FILE_READ_WRITE */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ibool* success);/*!< out: TRUE if succeed, FALSE if error */
|
|
|
|
|
/****************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro
|
|
|
|
|
os_file_create_simple_no_error_handling(), not directly this function!
|
2009-09-07 12:22:53 +02:00
|
|
|
|
A simple function to open or create a file.
|
|
|
|
|
@return own: handle to the file, not defined if error, error number
|
|
|
|
|
can be retrieved with os_file_get_last_error */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
os_file_t
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_create_simple_no_error_handling_func(
|
|
|
|
|
/*=========================================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
2008-12-01 07:10:29 +01:00
|
|
|
|
null-terminated string */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file
|
2008-12-01 07:10:29 +01:00
|
|
|
|
is opened (if does not exist, error), or
|
|
|
|
|
OS_FILE_CREATE if a new file is created
|
|
|
|
|
(if exists, error) */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint access_type,/*!< in: OS_FILE_READ_ONLY,
|
2008-12-01 07:10:29 +01:00
|
|
|
|
OS_FILE_READ_WRITE, or
|
|
|
|
|
OS_FILE_READ_ALLOW_DELETE; the last option is
|
|
|
|
|
used by a backup program reading the file */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ibool* success);/*!< out: TRUE if succeed, FALSE if error */
|
|
|
|
|
/****************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Tries to disable OS caching on an opened file descriptor. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_file_set_nocache(
|
|
|
|
|
/*================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
int fd, /*!< in: file descriptor to alter */
|
|
|
|
|
const char* file_name, /*!< in: file name, used in the
|
2008-12-01 07:10:29 +01:00
|
|
|
|
diagnostic message */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* operation_name);/*!< in: "open" or "create"; used in the
|
2008-12-01 07:10:29 +01:00
|
|
|
|
diagnostic message */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/****************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_file_create(), not directly
|
|
|
|
|
this function!
|
2009-09-07 12:22:53 +02:00
|
|
|
|
Opens an existing file or creates a new.
|
|
|
|
|
@return own: handle to the file, not defined if error, error number
|
|
|
|
|
can be retrieved with os_file_get_last_error */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
os_file_t
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_create_func(
|
|
|
|
|
/*================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
2008-12-01 07:10:29 +01:00
|
|
|
|
null-terminated string */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file
|
2008-12-01 07:10:29 +01:00
|
|
|
|
is opened (if does not exist, error), or
|
|
|
|
|
OS_FILE_CREATE if a new file is created
|
|
|
|
|
(if exists, error),
|
|
|
|
|
OS_FILE_OVERWRITE if a new file is created
|
|
|
|
|
or an old overwritten;
|
|
|
|
|
OS_FILE_OPEN_RAW, if a raw device or disk
|
|
|
|
|
partition should be opened */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint purpose,/*!< in: OS_FILE_AIO, if asynchronous,
|
2008-12-01 07:10:29 +01:00
|
|
|
|
non-buffered i/o is desired,
|
|
|
|
|
OS_FILE_NORMAL, if any normal file;
|
|
|
|
|
NOTE that it also depends on type, os_aio_..
|
|
|
|
|
and srv_.. variables whether we really use
|
|
|
|
|
async i/o or unbuffered i/o: look in the
|
|
|
|
|
function source code for the exact rules */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint type, /*!< in: OS_DATA_FILE or OS_LOG_FILE */
|
|
|
|
|
ibool* success);/*!< out: TRUE if succeed, FALSE if error */
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Deletes a file. The file has to be closed before calling this.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_delete(
|
|
|
|
|
/*===========*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* name); /*!< in: file path as a null-terminated string */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Deletes a file if it exists. The file has to be closed before calling this.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_delete_if_exists(
|
|
|
|
|
/*=====================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* name); /*!< in: file path as a null-terminated string */
|
|
|
|
|
/***********************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_file_rename(), not directly
|
|
|
|
|
this function!
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Renames a file (can also move it to another directory). It is safest that the
|
2009-09-07 12:22:53 +02:00
|
|
|
|
file is closed before calling this function.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_rename_func(
|
|
|
|
|
/*================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* oldpath, /*!< in: old file path as a
|
2008-12-01 07:10:29 +01:00
|
|
|
|
null-terminated string */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* newpath); /*!< in: new file path */
|
|
|
|
|
/***********************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_file_close(), not directly this
|
|
|
|
|
function!
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Closes a file handle. In case of error, error number can be retrieved with
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_get_last_error.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_close_func(
|
|
|
|
|
/*===============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file); /*!< in, own: handle to a file */
|
2011-07-14 21:22:41 +02:00
|
|
|
|
|
|
|
|
|
#ifdef UNIV_PFS_IO
|
|
|
|
|
/****************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_file_create_simple(),
|
|
|
|
|
not directly this function!
|
|
|
|
|
A performance schema instrumented wrapper function for
|
|
|
|
|
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_create_simple_func(
|
|
|
|
|
/*===========================*/
|
|
|
|
|
mysql_pfs_key_t key, /*!< in: Performance Schema Key */
|
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
|
|
|
|
null-terminated string */
|
|
|
|
|
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file is
|
|
|
|
|
opened (if does not exist, error), or
|
|
|
|
|
OS_FILE_CREATE if a new file is created
|
|
|
|
|
(if exists, error), or
|
|
|
|
|
OS_FILE_CREATE_PATH if new file
|
|
|
|
|
(if exists, error) and subdirectories along
|
|
|
|
|
its path are created (if needed)*/
|
|
|
|
|
ulint access_type,/*!< in: OS_FILE_READ_ONLY or
|
|
|
|
|
OS_FILE_READ_WRITE */
|
|
|
|
|
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
|
|
|
|
|
/****************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro
|
|
|
|
|
os_file_create_simple_no_error_handling(), not directly this function!
|
|
|
|
|
A performance schema instrumented wrapper function for
|
|
|
|
|
os_file_create_simple_no_error_handling(). 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_create_simple_no_error_handling_func(
|
|
|
|
|
/*=============================================*/
|
|
|
|
|
mysql_pfs_key_t key, /*!< in: Performance Schema Key */
|
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
|
|
|
|
null-terminated string */
|
|
|
|
|
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file
|
|
|
|
|
is opened (if does not exist, error), or
|
|
|
|
|
OS_FILE_CREATE if a new file is created
|
|
|
|
|
(if exists, error) */
|
|
|
|
|
ulint access_type,/*!< in: OS_FILE_READ_ONLY,
|
|
|
|
|
OS_FILE_READ_WRITE, or
|
|
|
|
|
OS_FILE_READ_ALLOW_DELETE; the last option is
|
|
|
|
|
used by a backup program reading the file */
|
|
|
|
|
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
|
|
|
|
|
/****************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_file_create(), not directly
|
|
|
|
|
this function!
|
|
|
|
|
A performance schema wrapper function for os_file_create().
|
|
|
|
|
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_create_func(
|
|
|
|
|
/*====================*/
|
|
|
|
|
mysql_pfs_key_t key, /*!< in: Performance Schema Key */
|
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
|
|
|
|
null-terminated string */
|
|
|
|
|
ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file
|
|
|
|
|
is opened (if does not exist, error), or
|
|
|
|
|
OS_FILE_CREATE if a new file is created
|
|
|
|
|
(if exists, error),
|
|
|
|
|
OS_FILE_OVERWRITE if a new file is created
|
|
|
|
|
or an old overwritten;
|
|
|
|
|
OS_FILE_OPEN_RAW, if a raw device or disk
|
|
|
|
|
partition should be opened */
|
|
|
|
|
ulint purpose,/*!< in: OS_FILE_AIO, if asynchronous,
|
|
|
|
|
non-buffered i/o is desired,
|
|
|
|
|
OS_FILE_NORMAL, if any normal file;
|
|
|
|
|
NOTE that it also depends on type, os_aio_..
|
|
|
|
|
and srv_.. variables whether we really use
|
|
|
|
|
async i/o or unbuffered i/o: look in the
|
|
|
|
|
function source code for the exact rules */
|
|
|
|
|
ulint type, /*!< in: OS_DATA_FILE or OS_LOG_FILE */
|
|
|
|
|
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_file_close(), not directly
|
|
|
|
|
this function!
|
|
|
|
|
A performance schema instrumented wrapper function for os_file_close().
|
|
|
|
|
@return TRUE if success */
|
|
|
|
|
UNIV_INLINE
|
|
|
|
|
ibool
|
|
|
|
|
pfs_os_file_close_func(
|
|
|
|
|
/*===================*/
|
|
|
|
|
os_file_t file, /*!< in, own: handle to a file */
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
/*******************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_file_read(), not directly
|
|
|
|
|
this function!
|
|
|
|
|
This is the performance schema instrumented wrapper function for
|
|
|
|
|
os_file_read() which requests a synchronous read operation.
|
|
|
|
|
@return TRUE if request was successful, FALSE if fail */
|
|
|
|
|
UNIV_INLINE
|
|
|
|
|
ibool
|
|
|
|
|
pfs_os_file_read_func(
|
|
|
|
|
/*==================*/
|
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
void* buf, /*!< in: buffer where to read */
|
|
|
|
|
ulint offset, /*!< in: least significant 32 bits of file
|
|
|
|
|
offset where to read */
|
|
|
|
|
ulint offset_high,/*!< in: most significant 32 bits of
|
|
|
|
|
offset */
|
|
|
|
|
ulint n, /*!< in: number of bytes to read */
|
|
|
|
|
trx_t* trx,
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
|
|
|
|
|
/*******************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_file_read_no_error_handling(),
|
|
|
|
|
not directly this function!
|
|
|
|
|
This is the performance schema instrumented wrapper function for
|
|
|
|
|
os_file_read_no_error_handling_func() which requests a synchronous
|
|
|
|
|
read operation.
|
|
|
|
|
@return TRUE if request was successful, FALSE if fail */
|
|
|
|
|
UNIV_INLINE
|
|
|
|
|
ibool
|
|
|
|
|
pfs_os_file_read_no_error_handling_func(
|
|
|
|
|
/*====================================*/
|
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
void* buf, /*!< in: buffer where to read */
|
|
|
|
|
ulint offset, /*!< in: least significant 32 bits of file
|
|
|
|
|
offset where to read */
|
|
|
|
|
ulint offset_high,/*!< in: most significant 32 bits of
|
|
|
|
|
offset */
|
|
|
|
|
ulint n, /*!< in: number of bytes to read */
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
|
|
|
|
|
/*******************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_aio(), not directly this
|
|
|
|
|
function!
|
|
|
|
|
Performance schema wrapper function of os_aio() which requests
|
|
|
|
|
an asynchronous i/o operation.
|
|
|
|
|
@return TRUE if request was queued successfully, FALSE if fail */
|
|
|
|
|
UNIV_INLINE
|
|
|
|
|
ibool
|
|
|
|
|
pfs_os_aio_func(
|
|
|
|
|
/*============*/
|
|
|
|
|
ulint type, /*!< in: OS_FILE_READ or OS_FILE_WRITE */
|
|
|
|
|
ulint mode, /*!< in: OS_AIO_NORMAL etc. I/O mode */
|
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
|
|
|
|
null-terminated string */
|
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
void* buf, /*!< in: buffer where to read or from which
|
|
|
|
|
to write */
|
|
|
|
|
ulint offset, /*!< in: least significant 32 bits of file
|
|
|
|
|
offset where to read or write */
|
|
|
|
|
ulint offset_high,/*!< in: most significant 32 bits of
|
|
|
|
|
offset */
|
|
|
|
|
ulint n, /*!< in: number of bytes to read or write */
|
|
|
|
|
fil_node_t* message1,/*!< in: message for the aio handler
|
|
|
|
|
(can be used to identify a completed
|
|
|
|
|
aio operation); ignored if mode is
|
|
|
|
|
OS_AIO_SYNC */
|
|
|
|
|
void* message2,/*!< in: message for the aio handler
|
|
|
|
|
(can be used to identify a completed
|
|
|
|
|
aio operation); ignored if mode is
|
|
|
|
|
OS_AIO_SYNC */
|
|
|
|
|
ulint space_id,
|
|
|
|
|
trx_t* trx,
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
/*******************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_file_write(), not directly
|
|
|
|
|
this function!
|
|
|
|
|
This is the performance schema instrumented wrapper function for
|
|
|
|
|
os_file_write() which requests a synchronous write operation.
|
|
|
|
|
@return TRUE if request was successful, FALSE if fail */
|
|
|
|
|
UNIV_INLINE
|
|
|
|
|
ibool
|
|
|
|
|
pfs_os_file_write_func(
|
|
|
|
|
/*===================*/
|
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
|
|
|
|
null-terminated string */
|
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
const void* buf, /*!< in: buffer from which to write */
|
|
|
|
|
ulint offset, /*!< in: least significant 32 bits of file
|
|
|
|
|
offset where to write */
|
|
|
|
|
ulint offset_high,/*!< in: most significant 32 bits of
|
|
|
|
|
offset */
|
|
|
|
|
ulint n, /*!< in: number of bytes to write */
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_file_flush(), not directly
|
|
|
|
|
this function!
|
|
|
|
|
This is the performance schema instrumented wrapper function for
|
|
|
|
|
os_file_flush() which flushes the write buffers of a given file to the disk.
|
|
|
|
|
Flushes the write buffers of a given file to the disk.
|
|
|
|
|
@return TRUE if success */
|
|
|
|
|
UNIV_INLINE
|
|
|
|
|
ibool
|
|
|
|
|
pfs_os_file_flush_func(
|
|
|
|
|
/*===================*/
|
|
|
|
|
os_file_t file, /*!< in, own: handle to a file */
|
2011-07-17 11:28:48 +02:00
|
|
|
|
ibool metadata,
|
2011-07-14 21:22:41 +02:00
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
NOTE! Please use the corresponding macro os_file_rename(), not directly
|
|
|
|
|
this function!
|
|
|
|
|
This is the performance schema instrumented wrapper function for
|
|
|
|
|
os_file_rename()
|
|
|
|
|
@return TRUE if success */
|
|
|
|
|
UNIV_INLINE
|
|
|
|
|
ibool
|
|
|
|
|
pfs_os_file_rename_func(
|
|
|
|
|
/*====================*/
|
|
|
|
|
mysql_pfs_key_t key, /*!< in: Performance Schema Key */
|
|
|
|
|
const char* oldpath,/*!< in: old file path as a null-terminated
|
|
|
|
|
string */
|
|
|
|
|
const char* newpath,/*!< in: new file path */
|
|
|
|
|
const char* src_file,/*!< in: file name where func invoked */
|
|
|
|
|
ulint src_line);/*!< in: line where the func invoked */
|
|
|
|
|
#endif /* UNIV_PFS_IO */
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
#ifdef UNIV_HOTBACKUP
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Closes a file handle.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_close_no_error_handling(
|
|
|
|
|
/*============================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file); /*!< in, own: handle to a file */
|
|
|
|
|
#endif /* UNIV_HOTBACKUP */
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Gets a file size.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_get_size(
|
|
|
|
|
/*=============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
ulint* size, /*!< out: least significant 32 bits of file
|
2008-12-01 07:10:29 +01:00
|
|
|
|
size */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint* size_high);/*!< out: most significant 32 bits of size */
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Gets file size as a 64-bit integer ib_int64_t.
|
|
|
|
|
@return size in bytes, -1 if error */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ib_int64_t
|
|
|
|
|
os_file_get_size_as_iblonglong(
|
|
|
|
|
/*===========================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file); /*!< in: handle to a file */
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Write the specified number of zeros to a newly created file.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_set_size(
|
|
|
|
|
/*=============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
2008-12-01 07:10:29 +01:00
|
|
|
|
null-terminated string */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
ulint size, /*!< in: least significant 32 bits of file
|
2008-12-01 07:10:29 +01:00
|
|
|
|
size */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint size_high);/*!< in: most significant 32 bits of size */
|
|
|
|
|
/***********************************************************************//**
|
|
|
|
|
Truncates a file at its current position.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_set_eof(
|
|
|
|
|
/*============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
FILE* file); /*!< in: file to be truncated */
|
|
|
|
|
/***********************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_file_flush(), not directly this function!
|
2009-09-07 12:22:53 +02:00
|
|
|
|
Flushes the write buffers of a given file to the disk.
|
|
|
|
|
@return TRUE if success */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_flush_func(
|
|
|
|
|
/*===============*/
|
2011-07-17 11:28:48 +02:00
|
|
|
|
os_file_t file, /*!< in, own: handle to a file */
|
|
|
|
|
ibool metadata);
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/***********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Retrieves the last error number if an error occurs in a file io function.
|
|
|
|
|
The number should be retrieved before any other OS calls (because they may
|
|
|
|
|
overwrite the error number). If the number is not known to this program,
|
2009-09-07 12:22:53 +02:00
|
|
|
|
the OS error number + 100 is returned.
|
|
|
|
|
@return error number, or OS error number + 100 */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ulint
|
|
|
|
|
os_file_get_last_error(
|
|
|
|
|
/*===================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ibool report_all_errors); /*!< in: TRUE if we want an error message
|
2008-12-01 07:10:29 +01:00
|
|
|
|
printed of all errors */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/*******************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_file_read(), not directly this function!
|
2009-09-07 12:22:53 +02:00
|
|
|
|
Requests a synchronous read operation.
|
|
|
|
|
@return TRUE if request was successful, FALSE if fail */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_read_func(
|
|
|
|
|
/*==============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
void* buf, /*!< in: buffer where to read */
|
|
|
|
|
ulint offset, /*!< in: least significant 32 bits of file
|
2008-12-01 07:10:29 +01:00
|
|
|
|
offset where to read */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint offset_high,/*!< in: most significant 32 bits of
|
2008-12-01 07:10:29 +01:00
|
|
|
|
offset */
|
2009-11-04 21:11:12 +01:00
|
|
|
|
ulint n, /*!< in: number of bytes to read */
|
|
|
|
|
trx_t* trx);
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/*******************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Rewind file to its start, read at most size - 1 bytes from it to str, and
|
|
|
|
|
NUL-terminate str. All errors are silently ignored. This function is
|
|
|
|
|
mostly meant to be used with temporary files. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_file_read_string(
|
|
|
|
|
/*================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
FILE* file, /*!< in: file to read from */
|
|
|
|
|
char* str, /*!< in: buffer where to read */
|
|
|
|
|
ulint size); /*!< in: size of buffer */
|
|
|
|
|
/*******************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_file_read_no_error_handling(),
|
|
|
|
|
not directly this function!
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Requests a synchronous positioned read operation. This function does not do
|
2009-09-07 12:22:53 +02:00
|
|
|
|
any error handling. In case of error it returns FALSE.
|
|
|
|
|
@return TRUE if request was successful, FALSE if fail */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_read_no_error_handling_func(
|
|
|
|
|
/*================================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
void* buf, /*!< in: buffer where to read */
|
|
|
|
|
ulint offset, /*!< in: least significant 32 bits of file
|
2008-12-01 07:10:29 +01:00
|
|
|
|
offset where to read */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint offset_high,/*!< in: most significant 32 bits of
|
2008-12-01 07:10:29 +01:00
|
|
|
|
offset */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint n); /*!< in: number of bytes to read */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/*******************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_file_write(), not directly this
|
|
|
|
|
function!
|
2009-09-07 12:22:53 +02:00
|
|
|
|
Requests a synchronous write operation.
|
|
|
|
|
@return TRUE if request was successful, FALSE if fail */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_file_write_func(
|
|
|
|
|
/*===============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
2008-12-01 07:10:29 +01:00
|
|
|
|
null-terminated string */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
const void* buf, /*!< in: buffer from which to write */
|
|
|
|
|
ulint offset, /*!< in: least significant 32 bits of file
|
2008-12-01 07:10:29 +01:00
|
|
|
|
offset where to write */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint offset_high,/*!< in: most significant 32 bits of
|
2008-12-01 07:10:29 +01:00
|
|
|
|
offset */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint n); /*!< in: number of bytes to write */
|
|
|
|
|
/*******************************************************************//**
|
|
|
|
|
Check the existence and type of the given file.
|
|
|
|
|
@return TRUE if call succeeded */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_status(
|
|
|
|
|
/*===========*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* path, /*!< in: pathname of the file */
|
|
|
|
|
ibool* exists, /*!< out: TRUE if file exists */
|
|
|
|
|
os_file_type_t* type); /*!< out: type of the file (if it exists) */
|
|
|
|
|
/****************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
The function os_file_dirname returns a directory component of a
|
|
|
|
|
null-terminated pathname string. In the usual case, dirname returns
|
|
|
|
|
the string up to, but not including, the final '/', and basename
|
|
|
|
|
is the component following the final '/'. Trailing '/' charac<EFBFBD>
|
|
|
|
|
ters are not counted as part of the pathname.
|
|
|
|
|
|
|
|
|
|
If path does not contain a slash, dirname returns the string ".".
|
|
|
|
|
|
|
|
|
|
Concatenating the string returned by dirname, a "/", and the basename
|
|
|
|
|
yields a complete pathname.
|
|
|
|
|
|
|
|
|
|
The return value is a copy of the directory component of the pathname.
|
|
|
|
|
The copy is allocated from heap. It is the caller responsibility
|
|
|
|
|
to free it after it is no longer needed.
|
|
|
|
|
|
|
|
|
|
The following list of examples (taken from SUSv2) shows the strings
|
|
|
|
|
returned by dirname and basename for different paths:
|
|
|
|
|
|
|
|
|
|
path dirname basename
|
|
|
|
|
"/usr/lib" "/usr" "lib"
|
|
|
|
|
"/usr/" "/" "usr"
|
|
|
|
|
"usr" "." "usr"
|
|
|
|
|
"/" "/" "/"
|
|
|
|
|
"." "." "."
|
|
|
|
|
".." "." ".."
|
2009-09-07 12:22:53 +02:00
|
|
|
|
|
|
|
|
|
@return own: directory component of the pathname */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
char*
|
|
|
|
|
os_file_dirname(
|
|
|
|
|
/*============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* path); /*!< in: pathname */
|
|
|
|
|
/****************************************************************//**
|
|
|
|
|
Creates all missing subdirectories along the given path.
|
|
|
|
|
@return TRUE if call succeeded FALSE otherwise */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_create_subdirs_if_needed(
|
|
|
|
|
/*=============================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* path); /*!< in: path name */
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
Initializes the asynchronous io system. Creates one array each for ibuf
|
|
|
|
|
and log i/o. Also creates one array each for read and write where each
|
|
|
|
|
array is divided logically into n_read_segs and n_write_segs
|
|
|
|
|
respectively. The caller must create an i/o handler thread for each
|
|
|
|
|
segment in these arrays. This function also creates the sync array.
|
|
|
|
|
No i/o handler thread needs to be created for that */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
2011-07-14 21:22:41 +02:00
|
|
|
|
ibool
|
2008-12-01 07:10:29 +01:00
|
|
|
|
os_aio_init(
|
|
|
|
|
/*========*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint n_per_seg, /*<! in: maximum number of pending aio
|
|
|
|
|
operations allowed per segment */
|
|
|
|
|
ulint n_read_segs, /*<! in: number of reader threads */
|
|
|
|
|
ulint n_write_segs, /*<! in: number of writer threads */
|
|
|
|
|
ulint n_slots_sync); /*<! in: number of slots in the sync aio
|
|
|
|
|
array */
|
2010-01-06 13:00:14 +01:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
Frees the asynchronous io system. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_aio_free(void);
|
|
|
|
|
/*=============*/
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/*******************************************************************//**
|
2011-07-14 21:22:41 +02:00
|
|
|
|
NOTE! Use the corresponding macro os_aio(), not directly this function!
|
2009-09-07 12:22:53 +02:00
|
|
|
|
Requests an asynchronous i/o operation.
|
|
|
|
|
@return TRUE if request was queued successfully, FALSE if fail */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
2011-07-14 21:22:41 +02:00
|
|
|
|
os_aio_func(
|
|
|
|
|
/*========*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint type, /*!< in: OS_FILE_READ or OS_FILE_WRITE */
|
|
|
|
|
ulint mode, /*!< in: OS_AIO_NORMAL, ..., possibly ORed
|
2008-12-01 07:10:29 +01:00
|
|
|
|
to OS_AIO_SIMULATED_WAKE_LATER: the
|
|
|
|
|
last flag advises this function not to wake
|
|
|
|
|
i/o-handler threads, but the caller will
|
|
|
|
|
do the waking explicitly later, in this
|
|
|
|
|
way the caller can post several requests in
|
|
|
|
|
a batch; NOTE that the batch must not be
|
|
|
|
|
so big that it exhausts the slots in aio
|
|
|
|
|
arrays! NOTE that a simulated batch
|
|
|
|
|
may introduce hidden chances of deadlocks,
|
|
|
|
|
because i/os are not actually handled until
|
|
|
|
|
all have been posted: use with great
|
|
|
|
|
caution! */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* name, /*!< in: name of the file or path as a
|
2008-12-01 07:10:29 +01:00
|
|
|
|
null-terminated string */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
os_file_t file, /*!< in: handle to a file */
|
|
|
|
|
void* buf, /*!< in: buffer where to read or from which
|
2008-12-01 07:10:29 +01:00
|
|
|
|
to write */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint offset, /*!< in: least significant 32 bits of file
|
2008-12-01 07:10:29 +01:00
|
|
|
|
offset where to read or write */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint offset_high, /*!< in: most significant 32 bits of
|
2008-12-01 07:10:29 +01:00
|
|
|
|
offset */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint n, /*!< in: number of bytes to read or write */
|
|
|
|
|
fil_node_t* message1,/*!< in: message for the aio handler
|
|
|
|
|
(can be used to identify a completed
|
|
|
|
|
aio operation); ignored if mode is
|
|
|
|
|
OS_AIO_SYNC */
|
2009-11-04 21:11:12 +01:00
|
|
|
|
void* message2,/*!< in: message for the aio handler
|
2009-09-07 12:22:53 +02:00
|
|
|
|
(can be used to identify a completed
|
|
|
|
|
aio operation); ignored if mode is
|
|
|
|
|
OS_AIO_SYNC */
|
2011-04-29 14:49:04 +02:00
|
|
|
|
ulint space_id,
|
2009-11-04 21:11:12 +01:00
|
|
|
|
trx_t* trx);
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/************************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Wakes up all async i/o threads so that they know to exit themselves in
|
|
|
|
|
shutdown. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_aio_wake_all_threads_at_shutdown(void);
|
|
|
|
|
/*=====================================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/************************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Waits until there are no pending writes in os_aio_write_array. There can
|
|
|
|
|
be other, synchronous, pending writes. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_aio_wait_until_no_pending_writes(void);
|
|
|
|
|
/*=====================================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/**********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Wakes up simulated aio i/o-handler threads if they have something to do. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_aio_simulated_wake_handler_threads(void);
|
|
|
|
|
/*=======================================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/**********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
This function can be called if one wants to post a batch of reads and
|
|
|
|
|
prefers an i/o-handler thread to handle them all at once later. You must
|
|
|
|
|
call os_aio_simulated_wake_handler_threads later to ensure the threads
|
|
|
|
|
are not left sleeping! */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_aio_simulated_put_read_threads_to_sleep(void);
|
|
|
|
|
/*============================================*/
|
|
|
|
|
|
|
|
|
|
#ifdef WIN_ASYNC_IO
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/**********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
This function is only used in Windows asynchronous i/o.
|
|
|
|
|
Waits for an aio operation to complete. This function is used to wait the
|
|
|
|
|
for completed requests. The aio array of pending requests is divided
|
|
|
|
|
into segments. The thread specifies which segment or slot it wants to wait
|
|
|
|
|
for. NOTE: this function will also take care of freeing the aio slot,
|
2009-09-07 12:22:53 +02:00
|
|
|
|
therefore no other thread is allowed to do the freeing!
|
|
|
|
|
@return TRUE if the aio operation succeeded */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_aio_windows_handle(
|
|
|
|
|
/*==================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint segment, /*!< in: the number of the segment in the aio
|
2008-12-01 07:10:29 +01:00
|
|
|
|
arrays to wait for; segment 0 is the ibuf
|
|
|
|
|
i/o thread, segment 1 the log i/o thread,
|
|
|
|
|
then follow the non-ibuf read threads, and as
|
|
|
|
|
the last are the non-ibuf write threads; if
|
|
|
|
|
this is ULINT_UNDEFINED, then it means that
|
|
|
|
|
sync aio is used, and this parameter is
|
|
|
|
|
ignored */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint pos, /*!< this parameter is used only in sync aio:
|
2008-12-01 07:10:29 +01:00
|
|
|
|
wait for the aio slot at this position */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
fil_node_t**message1, /*!< out: the messages passed with the aio
|
2008-12-01 07:10:29 +01:00
|
|
|
|
request; note that also in the case where
|
|
|
|
|
the aio operation failed, these output
|
|
|
|
|
parameters are valid and can be used to
|
|
|
|
|
restart the operation, for example */
|
|
|
|
|
void** message2,
|
2011-04-29 14:49:04 +02:00
|
|
|
|
ulint* type, /*!< out: OS_FILE_WRITE or ..._READ */
|
|
|
|
|
ulint* space_id);
|
2008-12-01 07:10:29 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/**********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Does simulated aio. This function should be called by an i/o-handler
|
2009-09-07 12:22:53 +02:00
|
|
|
|
thread.
|
|
|
|
|
@return TRUE if the aio operation succeeded */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_aio_simulated_handle(
|
|
|
|
|
/*====================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
ulint segment, /*!< in: the number of the segment in the aio
|
2008-12-01 07:10:29 +01:00
|
|
|
|
arrays to wait for; segment 0 is the ibuf
|
|
|
|
|
i/o thread, segment 1 the log i/o thread,
|
|
|
|
|
then follow the non-ibuf read threads, and as
|
|
|
|
|
the last are the non-ibuf write threads */
|
2009-09-07 12:22:53 +02:00
|
|
|
|
fil_node_t**message1, /*!< out: the messages passed with the aio
|
2008-12-01 07:10:29 +01:00
|
|
|
|
request; note that also in the case where
|
|
|
|
|
the aio operation failed, these output
|
|
|
|
|
parameters are valid and can be used to
|
|
|
|
|
restart the operation, for example */
|
|
|
|
|
void** message2,
|
2011-04-29 14:49:04 +02:00
|
|
|
|
ulint* type, /*!< out: OS_FILE_WRITE or ..._READ */
|
|
|
|
|
ulint* space_id);
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/**********************************************************************//**
|
|
|
|
|
Validates the consistency of the aio system.
|
|
|
|
|
@return TRUE if ok */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_aio_validate(void);
|
|
|
|
|
/*=================*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/**********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Prints info of the aio arrays. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_aio_print(
|
|
|
|
|
/*=========*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
FILE* file); /*!< in: file where to print */
|
|
|
|
|
/**********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Refreshes the statistics used to print per-second averages. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
void
|
|
|
|
|
os_aio_refresh_stats(void);
|
|
|
|
|
/*======================*/
|
|
|
|
|
|
|
|
|
|
#ifdef UNIV_DEBUG
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/**********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Checks that all slots in the system have been freed, that is, there are
|
|
|
|
|
no pending io operations. */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_aio_all_slots_free(void);
|
|
|
|
|
/*=======================*/
|
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
|
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/*******************************************************************//**
|
|
|
|
|
This function returns information about the specified file
|
|
|
|
|
@return TRUE if stat information found */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_file_get_status(
|
|
|
|
|
/*===============*/
|
2009-09-07 12:22:53 +02:00
|
|
|
|
const char* path, /*!< in: pathname of the file */
|
|
|
|
|
os_file_stat_t* stat_info); /*!< information of a file in a
|
2008-12-01 07:10:29 +01:00
|
|
|
|
directory */
|
|
|
|
|
|
2011-07-14 21:22:41 +02:00
|
|
|
|
#if !defined(UNIV_HOTBACKUP)
|
2009-09-07 12:22:53 +02:00
|
|
|
|
/*********************************************************************//**
|
2008-12-01 07:10:29 +01:00
|
|
|
|
Creates a temporary file that will be deleted on close.
|
2009-09-07 12:22:53 +02:00
|
|
|
|
This function is defined in ha_innodb.cc.
|
|
|
|
|
@return temporary file descriptor, or < 0 on error */
|
2008-12-01 07:10:29 +01:00
|
|
|
|
UNIV_INTERN
|
|
|
|
|
int
|
|
|
|
|
innobase_mysql_tmpfile(void);
|
|
|
|
|
/*========================*/
|
2011-07-14 21:22:41 +02:00
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(LINUX_NATIVE_AIO)
|
|
|
|
|
/**************************************************************************
|
|
|
|
|
This function is only used in Linux native asynchronous i/o.
|
|
|
|
|
Waits for an aio operation to complete. This function is used to wait the
|
|
|
|
|
for completed requests. The aio array of pending requests is divided
|
|
|
|
|
into segments. The thread specifies which segment or slot it wants to wait
|
|
|
|
|
for. NOTE: this function will also take care of freeing the aio slot,
|
|
|
|
|
therefore no other thread is allowed to do the freeing!
|
|
|
|
|
@return TRUE if the IO was successful */
|
|
|
|
|
UNIV_INTERN
|
|
|
|
|
ibool
|
|
|
|
|
os_aio_linux_handle(
|
|
|
|
|
/*================*/
|
|
|
|
|
ulint global_seg, /*!< in: segment number in the aio array
|
|
|
|
|
to wait for; segment 0 is the ibuf
|
|
|
|
|
i/o thread, segment 1 is log i/o thread,
|
|
|
|
|
then follow the non-ibuf read threads,
|
|
|
|
|
and the last are the non-ibuf write
|
|
|
|
|
threads. */
|
|
|
|
|
fil_node_t**message1, /*!< out: the messages passed with the */
|
|
|
|
|
void** message2, /*!< aio request; note that in case the
|
|
|
|
|
aio operation failed, these output
|
|
|
|
|
parameters are valid and can be used to
|
|
|
|
|
restart the operation. */
|
|
|
|
|
ulint* type, /*!< out: OS_FILE_WRITE or ..._READ */
|
|
|
|
|
ulint* space_id);
|
|
|
|
|
#endif /* LINUX_NATIVE_AIO */
|
|
|
|
|
|
|
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
|
#include "os0file.ic"
|
|
|
|
|
#endif
|
2008-12-01 07:10:29 +01:00
|
|
|
|
|
|
|
|
|
#endif
|