mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 20:11:42 +01:00
2db645141c
------------------------------------------------------------------------ r6521 | marko | 2010-01-27 10:49:01 +0200 (Wed, 27 Jan 2010) | 17 lines branches/zip: Drop temporary tables at startup. This addresses the third aspect of Bug #41609. row_mysql_drop_temp_tables(): New function, to drop all temporary tables. These can be distinguished by the least significant bit of MIX_LEN. However, we will skip ROW_FORMAT=REDUNDANT tables, because in the records for those tables, that bit may be garbage. recv_recovery_from_checkpoint_finish(): Invoke row_mysql_drop_temp_tables(). Normally, if the .frm files for the temporary tables exist at startup, MySQL will ask InnoDB to drop the temporary tables. However, if the files are deleted, for instance, by the boot scripts of the operating system, the tables would remain in the InnoDB data dictionary unless someone digs them up by innodb_table_monitor and creates .frm files for dropping the tables. rb://221 approved by Sunny Bains. ------------------------------------------------------------------------ r6525 | marko | 2010-01-28 16:23:15 +0200 (Thu, 28 Jan 2010) | 11 lines branches/zip: buf_LRU_invalidate_tablespace(): Do not unnecessarily acquire the block_mutex for every block in the LRU list. Only acquire it when holding buf_pool_mutex is not sufficient. This should speed up the function and considerably reduce traffic on the memory bus and caches. I noticed this deficiency when working on Issue #157. This deficiency popped up again in Issue #449 (Bug #35077), which this fix does not fully address. rb://78 revision 1 approved by Heikki Tuuri. ------------------------------------------------------------------------ r6526 | jyang | 2010-01-28 18:12:40 +0200 (Thu, 28 Jan 2010) | 8 lines branches/zip: Add index translation table to map mysql index number to InnoDB index structure directly. Fix Bug #47622: "the new index is added before the existing ones in MySQL, but after one in SE". rb://215, approved by Marko ------------------------------------------------------------------------ r6527 | vasil | 2010-01-29 14:39:48 +0200 (Fri, 29 Jan 2010) | 6 lines branches/zip: Extend the comment about row_mysql_handle_errors(). Suggested by: Heikki ------------------------------------------------------------------------ r6533 | calvin | 2010-01-29 23:31:59 +0200 (Fri, 29 Jan 2010) | 4 lines branches/zip: remove duplicated copyright and license info. ------------------------------------------------------------------------ r6534 | sunny | 2010-01-29 23:42:49 +0200 (Fri, 29 Jan 2010) | 15 lines branches/zip: Two changes to fix the problem: 1. First scan the joining transaction's locks and check if no other transaction is waiting for a lock held by the joining transaction. If no other transaction is waiting then no deadlock an occur and we avoid doing an exhaustive search. 2. Change the direction of the lock traversal from backward to forward. Previously we traversed backward from the lock that has to wait, the function to that fetched the previous node was very inefficient resulting in O(n^2) access to the rec lock list. Fix Bug #49047 InnoDB deadlock detection is CPU intensive with many locks on a single row. rb://218 ------------------------------------------------------------------------ r6539 | marko | 2010-02-01 11:31:12 +0200 (Mon, 01 Feb 2010) | 75 lines branches/zip: Merge revisions 6471:6538 from branches/5.1: ------------------------------------------------------------------------ r6488 | sunny | 2010-01-21 02:55:08 +0200 (Thu, 21 Jan 2010) | 2 lines Changed paths: M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Factor out test for bug#44030 from innodb-autoinc.test into a separate test/result files. ------------------------------------------------------------------------ r6489 | sunny | 2010-01-21 02:57:50 +0200 (Thu, 21 Jan 2010) | 2 lines Changed paths: A /branches/5.1/mysql-test/innodb-autoinc-44030.result A /branches/5.1/mysql-test/innodb-autoinc-44030.test branches/5.1: Factor out test for bug#44030 from innodb-autoinc.test into a separate test/result files. ------------------------------------------------------------------------ r6492 | sunny | 2010-01-21 09:38:35 +0200 (Thu, 21 Jan 2010) | 1 line Changed paths: M /branches/5.1/mysql-test/innodb-autoinc-44030.test branches/5.1: Add reference to bug#47621 in the comment. ------------------------------------------------------------------------ r6535 | sunny | 2010-01-30 00:08:40 +0200 (Sat, 30 Jan 2010) | 11 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc branches/5.1: Undo the change from r6424. We need to return DB_SUCCESS even if we were unable to initialize the tabe autoinc value. This is required for the open to succeed. The only condition we currently treat as a hard error is if the autoinc field instance passed in by MySQL is NULL. Previously if the table autoinc value was 0 and the next value was requested we had an assertion that would fail. Change that assertion and treat a value of 0 to mean that the autoinc system is unavailable. Generation of next value will now return failure. rb://237 ------------------------------------------------------------------------ r6536 | sunny | 2010-01-30 00:13:42 +0200 (Sat, 30 Jan 2010) | 6 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Check *first_value everytime against the column max value and set *first_value to next autoinc if it's > col max value. ie. not rely on what is passed in from MySQL. [49497] Error 1467 (ER_AUTOINC_READ_FAILED) on inserting a negative value rb://236 ------------------------------------------------------------------------ r6537 | sunny | 2010-01-30 00:35:00 +0200 (Sat, 30 Jan 2010) | 2 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Undo r6536. ------------------------------------------------------------------------ r6538 | sunny | 2010-01-30 00:43:06 +0200 (Sat, 30 Jan 2010) | 6 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Check *first_value every time against the column max value and set *first_value to next autoinc if it's > col max value. ie. not rely on what is passed in from MySQL. [49497] Error 1467 (ER_AUTOINC_READ_FAILED) on inserting a negative value rb://236 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r6540 | marko | 2010-02-01 11:35:13 +0200 (Mon, 01 Feb 2010) | 1 line branches/zip: ChangeLog: Document the merge of 6471:6538 from branches/5.1. ------------------------------------------------------------------------ r6546 | jyang | 2010-02-03 11:05:24 +0200 (Wed, 03 Feb 2010) | 9 lines branches/zip: Relax assertion on the number of index defined in InnoDB must be comparable with that of MySQL to tolerate possible dictionary inconsistency. Fix Mantis issue #455, "UNIV_DEBUG+ assert ha_innodb.cc:3152 ib_num_index >= mysql_num_index". rb://248 Approved by Marko. ------------------------------------------------------------------------ r6547 | marko | 2010-02-03 14:43:38 +0200 (Wed, 03 Feb 2010) | 14 lines branches/zip: Clean up CHECK TABLE error handling. (Issue #220) ha_innobase::change_active_index(): Clean up code formatting. ha_innobase::check(): Incorporate the code from row_check_table_for_mysql(). Report errors to the client connection instead of writing them to the error log. row_check_table_for_mysql(): Remove. row_check_index_for_mysql(): Renamed from row_scan_and_check_index(). Let the caller initialize prebuilt, and assume that the index is usable. rb://178 approved by Sunny Bains ------------------------------------------------------------------------ r6548 | marko | 2010-02-03 15:01:39 +0200 (Wed, 03 Feb 2010) | 11 lines branches/zip: buf_LRU_invalidate_tablespace(): Ensure that prev_bpage is not relocated when freeing a compressed block. This avoids the costly rescan of the LRU list. (Bug #35077, Issue #449) At most one buffer-fix will be active at a time, affecting two blocks: the buf_page_t and the compressed page frame. This should not block the memory defragmentation in buf0buddy.c too much. In fact, it may avoid unnecessary copying if also prev_bpage belongs to the tablespace that is being invalidated. rb://240 ------------------------------------------------------------------------ r6559 | marko | 2010-02-04 13:21:18 +0200 (Thu, 04 Feb 2010) | 14 lines branches/zip: Pass the file name and line number of the caller of the b-tree cursor functions to the buffer pool requests, in order to make the latch diagnostics more accurate. buf_page_optimistic_get_func(): Renamed to buf_page_optimistic_get(). btr_page_get_father_node_ptr(), btr_insert_on_non_leaf_level(), btr_pcur_open(), btr_pcur_open_with_no_init(), btr_pcur_open_on_user_rec(), btr_pcur_open_at_rnd_pos(), btr_pcur_restore_position(), btr_cur_open_at_index_side(), btr_cur_open_at_rnd_pos(): Rename the function to _func and add the parameters file, line. Define wrapper macros with __FILE__, __LINE__. btr_cur_search_to_nth_level(): Add the parameters file, line. ------------------------------------------------------------------------ r6560 | sunny | 2010-02-04 16:11:23 +0200 (Thu, 04 Feb 2010) | 7 lines branches/zip: Remove the additional check introduced in r6534 which tries to check if the joining transaction has any other transactions waiting on its locks. This optimization results in excessive deadlocks when running Sysbench with a large number of threads. The function seems to return FALSE positives. rb://250 ------------------------------------------------------------------------
811 lines
30 KiB
C
811 lines
30 KiB
C
/***********************************************************************
|
||
|
||
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
||
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.
|
||
|
||
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
|
||
The interface to the operating system file io
|
||
|
||
Created 10/21/1995 Heikki Tuuri
|
||
*******************************************************/
|
||
|
||
#ifndef os0file_h
|
||
#define os0file_h
|
||
|
||
#include "univ.i"
|
||
|
||
#ifndef __WIN__
|
||
#include <dirent.h>
|
||
#include <sys/stat.h>
|
||
#include <time.h>
|
||
#endif
|
||
|
||
/** File node of a tablespace or the log data space */
|
||
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;
|
||
/** Flag: enable debug printout for asynchronous i/o */
|
||
extern ibool os_aio_print_debug;
|
||
|
||
/** Number of pending os_file_pread() operations */
|
||
extern ulint os_file_n_pending_preads;
|
||
/** Number of pending os_file_pwrite() operations */
|
||
extern ulint os_file_n_pending_pwrites;
|
||
|
||
/** Number of pending read operations */
|
||
extern ulint os_n_pending_reads;
|
||
/** Number of pending write operations */
|
||
extern ulint os_n_pending_writes;
|
||
|
||
#ifdef __WIN__
|
||
|
||
/** We define always WIN_ASYNC_IO, and check at run-time whether
|
||
the OS actually supports it: Win 95 does not, NT does. */
|
||
#define WIN_ASYNC_IO
|
||
|
||
/** Use unbuffered I/O */
|
||
#define UNIV_NON_BUFFERED_IO
|
||
|
||
#endif
|
||
|
||
#ifdef __WIN__
|
||
/** File handle */
|
||
#define os_file_t HANDLE
|
||
/** Convert a C file descriptor to a native file handle
|
||
@param fd file descriptor
|
||
@return native file handle */
|
||
#define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
|
||
#else
|
||
/** File handle */
|
||
typedef int os_file_t;
|
||
/** Convert a C file descriptor to a native file handle
|
||
@param fd file descriptor
|
||
@return native file handle */
|
||
#define OS_FILE_FROM_FD(fd) fd
|
||
#endif
|
||
|
||
/** Umask for creating files */
|
||
extern ulint os_innodb_umask;
|
||
|
||
/** 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
|
||
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. */
|
||
|
||
#define OS_FILE_LOG_BLOCK_SIZE 512
|
||
|
||
/** Options for file_create @{ */
|
||
#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
|
||
/* @} */
|
||
|
||
/** Types for file create @{ */
|
||
#define OS_DATA_FILE 100
|
||
#define OS_LOG_FILE 101
|
||
/* @} */
|
||
|
||
/** Error codes from os_file_get_last_error @{ */
|
||
#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
|
||
#define OS_FILE_INSUFFICIENT_RESOURCE 78
|
||
#define OS_FILE_AIO_INTERRUPTED 79
|
||
#define OS_FILE_OPERATION_ABORTED 80
|
||
/* @} */
|
||
|
||
/** Types for aio operations @{ */
|
||
#define OS_FILE_READ 10
|
||
#define OS_FILE_WRITE 11
|
||
|
||
#define OS_FILE_LOG 256 /* This can be ORed to type */
|
||
/* @} */
|
||
|
||
#define OS_AIO_N_PENDING_IOS_PER_THREAD 32 /*!< Win NT does not allow more
|
||
than 64 */
|
||
|
||
/** Modes for aio operations @{ */
|
||
#define OS_AIO_NORMAL 21 /*!< Normal asynchronous i/o not for ibuf
|
||
pages or ibuf bitmap pages */
|
||
#define OS_AIO_IBUF 22 /*!< Asynchronous i/o for ibuf pages or ibuf
|
||
bitmap pages */
|
||
#define OS_AIO_LOG 23 /*!< Asynchronous i/o for the log */
|
||
#define OS_AIO_SYNC 24 /*!< Asynchronous i/o where the calling thread
|
||
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. */
|
||
|
||
#define OS_AIO_SIMULATED_WAKE_LATER 512 /*!< This can be ORed to mode
|
||
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 */
|
||
/* @} */
|
||
|
||
#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 */
|
||
|
||
extern ulint os_n_file_reads;
|
||
extern ulint os_n_file_writes;
|
||
extern ulint os_n_fsyncs;
|
||
|
||
/* 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{
|
||
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 */
|
||
};
|
||
typedef struct os_file_stat_struct os_file_stat_t;
|
||
|
||
#ifdef __WIN__
|
||
typedef HANDLE os_file_dir_t; /*!< directory stream */
|
||
#else
|
||
typedef DIR* os_file_dir_t; /*!< directory stream */
|
||
#endif
|
||
|
||
/***********************************************************************//**
|
||
Gets the operating system version. Currently works only on Windows.
|
||
@return OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */
|
||
UNIV_INTERN
|
||
ulint
|
||
os_get_os_version(void);
|
||
/*===================*/
|
||
#ifndef UNIV_HOTBACKUP
|
||
/****************************************************************//**
|
||
Creates the seek mutexes used in positioned reads and writes. */
|
||
UNIV_INTERN
|
||
void
|
||
os_io_init_simple(void);
|
||
/*===================*/
|
||
/***********************************************************************//**
|
||
Creates a temporary file. This function is like tmpfile(3), but
|
||
the temporary file is created in the MySQL temporary directory.
|
||
On Netware, this function is like tmpfile(3), because the C run-time
|
||
library of Netware does not expose the delete-on-close flag.
|
||
@return temporary file handle, or NULL on error */
|
||
|
||
FILE*
|
||
os_file_create_tmpfile(void);
|
||
/*========================*/
|
||
#endif /* !UNIV_HOTBACKUP */
|
||
/***********************************************************************//**
|
||
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 '.'
|
||
and '..' items at the start of the directory listing.
|
||
@return directory stream, NULL if error */
|
||
UNIV_INTERN
|
||
os_file_dir_t
|
||
os_file_opendir(
|
||
/*============*/
|
||
const char* dirname, /*!< in: directory name; it must not
|
||
contain a trailing '\' or '/' */
|
||
ibool error_is_fatal);/*!< in: TRUE if we should treat an
|
||
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 */
|
||
/***********************************************************************//**
|
||
Closes a directory stream.
|
||
@return 0 if success, -1 if failure */
|
||
UNIV_INTERN
|
||
int
|
||
os_file_closedir(
|
||
/*=============*/
|
||
os_file_dir_t dir); /*!< in: directory stream */
|
||
/***********************************************************************//**
|
||
This function returns information of the next file in the directory. We jump
|
||
over the '.' and '..' entries in the directory.
|
||
@return 0 if ok, -1 if error, 1 if at the end of the directory */
|
||
UNIV_INTERN
|
||
int
|
||
os_file_readdir_next_file(
|
||
/*======================*/
|
||
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 */
|
||
/*****************************************************************//**
|
||
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
|
||
fail_if_exists arguments is true.
|
||
@return TRUE if call succeeds, FALSE on error */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_create_directory(
|
||
/*=====================*/
|
||
const char* pathname, /*!< in: directory name as
|
||
null-terminated string */
|
||
ibool fail_if_exists);/*!< in: if TRUE, pre-existing directory
|
||
is treated as an error. */
|
||
/****************************************************************//**
|
||
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 */
|
||
UNIV_INTERN
|
||
os_file_t
|
||
os_file_create_simple(
|
||
/*==================*/
|
||
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 */
|
||
/****************************************************************//**
|
||
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 */
|
||
UNIV_INTERN
|
||
os_file_t
|
||
os_file_create_simple_no_error_handling(
|
||
/*====================================*/
|
||
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 */
|
||
/****************************************************************//**
|
||
Tries to disable OS caching on an opened file descriptor. */
|
||
UNIV_INTERN
|
||
void
|
||
os_file_set_nocache(
|
||
/*================*/
|
||
int fd, /*!< in: file descriptor to alter */
|
||
const char* file_name, /*!< in: file name, used in the
|
||
diagnostic message */
|
||
const char* operation_name);/*!< in: "open" or "create"; used in the
|
||
diagnostic message */
|
||
/****************************************************************//**
|
||
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 */
|
||
UNIV_INTERN
|
||
os_file_t
|
||
os_file_create(
|
||
/*===========*/
|
||
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 */
|
||
/***********************************************************************//**
|
||
Deletes a file. The file has to be closed before calling this.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_delete(
|
||
/*===========*/
|
||
const char* name); /*!< in: file path as a null-terminated string */
|
||
|
||
/***********************************************************************//**
|
||
Deletes a file if it exists. The file has to be closed before calling this.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_delete_if_exists(
|
||
/*=====================*/
|
||
const char* name); /*!< in: file path as a null-terminated string */
|
||
/***********************************************************************//**
|
||
Renames a file (can also move it to another directory). It is safest that the
|
||
file is closed before calling this function.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_rename(
|
||
/*===========*/
|
||
const char* oldpath, /*!< in: old file path as a
|
||
null-terminated string */
|
||
const char* newpath); /*!< in: new file path */
|
||
/***********************************************************************//**
|
||
Closes a file handle. In case of error, error number can be retrieved with
|
||
os_file_get_last_error.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_close(
|
||
/*==========*/
|
||
os_file_t file); /*!< in, own: handle to a file */
|
||
#ifdef UNIV_HOTBACKUP
|
||
/***********************************************************************//**
|
||
Closes a file handle.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_close_no_error_handling(
|
||
/*============================*/
|
||
os_file_t file); /*!< in, own: handle to a file */
|
||
#endif /* UNIV_HOTBACKUP */
|
||
/***********************************************************************//**
|
||
Gets a file size.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_get_size(
|
||
/*=============*/
|
||
os_file_t file, /*!< in: handle to a file */
|
||
ulint* size, /*!< out: least significant 32 bits of file
|
||
size */
|
||
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 */
|
||
UNIV_INTERN
|
||
ib_int64_t
|
||
os_file_get_size_as_iblonglong(
|
||
/*===========================*/
|
||
os_file_t file); /*!< in: handle to a file */
|
||
/***********************************************************************//**
|
||
Write the specified number of zeros to a newly created file.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_set_size(
|
||
/*=============*/
|
||
const char* name, /*!< in: name of the file or path as a
|
||
null-terminated string */
|
||
os_file_t file, /*!< in: handle to a file */
|
||
ulint size, /*!< in: least significant 32 bits of file
|
||
size */
|
||
ulint size_high);/*!< in: most significant 32 bits of size */
|
||
/***********************************************************************//**
|
||
Truncates a file at its current position.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_set_eof(
|
||
/*============*/
|
||
FILE* file); /*!< in: file to be truncated */
|
||
/***********************************************************************//**
|
||
Flushes the write buffers of a given file to the disk.
|
||
@return TRUE if success */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_flush(
|
||
/*==========*/
|
||
os_file_t file); /*!< in, own: handle to a file */
|
||
/***********************************************************************//**
|
||
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,
|
||
the OS error number + 100 is returned.
|
||
@return error number, or OS error number + 100 */
|
||
UNIV_INTERN
|
||
ulint
|
||
os_file_get_last_error(
|
||
/*===================*/
|
||
ibool report_all_errors); /*!< in: TRUE if we want an error message
|
||
printed of all errors */
|
||
/*******************************************************************//**
|
||
Requests a synchronous read operation.
|
||
@return TRUE if request was successful, FALSE if fail */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_read(
|
||
/*=========*/
|
||
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 */
|
||
/*******************************************************************//**
|
||
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(
|
||
/*================*/
|
||
FILE* file, /*!< in: file to read from */
|
||
char* str, /*!< in: buffer where to read */
|
||
ulint size); /*!< in: size of buffer */
|
||
/*******************************************************************//**
|
||
Requests a synchronous positioned read operation. This function does not do
|
||
any error handling. In case of error it returns FALSE.
|
||
@return TRUE if request was successful, FALSE if fail */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_read_no_error_handling(
|
||
/*===========================*/
|
||
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 */
|
||
|
||
/*******************************************************************//**
|
||
Requests a synchronous write operation.
|
||
@return TRUE if request was successful, FALSE if fail */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_write(
|
||
/*==========*/
|
||
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 */
|
||
/*******************************************************************//**
|
||
Check the existence and type of the given file.
|
||
@return TRUE if call succeeded */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_status(
|
||
/*===========*/
|
||
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) */
|
||
/****************************************************************//**
|
||
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<61>
|
||
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"
|
||
"/" "/" "/"
|
||
"." "." "."
|
||
".." "." ".."
|
||
|
||
@return own: directory component of the pathname */
|
||
UNIV_INTERN
|
||
char*
|
||
os_file_dirname(
|
||
/*============*/
|
||
const char* path); /*!< in: pathname */
|
||
/****************************************************************//**
|
||
Creates all missing subdirectories along the given path.
|
||
@return TRUE if call succeeded FALSE otherwise */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_create_subdirs_if_needed(
|
||
/*=============================*/
|
||
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 */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_aio_init(
|
||
/*========*/
|
||
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 */
|
||
/***********************************************************************
|
||
Frees the asynchronous io system. */
|
||
UNIV_INTERN
|
||
void
|
||
os_aio_free(void);
|
||
/*=============*/
|
||
|
||
/*******************************************************************//**
|
||
Requests an asynchronous i/o operation.
|
||
@return TRUE if request was queued successfully, FALSE if fail */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_aio(
|
||
/*===*/
|
||
ulint type, /*!< in: OS_FILE_READ or OS_FILE_WRITE */
|
||
ulint mode, /*!< in: OS_AIO_NORMAL, ..., possibly ORed
|
||
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! */
|
||
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 */
|
||
/************************************************************************//**
|
||
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);
|
||
/*=====================================*/
|
||
/************************************************************************//**
|
||
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);
|
||
/*=====================================*/
|
||
/**********************************************************************//**
|
||
Wakes up simulated aio i/o-handler threads if they have something to do. */
|
||
UNIV_INTERN
|
||
void
|
||
os_aio_simulated_wake_handler_threads(void);
|
||
/*=======================================*/
|
||
/**********************************************************************//**
|
||
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
|
||
/**********************************************************************//**
|
||
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,
|
||
therefore no other thread is allowed to do the freeing!
|
||
@return TRUE if the aio operation succeeded */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_aio_windows_handle(
|
||
/*==================*/
|
||
ulint segment, /*!< in: the number of the segment in the aio
|
||
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 */
|
||
ulint pos, /*!< this parameter is used only in sync aio:
|
||
wait for the aio slot at this position */
|
||
fil_node_t**message1, /*!< out: the messages passed with the aio
|
||
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,
|
||
ulint* type); /*!< out: OS_FILE_WRITE or ..._READ */
|
||
#endif
|
||
|
||
/**********************************************************************//**
|
||
Does simulated aio. This function should be called by an i/o-handler
|
||
thread.
|
||
@return TRUE if the aio operation succeeded */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_aio_simulated_handle(
|
||
/*====================*/
|
||
ulint segment, /*!< in: the number of the segment in the aio
|
||
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 */
|
||
fil_node_t**message1, /*!< out: the messages passed with the aio
|
||
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,
|
||
ulint* type); /*!< out: OS_FILE_WRITE or ..._READ */
|
||
/**********************************************************************//**
|
||
Validates the consistency of the aio system.
|
||
@return TRUE if ok */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_aio_validate(void);
|
||
/*=================*/
|
||
/**********************************************************************//**
|
||
Prints info of the aio arrays. */
|
||
UNIV_INTERN
|
||
void
|
||
os_aio_print(
|
||
/*=========*/
|
||
FILE* file); /*!< in: file where to print */
|
||
/**********************************************************************//**
|
||
Refreshes the statistics used to print per-second averages. */
|
||
UNIV_INTERN
|
||
void
|
||
os_aio_refresh_stats(void);
|
||
/*======================*/
|
||
|
||
#ifdef UNIV_DEBUG
|
||
/**********************************************************************//**
|
||
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 */
|
||
|
||
/*******************************************************************//**
|
||
This function returns information about the specified file
|
||
@return TRUE if stat information found */
|
||
UNIV_INTERN
|
||
ibool
|
||
os_file_get_status(
|
||
/*===============*/
|
||
const char* path, /*!< in: pathname of the file */
|
||
os_file_stat_t* stat_info); /*!< information of a file in a
|
||
directory */
|
||
|
||
#if !defined(UNIV_HOTBACKUP) && !defined(__NETWARE__)
|
||
/*********************************************************************//**
|
||
Creates a temporary file that will be deleted on close.
|
||
This function is defined in ha_innodb.cc.
|
||
@return temporary file descriptor, or < 0 on error */
|
||
UNIV_INTERN
|
||
int
|
||
innobase_mysql_tmpfile(void);
|
||
/*========================*/
|
||
#endif /* !UNIV_HOTBACKUP && !__NETWARE__ */
|
||
|
||
|
||
#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 */
|
||
#endif /* LINUX_NATIVE_AIO */
|
||
|
||
#endif
|