MDEV-12534 Use atomic operations whenever available
Allow 64-bit atomic operations on 32-bit systems, only relying on HAVE_ATOMIC_BUILTINS_64, disregarding the width of the register file. Define UNIV_WORD_SIZE correctly on all systems, including Windows. In MariaDB 10.0 and 10.1, it was incorrectly defined as 4 on 64-bit Windows. Define HAVE_ATOMIC_BUILTINS_64 on Windows (64-bit atomics are available on both 32-bit and 64-bit Windows platforms; the operations were unnecessarily disabled even on 64-bit Windows). MONITOR_OS_PENDING_READS, MONITOR_OS_PENDING_WRITES: Enable by default. os_file_n_pending_preads, os_file_n_pending_pwrites, os_n_pending_reads, os_n_pending_writes: Remove. Use the monitor counters instead. os_file_count_mutex: Remove. On a system that does not support 64-bit atomics, monitor_mutex will be used instead.
This commit is contained in:
parent
88613e1df6
commit
d34a67b067
@ -881,15 +881,11 @@ buf_read_recv_pages(
|
|||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count > 1000) {
|
if (count > 1000) {
|
||||||
fprintf(stderr,
|
ib_logf(IB_LOG_LEVEL_ERROR,
|
||||||
"InnoDB: Error: InnoDB has waited for"
|
"waited for 10 seconds for " ULINTPF
|
||||||
" 10 seconds for pending\n"
|
" pending reads to the buffer pool to"
|
||||||
"InnoDB: reads to the buffer pool to"
|
" be finished",
|
||||||
" be finished.\n"
|
buf_pool->n_pend_reads);
|
||||||
"InnoDB: Number of pending reads %lu,"
|
|
||||||
" pending pread calls %lu\n",
|
|
||||||
(ulong) buf_pool->n_pend_reads,
|
|
||||||
(ulong) os_file_n_pending_preads);
|
|
||||||
|
|
||||||
os_aio_print_debug = TRUE;
|
os_aio_print_debug = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2009, Percona Inc.
|
Copyright (c) 2009, Percona Inc.
|
||||||
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
|
Copyright (c) 2013, 2017, MariaDB Corporation.
|
||||||
|
|
||||||
Portions of this file contain modifications contributed and copyrighted
|
Portions of this file contain modifications contributed and copyrighted
|
||||||
by Percona Inc.. Those modifications are
|
by Percona Inc.. Those modifications are
|
||||||
@ -51,16 +51,6 @@ extern ibool os_has_said_disk_full;
|
|||||||
/** Flag: enable debug printout for asynchronous i/o */
|
/** Flag: enable debug printout for asynchronous i/o */
|
||||||
extern ibool os_aio_print_debug;
|
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__
|
#ifdef __WIN__
|
||||||
|
|
||||||
/** We define always WIN_ASYNC_IO, and check at run-time whether
|
/** We define always WIN_ASYNC_IO, and check at run-time whether
|
||||||
|
@ -667,10 +667,7 @@ os_atomic_clear(volatile lock_word_t* ptr)
|
|||||||
|
|
||||||
# define HAVE_ATOMIC_BUILTINS
|
# define HAVE_ATOMIC_BUILTINS
|
||||||
# define HAVE_ATOMIC_BUILTINS_BYTE
|
# define HAVE_ATOMIC_BUILTINS_BYTE
|
||||||
|
|
||||||
# ifndef _WIN32
|
|
||||||
# define HAVE_ATOMIC_BUILTINS_64
|
# define HAVE_ATOMIC_BUILTINS_64
|
||||||
# endif
|
|
||||||
|
|
||||||
/**********************************************************//**
|
/**********************************************************//**
|
||||||
Atomic compare and exchange of signed integers (both 32 and 64 bit).
|
Atomic compare and exchange of signed integers (both 32 and 64 bit).
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2012, Facebook Inc.
|
Copyright (c) 2012, Facebook Inc.
|
||||||
|
Copyright (c) 2017, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
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
|
under the terms of the GNU General Public License as published by the
|
||||||
@ -541,22 +542,30 @@ on the counters */
|
|||||||
|
|
||||||
/** Increment a monitor counter under mutex protection.
|
/** Increment a monitor counter under mutex protection.
|
||||||
Use MONITOR_INC if appropriate mutex protection already exists.
|
Use MONITOR_INC if appropriate mutex protection already exists.
|
||||||
|
@param mutex mutex to acquire and release
|
||||||
@param monitor monitor to be incremented by 1
|
@param monitor monitor to be incremented by 1
|
||||||
@param mutex mutex to acquire and relese */
|
@param enabled whether the monitor is enabled */
|
||||||
# define MONITOR_MUTEX_INC(mutex, monitor) \
|
#define MONITOR_MUTEX_INC_LOW(mutex, monitor, enabled) \
|
||||||
ut_ad(!mutex_own(mutex)); \
|
ut_ad(!mutex_own(mutex)); \
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
if (enabled) { \
|
||||||
mutex_enter(mutex); \
|
mutex_enter(mutex); \
|
||||||
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
|
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
|
||||||
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
|
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
|
||||||
} \
|
} \
|
||||||
mutex_exit(mutex); \
|
mutex_exit(mutex); \
|
||||||
}
|
}
|
||||||
|
/** Increment a monitor counter under mutex protection.
|
||||||
|
Use MONITOR_INC if appropriate mutex protection already exists.
|
||||||
|
@param mutex mutex to acquire and release
|
||||||
|
@param monitor monitor to be incremented by 1 */
|
||||||
|
#define MONITOR_MUTEX_INC(mutex, monitor) \
|
||||||
|
MONITOR_MUTEX_INC_LOW(mutex, monitor, MONITOR_IS_ON(monitor))
|
||||||
/** Decrement a monitor counter under mutex protection.
|
/** Decrement a monitor counter under mutex protection.
|
||||||
Use MONITOR_DEC if appropriate mutex protection already exists.
|
Use MONITOR_DEC if appropriate mutex protection already exists.
|
||||||
|
@param mutex mutex to acquire and release
|
||||||
@param monitor monitor to be decremented by 1
|
@param monitor monitor to be decremented by 1
|
||||||
@param mutex mutex to acquire and relese */
|
@param enabled whether the monitor is enabled */
|
||||||
# define MONITOR_MUTEX_DEC(mutex, monitor) \
|
#define MONITOR_MUTEX_DEC_LOW(mutex, monitor, enabled) \
|
||||||
ut_ad(!mutex_own(mutex)); \
|
ut_ad(!mutex_own(mutex)); \
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
if (MONITOR_IS_ON(monitor)) { \
|
||||||
mutex_enter(mutex); \
|
mutex_enter(mutex); \
|
||||||
@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists.
|
|||||||
} \
|
} \
|
||||||
mutex_exit(mutex); \
|
mutex_exit(mutex); \
|
||||||
}
|
}
|
||||||
|
/** Decrement a monitor counter under mutex protection.
|
||||||
|
Use MONITOR_DEC if appropriate mutex protection already exists.
|
||||||
|
@param mutex mutex to acquire and release
|
||||||
|
@param monitor monitor to be decremented by 1 */
|
||||||
|
#define MONITOR_MUTEX_DEC(mutex, monitor) \
|
||||||
|
MONITOR_MUTEX_DEC_LOW(mutex, monitor, MONITOR_IS_ON(monitor))
|
||||||
|
|
||||||
#if defined HAVE_ATOMIC_BUILTINS_64
|
#if defined HAVE_ATOMIC_BUILTINS_64
|
||||||
/** Atomically increment a monitor counter.
|
/** Atomically increment a monitor counter.
|
||||||
Use MONITOR_INC if appropriate mutex protection exists.
|
Use MONITOR_INC if appropriate mutex protection exists.
|
||||||
@param monitor monitor to be incremented by 1 */
|
@param monitor monitor to be incremented by 1
|
||||||
# define MONITOR_ATOMIC_INC(monitor) \
|
@param enabled whether the monitor is enabled */
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
|
||||||
|
if (enabled) { \
|
||||||
ib_uint64_t value; \
|
ib_uint64_t value; \
|
||||||
value = os_atomic_increment_uint64( \
|
value = os_atomic_increment_uint64( \
|
||||||
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
|
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
|
||||||
@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists.
|
|||||||
|
|
||||||
/** Atomically decrement a monitor counter.
|
/** Atomically decrement a monitor counter.
|
||||||
Use MONITOR_DEC if appropriate mutex protection exists.
|
Use MONITOR_DEC if appropriate mutex protection exists.
|
||||||
@param monitor monitor to be decremented by 1 */
|
@param monitor monitor to be decremented by 1
|
||||||
# define MONITOR_ATOMIC_DEC(monitor) \
|
@param enabled whether the monitor is enabled */
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
|
||||||
|
if (enabled) { \
|
||||||
ib_uint64_t value; \
|
ib_uint64_t value; \
|
||||||
value = os_atomic_decrement_uint64( \
|
value = os_atomic_decrement_uint64( \
|
||||||
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
|
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
|
||||||
@ -617,14 +634,29 @@ srv_mon_free(void);
|
|||||||
|
|
||||||
/** Atomically increment a monitor counter.
|
/** Atomically increment a monitor counter.
|
||||||
Use MONITOR_INC if appropriate mutex protection exists.
|
Use MONITOR_INC if appropriate mutex protection exists.
|
||||||
@param monitor monitor to be incremented by 1 */
|
@param monitor monitor to be incremented by 1
|
||||||
# define MONITOR_ATOMIC_INC(monitor) MONITOR_MUTEX_INC(&monitor_mutex, monitor)
|
@param enabled whether the monitor is enabled */
|
||||||
|
# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
|
||||||
|
MONITOR_MUTEX_INC_LOW(&monitor_mutex, monitor, enabled)
|
||||||
/** Atomically decrement a monitor counter.
|
/** Atomically decrement a monitor counter.
|
||||||
Use MONITOR_DEC if appropriate mutex protection exists.
|
Use MONITOR_DEC if appropriate mutex protection exists.
|
||||||
@param monitor monitor to be decremented by 1 */
|
@param monitor monitor to be decremented by 1
|
||||||
# define MONITOR_ATOMIC_DEC(monitor) MONITOR_MUTEX_DEC(&monitor_mutex, monitor)
|
@param enabled whether the monitor is enabled */
|
||||||
|
# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
|
||||||
|
MONITOR_MUTEX_DEC_LOW(&monitor_mutex, monitor, enabled)
|
||||||
#endif /* HAVE_ATOMIC_BUILTINS_64 */
|
#endif /* HAVE_ATOMIC_BUILTINS_64 */
|
||||||
|
|
||||||
|
/** Atomically increment a monitor counter if it is enabled.
|
||||||
|
Use MONITOR_INC if appropriate mutex protection exists.
|
||||||
|
@param monitor monitor to be incremented by 1 */
|
||||||
|
#define MONITOR_ATOMIC_INC(monitor) \
|
||||||
|
MONITOR_ATOMIC_INC_LOW(monitor, MONITOR_IS_ON(monitor))
|
||||||
|
/** Atomically decrement a monitor counter if it is enabled.
|
||||||
|
Use MONITOR_DEC if appropriate mutex protection exists.
|
||||||
|
@param monitor monitor to be decremented by 1 */
|
||||||
|
#define MONITOR_ATOMIC_DEC(monitor) \
|
||||||
|
MONITOR_ATOMIC_DEC_LOW(monitor, MONITOR_IS_ON(monitor))
|
||||||
|
|
||||||
#define MONITOR_DEC(monitor) \
|
#define MONITOR_DEC(monitor) \
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
if (MONITOR_IS_ON(monitor)) { \
|
||||||
MONITOR_VALUE(monitor)--; \
|
MONITOR_VALUE(monitor)--; \
|
||||||
|
@ -285,22 +285,12 @@ definitions: */
|
|||||||
|
|
||||||
#endif /* !UNIV_MUST_NOT_INLINE */
|
#endif /* !UNIV_MUST_NOT_INLINE */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#define UNIV_WORD_SIZE SIZEOF_SIZE_T
|
||||||
#define UNIV_WORD_SIZE 4
|
|
||||||
#elif defined(_WIN64)
|
|
||||||
#define UNIV_WORD_SIZE 8
|
|
||||||
#else
|
|
||||||
/** MySQL config.h generated by GNU autoconf will define SIZEOF_LONG in Posix */
|
|
||||||
#define UNIV_WORD_SIZE SIZEOF_LONG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** The following alignment is used in memory allocations in memory heap
|
/** The following alignment is used in memory allocations in memory heap
|
||||||
management to ensure correct alignment for doubles etc. */
|
management to ensure correct alignment for doubles etc. */
|
||||||
#define UNIV_MEM_ALIGNMENT 8
|
#define UNIV_MEM_ALIGNMENT 8
|
||||||
|
|
||||||
/** The following alignment is used in aligning lints etc. */
|
|
||||||
#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DATABASE VERSION CONTROL
|
DATABASE VERSION CONTROL
|
||||||
========================
|
========================
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2009, Percona Inc.
|
Copyright (c) 2009, Percona Inc.
|
||||||
Copyright (c) 2012, 2017, MariaDB Corporation. All Rights Reserved.
|
Copyright (c) 2013, 2017, MariaDB Corporation.
|
||||||
|
|
||||||
Portions of this file contain modifications contributed and copyrighted
|
Portions of this file contain modifications contributed and copyrighted
|
||||||
by Percona Inc.. Those modifications are
|
by Percona Inc.. Those modifications are
|
||||||
@ -284,21 +284,6 @@ UNIV_INTERN time_t os_last_printout;
|
|||||||
|
|
||||||
UNIV_INTERN ibool os_has_said_disk_full = FALSE;
|
UNIV_INTERN ibool os_has_said_disk_full = FALSE;
|
||||||
|
|
||||||
#if !defined(UNIV_HOTBACKUP) \
|
|
||||||
&& (!defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8)
|
|
||||||
/** The mutex protecting the following counts of pending I/O operations */
|
|
||||||
static os_ib_mutex_t os_file_count_mutex;
|
|
||||||
#endif /* !UNIV_HOTBACKUP && (!HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8) */
|
|
||||||
|
|
||||||
/** Number of pending os_file_pread() operations */
|
|
||||||
UNIV_INTERN ulint os_file_n_pending_preads = 0;
|
|
||||||
/** Number of pending os_file_pwrite() operations */
|
|
||||||
UNIV_INTERN ulint os_file_n_pending_pwrites = 0;
|
|
||||||
/** Number of pending write operations */
|
|
||||||
UNIV_INTERN ulint os_n_pending_writes = 0;
|
|
||||||
/** Number of pending read operations */
|
|
||||||
UNIV_INTERN ulint os_n_pending_reads = 0;
|
|
||||||
|
|
||||||
#ifdef UNIV_DEBUG
|
#ifdef UNIV_DEBUG
|
||||||
# ifndef UNIV_HOTBACKUP
|
# ifndef UNIV_HOTBACKUP
|
||||||
/**********************************************************************//**
|
/**********************************************************************//**
|
||||||
@ -752,10 +737,6 @@ void
|
|||||||
os_io_init_simple(void)
|
os_io_init_simple(void)
|
||||||
/*===================*/
|
/*===================*/
|
||||||
{
|
{
|
||||||
#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
|
|
||||||
os_file_count_mutex = os_mutex_create();
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */
|
|
||||||
|
|
||||||
for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
|
for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
|
||||||
os_file_seek_mutexes[i] = os_mutex_create();
|
os_file_seek_mutexes[i] = os_mutex_create();
|
||||||
}
|
}
|
||||||
@ -2364,9 +2345,6 @@ os_file_pread(
|
|||||||
os_offset_t offset) /*!< in: file offset from where to read */
|
os_offset_t offset) /*!< in: file offset from where to read */
|
||||||
{
|
{
|
||||||
off_t offs;
|
off_t offs;
|
||||||
#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
|
|
||||||
ssize_t n_bytes;
|
|
||||||
#endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */
|
|
||||||
|
|
||||||
ut_ad(n);
|
ut_ad(n);
|
||||||
|
|
||||||
@ -2383,33 +2361,12 @@ os_file_pread(
|
|||||||
|
|
||||||
os_n_file_reads++;
|
os_n_file_reads++;
|
||||||
|
|
||||||
#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
|
|
||||||
(void) os_atomic_increment_ulint(&os_n_pending_reads, 1);
|
|
||||||
(void) os_atomic_increment_ulint(&os_file_n_pending_preads, 1);
|
|
||||||
MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
#else
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_file_n_pending_preads++;
|
|
||||||
os_n_pending_reads++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */
|
|
||||||
|
|
||||||
n_bytes = pread(file, buf, n, offs);
|
|
||||||
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
|
|
||||||
(void) os_atomic_decrement_ulint(&os_n_pending_reads, 1);
|
|
||||||
(void) os_atomic_decrement_ulint(&os_file_n_pending_preads, 1);
|
|
||||||
MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
#else
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_file_n_pending_preads--;
|
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD == 8 */
|
|
||||||
|
|
||||||
|
#ifdef HAVE_PREAD
|
||||||
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
|
ssize_t n_bytes = pread(file, buf, n, offs);
|
||||||
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
return(n_bytes);
|
return(n_bytes);
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
@ -2419,15 +2376,7 @@ os_file_pread(
|
|||||||
ulint i;
|
ulint i;
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
(void) os_atomic_increment_ulint(&os_n_pending_reads, 1);
|
|
||||||
MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
#else
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_n_pending_reads++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
/* Protect the seek / read operation with a mutex */
|
/* Protect the seek / read operation with a mutex */
|
||||||
i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES;
|
i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES;
|
||||||
@ -2447,16 +2396,7 @@ os_file_pread(
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
(void) os_atomic_decrement_ulint(&os_n_pending_reads, 1);
|
|
||||||
MONITOR_ATOIC_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
#else
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD_SIZE == 8 */
|
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2493,32 +2433,11 @@ os_file_pwrite(
|
|||||||
|
|
||||||
os_n_file_writes++;
|
os_n_file_writes++;
|
||||||
|
|
||||||
#if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD)
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES);
|
||||||
#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
|
#ifdef HAVE_PWRITE
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_file_n_pending_pwrites++;
|
|
||||||
os_n_pending_writes++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#else
|
|
||||||
(void) os_atomic_increment_ulint(&os_n_pending_writes, 1);
|
|
||||||
(void) os_atomic_increment_ulint(&os_file_n_pending_pwrites, 1);
|
|
||||||
MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */
|
|
||||||
|
|
||||||
ret = pwrite(file, buf, (ssize_t) n, offs);
|
ret = pwrite(file, buf, (ssize_t) n, offs);
|
||||||
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_file_n_pending_pwrites--;
|
|
||||||
os_n_pending_writes--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#else
|
|
||||||
(void) os_atomic_decrement_ulint(&os_n_pending_writes, 1);
|
|
||||||
(void) os_atomic_decrement_ulint(&os_file_n_pending_pwrites, 1);
|
|
||||||
MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */
|
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
#else
|
#else
|
||||||
@ -2528,10 +2447,7 @@ os_file_pwrite(
|
|||||||
ulint i;
|
ulint i;
|
||||||
# endif /* !UNIV_HOTBACKUP */
|
# endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
# ifndef UNIV_HOTBACKUP
|
# ifndef UNIV_HOTBACKUP
|
||||||
/* Protect the seek / write operation with a mutex */
|
/* Protect the seek / write operation with a mutex */
|
||||||
@ -2555,14 +2471,10 @@ func_exit:
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
# endif /* !UNIV_HOTBACKUP */
|
# endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* HAVE_PWRITE */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2597,6 +2509,7 @@ os_file_read_func(
|
|||||||
|
|
||||||
os_n_file_reads++;
|
os_n_file_reads++;
|
||||||
os_bytes_read_since_printout += n;
|
os_bytes_read_since_printout += n;
|
||||||
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
ut_ad(buf);
|
ut_ad(buf);
|
||||||
@ -2605,10 +2518,7 @@ try_again:
|
|||||||
low = (DWORD) offset & 0xFFFFFFFF;
|
low = (DWORD) offset & 0xFFFFFFFF;
|
||||||
high = (DWORD) (offset >> 32);
|
high = (DWORD) (offset >> 32);
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
/* Protect the seek / read operation with a mutex */
|
/* Protect the seek / read operation with a mutex */
|
||||||
@ -2626,11 +2536,7 @@ try_again:
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
goto error_handling;
|
goto error_handling;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2640,10 +2546,7 @@ try_again:
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
if (ret && len == n) {
|
if (ret && len == n) {
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
@ -2728,6 +2631,7 @@ os_file_read_no_error_handling_func(
|
|||||||
|
|
||||||
os_n_file_reads++;
|
os_n_file_reads++;
|
||||||
os_bytes_read_since_printout += n;
|
os_bytes_read_since_printout += n;
|
||||||
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
ut_ad(buf);
|
ut_ad(buf);
|
||||||
@ -2736,10 +2640,7 @@ try_again:
|
|||||||
low = (DWORD) offset & 0xFFFFFFFF;
|
low = (DWORD) offset & 0xFFFFFFFF;
|
||||||
high = (DWORD) (offset >> 32);
|
high = (DWORD) (offset >> 32);
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
/* Protect the seek / read operation with a mutex */
|
/* Protect the seek / read operation with a mutex */
|
||||||
@ -2757,11 +2658,7 @@ try_again:
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
goto error_handling;
|
goto error_handling;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2771,10 +2668,7 @@ try_again:
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
if (ret && len == n) {
|
if (ret && len == n) {
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
@ -2854,7 +2748,6 @@ os_file_write_func(
|
|||||||
ulint n) /*!< in: number of bytes to write */
|
ulint n) /*!< in: number of bytes to write */
|
||||||
{
|
{
|
||||||
ut_ad(!srv_read_only_mode);
|
ut_ad(!srv_read_only_mode);
|
||||||
|
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
@ -2876,14 +2769,12 @@ os_file_write_func(
|
|||||||
|
|
||||||
ut_ad(buf);
|
ut_ad(buf);
|
||||||
ut_ad(n > 0);
|
ut_ad(n > 0);
|
||||||
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES);
|
||||||
retry:
|
retry:
|
||||||
low = (DWORD) offset & 0xFFFFFFFF;
|
low = (DWORD) offset & 0xFFFFFFFF;
|
||||||
high = (DWORD) (offset >> 32);
|
high = (DWORD) (offset >> 32);
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
/* Protect the seek / write operation with a mutex */
|
/* Protect the seek / write operation with a mutex */
|
||||||
@ -2901,10 +2792,7 @@ retry:
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
ut_print_timestamp(stderr);
|
ut_print_timestamp(stderr);
|
||||||
|
|
||||||
@ -2928,10 +2816,7 @@ retry:
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
if (ret && len == n) {
|
if (ret && len == n) {
|
||||||
|
|
||||||
@ -5751,19 +5636,24 @@ os_aio_print(
|
|||||||
time_elapsed = 0.001 + difftime(current_time, os_last_printout);
|
time_elapsed = 0.001 + difftime(current_time, os_last_printout);
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
|
"Pending flushes (fsync) log: " ULINTPF
|
||||||
"%lu OS file reads, %lu OS file writes, %lu OS fsyncs\n",
|
"; buffer pool: " ULINTPF "\n"
|
||||||
(ulong) fil_n_pending_log_flushes,
|
ULINTPF " OS file reads, "
|
||||||
(ulong) fil_n_pending_tablespace_flushes,
|
ULINTPF " OS file writes, "
|
||||||
(ulong) os_n_file_reads,
|
ULINTPF " OS fsyncs\n",
|
||||||
(ulong) os_n_file_writes,
|
fil_n_pending_log_flushes,
|
||||||
(ulong) os_n_fsyncs);
|
fil_n_pending_tablespace_flushes,
|
||||||
|
os_n_file_reads,
|
||||||
|
os_n_file_writes,
|
||||||
|
os_n_fsyncs);
|
||||||
|
|
||||||
if (os_file_n_pending_preads != 0 || os_file_n_pending_pwrites != 0) {
|
const ulint n_reads = MONITOR_VALUE(MONITOR_OS_PENDING_READS);
|
||||||
|
const ulint n_writes = MONITOR_VALUE(MONITOR_OS_PENDING_WRITES);
|
||||||
|
|
||||||
|
if (n_reads != 0 || n_writes != 0) {
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"%lu pending preads, %lu pending pwrites\n",
|
ULINTPF " pending reads, " ULINTPF " pending writes\n",
|
||||||
(ulong) os_file_n_pending_preads,
|
n_reads, n_writes);
|
||||||
(ulong) os_file_n_pending_pwrites);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (os_n_file_reads == os_n_file_reads_old) {
|
if (os_n_file_reads == os_n_file_reads_old) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2012, Facebook Inc.
|
Copyright (c) 2012, Facebook Inc.
|
||||||
|
Copyright (c) 2017, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
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
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -643,11 +644,11 @@ static monitor_info_t innodb_counter_info[] =
|
|||||||
MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC},
|
MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC},
|
||||||
|
|
||||||
{"os_pending_reads", "os", "Number of reads pending",
|
{"os_pending_reads", "os", "Number of reads pending",
|
||||||
MONITOR_NONE,
|
MONITOR_DEFAULT_ON,
|
||||||
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS},
|
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS},
|
||||||
|
|
||||||
{"os_pending_writes", "os", "Number of writes pending",
|
{"os_pending_writes", "os", "Number of writes pending",
|
||||||
MONITOR_NONE,
|
MONITOR_DEFAULT_ON,
|
||||||
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES},
|
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES},
|
||||||
|
|
||||||
{"os_log_bytes_written", "os",
|
{"os_log_bytes_written", "os",
|
||||||
|
@ -1409,10 +1409,10 @@ srv_export_innodb_status(void)
|
|||||||
mutex_enter(&srv_innodb_monitor_mutex);
|
mutex_enter(&srv_innodb_monitor_mutex);
|
||||||
|
|
||||||
export_vars.innodb_data_pending_reads =
|
export_vars.innodb_data_pending_reads =
|
||||||
os_n_pending_reads;
|
MONITOR_VALUE(MONITOR_OS_PENDING_READS);
|
||||||
|
|
||||||
export_vars.innodb_data_pending_writes =
|
export_vars.innodb_data_pending_writes =
|
||||||
os_n_pending_writes;
|
MONITOR_VALUE(MONITOR_OS_PENDING_WRITES);
|
||||||
|
|
||||||
export_vars.innodb_data_pending_fsyncs =
|
export_vars.innodb_data_pending_fsyncs =
|
||||||
fil_n_pending_log_flushes
|
fil_n_pending_log_flushes
|
||||||
|
@ -1069,9 +1069,10 @@ sync_array_print_long_waits(
|
|||||||
now the values of pending calls of these. */
|
now the values of pending calls of these. */
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"InnoDB: Pending preads %lu, pwrites %lu\n",
|
"InnoDB: Pending reads " UINT64PF
|
||||||
(ulong) os_file_n_pending_preads,
|
", writes " UINT64PF "\n",
|
||||||
(ulong) os_file_n_pending_pwrites);
|
MONITOR_VALUE(MONITOR_OS_PENDING_READS),
|
||||||
|
MONITOR_VALUE(MONITOR_OS_PENDING_WRITES));
|
||||||
|
|
||||||
srv_print_innodb_monitor = TRUE;
|
srv_print_innodb_monitor = TRUE;
|
||||||
os_event_set(srv_monitor_event);
|
os_event_set(srv_monitor_event);
|
||||||
|
@ -986,15 +986,11 @@ not_to_recover:
|
|||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count > 1000) {
|
if (count > 1000) {
|
||||||
fprintf(stderr,
|
ib_logf(IB_LOG_LEVEL_ERROR,
|
||||||
"InnoDB: Error: InnoDB has waited for"
|
"waited for 10 seconds for " ULINTPF
|
||||||
" 10 seconds for pending\n"
|
" pending reads to the buffer pool to"
|
||||||
"InnoDB: reads to the buffer pool to"
|
" be finished",
|
||||||
" be finished.\n"
|
buf_pool->n_pend_reads);
|
||||||
"InnoDB: Number of pending reads %lu,"
|
|
||||||
" pending pread calls %lu\n",
|
|
||||||
(ulong) buf_pool->n_pend_reads,
|
|
||||||
(ulong) os_file_n_pending_preads);
|
|
||||||
|
|
||||||
os_aio_print_debug = TRUE;
|
os_aio_print_debug = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2009, Percona Inc.
|
Copyright (c) 2009, Percona Inc.
|
||||||
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
|
Copyright (c) 2013, 2017, MariaDB Corporation.
|
||||||
|
|
||||||
Portions of this file contain modifications contributed and copyrighted
|
Portions of this file contain modifications contributed and copyrighted
|
||||||
by Percona Inc.. Those modifications are
|
by Percona Inc.. Those modifications are
|
||||||
@ -52,16 +52,6 @@ extern ibool os_has_said_disk_full;
|
|||||||
/** Flag: enable debug printout for asynchronous i/o */
|
/** Flag: enable debug printout for asynchronous i/o */
|
||||||
extern ibool os_aio_print_debug;
|
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__
|
#ifdef __WIN__
|
||||||
|
|
||||||
/** We define always WIN_ASYNC_IO, and check at run-time whether
|
/** We define always WIN_ASYNC_IO, and check at run-time whether
|
||||||
|
@ -718,10 +718,7 @@ os_atomic_clear(volatile lock_word_t* ptr)
|
|||||||
|
|
||||||
# define HAVE_ATOMIC_BUILTINS
|
# define HAVE_ATOMIC_BUILTINS
|
||||||
# define HAVE_ATOMIC_BUILTINS_BYTE
|
# define HAVE_ATOMIC_BUILTINS_BYTE
|
||||||
|
|
||||||
# ifndef _WIN32
|
|
||||||
# define HAVE_ATOMIC_BUILTINS_64
|
# define HAVE_ATOMIC_BUILTINS_64
|
||||||
# endif
|
|
||||||
|
|
||||||
/**********************************************************//**
|
/**********************************************************//**
|
||||||
Atomic compare and exchange of signed integers (both 32 and 64 bit).
|
Atomic compare and exchange of signed integers (both 32 and 64 bit).
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2012, Facebook Inc.
|
Copyright (c) 2012, Facebook Inc.
|
||||||
|
Copyright (c) 2017, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
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
|
under the terms of the GNU General Public License as published by the
|
||||||
@ -541,22 +542,30 @@ on the counters */
|
|||||||
|
|
||||||
/** Increment a monitor counter under mutex protection.
|
/** Increment a monitor counter under mutex protection.
|
||||||
Use MONITOR_INC if appropriate mutex protection already exists.
|
Use MONITOR_INC if appropriate mutex protection already exists.
|
||||||
|
@param mutex mutex to acquire and release
|
||||||
@param monitor monitor to be incremented by 1
|
@param monitor monitor to be incremented by 1
|
||||||
@param mutex mutex to acquire and relese */
|
@param enabled whether the monitor is enabled */
|
||||||
# define MONITOR_MUTEX_INC(mutex, monitor) \
|
#define MONITOR_MUTEX_INC_LOW(mutex, monitor, enabled) \
|
||||||
ut_ad(!mutex_own(mutex)); \
|
ut_ad(!mutex_own(mutex)); \
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
if (enabled) { \
|
||||||
mutex_enter(mutex); \
|
mutex_enter(mutex); \
|
||||||
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
|
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
|
||||||
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
|
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
|
||||||
} \
|
} \
|
||||||
mutex_exit(mutex); \
|
mutex_exit(mutex); \
|
||||||
}
|
}
|
||||||
|
/** Increment a monitor counter under mutex protection.
|
||||||
|
Use MONITOR_INC if appropriate mutex protection already exists.
|
||||||
|
@param mutex mutex to acquire and release
|
||||||
|
@param monitor monitor to be incremented by 1 */
|
||||||
|
#define MONITOR_MUTEX_INC(mutex, monitor) \
|
||||||
|
MONITOR_MUTEX_INC_LOW(mutex, monitor, MONITOR_IS_ON(monitor))
|
||||||
/** Decrement a monitor counter under mutex protection.
|
/** Decrement a monitor counter under mutex protection.
|
||||||
Use MONITOR_DEC if appropriate mutex protection already exists.
|
Use MONITOR_DEC if appropriate mutex protection already exists.
|
||||||
|
@param mutex mutex to acquire and release
|
||||||
@param monitor monitor to be decremented by 1
|
@param monitor monitor to be decremented by 1
|
||||||
@param mutex mutex to acquire and relese */
|
@param enabled whether the monitor is enabled */
|
||||||
# define MONITOR_MUTEX_DEC(mutex, monitor) \
|
#define MONITOR_MUTEX_DEC_LOW(mutex, monitor, enabled) \
|
||||||
ut_ad(!mutex_own(mutex)); \
|
ut_ad(!mutex_own(mutex)); \
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
if (MONITOR_IS_ON(monitor)) { \
|
||||||
mutex_enter(mutex); \
|
mutex_enter(mutex); \
|
||||||
@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists.
|
|||||||
} \
|
} \
|
||||||
mutex_exit(mutex); \
|
mutex_exit(mutex); \
|
||||||
}
|
}
|
||||||
|
/** Decrement a monitor counter under mutex protection.
|
||||||
|
Use MONITOR_DEC if appropriate mutex protection already exists.
|
||||||
|
@param mutex mutex to acquire and release
|
||||||
|
@param monitor monitor to be decremented by 1 */
|
||||||
|
#define MONITOR_MUTEX_DEC(mutex, monitor) \
|
||||||
|
MONITOR_MUTEX_DEC_LOW(mutex, monitor, MONITOR_IS_ON(monitor))
|
||||||
|
|
||||||
#if defined HAVE_ATOMIC_BUILTINS_64
|
#if defined HAVE_ATOMIC_BUILTINS_64
|
||||||
/** Atomically increment a monitor counter.
|
/** Atomically increment a monitor counter.
|
||||||
Use MONITOR_INC if appropriate mutex protection exists.
|
Use MONITOR_INC if appropriate mutex protection exists.
|
||||||
@param monitor monitor to be incremented by 1 */
|
@param monitor monitor to be incremented by 1
|
||||||
# define MONITOR_ATOMIC_INC(monitor) \
|
@param enabled whether the monitor is enabled */
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
|
||||||
|
if (enabled) { \
|
||||||
ib_uint64_t value; \
|
ib_uint64_t value; \
|
||||||
value = os_atomic_increment_uint64( \
|
value = os_atomic_increment_uint64( \
|
||||||
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
|
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
|
||||||
@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists.
|
|||||||
|
|
||||||
/** Atomically decrement a monitor counter.
|
/** Atomically decrement a monitor counter.
|
||||||
Use MONITOR_DEC if appropriate mutex protection exists.
|
Use MONITOR_DEC if appropriate mutex protection exists.
|
||||||
@param monitor monitor to be decremented by 1 */
|
@param monitor monitor to be decremented by 1
|
||||||
# define MONITOR_ATOMIC_DEC(monitor) \
|
@param enabled whether the monitor is enabled */
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
|
||||||
|
if (enabled) { \
|
||||||
ib_uint64_t value; \
|
ib_uint64_t value; \
|
||||||
value = os_atomic_decrement_uint64( \
|
value = os_atomic_decrement_uint64( \
|
||||||
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
|
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
|
||||||
@ -617,14 +634,29 @@ srv_mon_free(void);
|
|||||||
|
|
||||||
/** Atomically increment a monitor counter.
|
/** Atomically increment a monitor counter.
|
||||||
Use MONITOR_INC if appropriate mutex protection exists.
|
Use MONITOR_INC if appropriate mutex protection exists.
|
||||||
@param monitor monitor to be incremented by 1 */
|
@param monitor monitor to be incremented by 1
|
||||||
# define MONITOR_ATOMIC_INC(monitor) MONITOR_MUTEX_INC(&monitor_mutex, monitor)
|
@param enabled whether the monitor is enabled */
|
||||||
|
# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
|
||||||
|
MONITOR_MUTEX_INC_LOW(&monitor_mutex, monitor, enabled)
|
||||||
/** Atomically decrement a monitor counter.
|
/** Atomically decrement a monitor counter.
|
||||||
Use MONITOR_DEC if appropriate mutex protection exists.
|
Use MONITOR_DEC if appropriate mutex protection exists.
|
||||||
@param monitor monitor to be decremented by 1 */
|
@param monitor monitor to be decremented by 1
|
||||||
# define MONITOR_ATOMIC_DEC(monitor) MONITOR_MUTEX_DEC(&monitor_mutex, monitor)
|
@param enabled whether the monitor is enabled */
|
||||||
|
# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
|
||||||
|
MONITOR_MUTEX_DEC_LOW(&monitor_mutex, monitor, enabled)
|
||||||
#endif /* HAVE_ATOMIC_BUILTINS_64 */
|
#endif /* HAVE_ATOMIC_BUILTINS_64 */
|
||||||
|
|
||||||
|
/** Atomically increment a monitor counter if it is enabled.
|
||||||
|
Use MONITOR_INC if appropriate mutex protection exists.
|
||||||
|
@param monitor monitor to be incremented by 1 */
|
||||||
|
#define MONITOR_ATOMIC_INC(monitor) \
|
||||||
|
MONITOR_ATOMIC_INC_LOW(monitor, MONITOR_IS_ON(monitor))
|
||||||
|
/** Atomically decrement a monitor counter if it is enabled.
|
||||||
|
Use MONITOR_DEC if appropriate mutex protection exists.
|
||||||
|
@param monitor monitor to be decremented by 1 */
|
||||||
|
#define MONITOR_ATOMIC_DEC(monitor) \
|
||||||
|
MONITOR_ATOMIC_DEC_LOW(monitor, MONITOR_IS_ON(monitor))
|
||||||
|
|
||||||
#define MONITOR_DEC(monitor) \
|
#define MONITOR_DEC(monitor) \
|
||||||
if (MONITOR_IS_ON(monitor)) { \
|
if (MONITOR_IS_ON(monitor)) { \
|
||||||
MONITOR_VALUE(monitor)--; \
|
MONITOR_VALUE(monitor)--; \
|
||||||
|
@ -304,22 +304,12 @@ definitions: */
|
|||||||
|
|
||||||
#endif /* !UNIV_MUST_NOT_INLINE */
|
#endif /* !UNIV_MUST_NOT_INLINE */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#define UNIV_WORD_SIZE SIZEOF_SIZE_T
|
||||||
#define UNIV_WORD_SIZE 4
|
|
||||||
#elif defined(_WIN64)
|
|
||||||
#define UNIV_WORD_SIZE 8
|
|
||||||
#else
|
|
||||||
/** MySQL config.h generated by GNU autoconf will define SIZEOF_LONG in Posix */
|
|
||||||
#define UNIV_WORD_SIZE SIZEOF_LONG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** The following alignment is used in memory allocations in memory heap
|
/** The following alignment is used in memory allocations in memory heap
|
||||||
management to ensure correct alignment for doubles etc. */
|
management to ensure correct alignment for doubles etc. */
|
||||||
#define UNIV_MEM_ALIGNMENT 8
|
#define UNIV_MEM_ALIGNMENT 8
|
||||||
|
|
||||||
/** The following alignment is used in aligning lints etc. */
|
|
||||||
#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DATABASE VERSION CONTROL
|
DATABASE VERSION CONTROL
|
||||||
========================
|
========================
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2009, Percona Inc.
|
Copyright (c) 2009, Percona Inc.
|
||||||
Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved.
|
Copyright (c) 2013, 2017, MariaDB Corporation.
|
||||||
|
|
||||||
Portions of this file contain modifications contributed and copyrighted
|
Portions of this file contain modifications contributed and copyrighted
|
||||||
by Percona Inc.. Those modifications are
|
by Percona Inc.. Those modifications are
|
||||||
@ -291,21 +291,6 @@ UNIV_INTERN time_t os_last_printout;
|
|||||||
|
|
||||||
UNIV_INTERN ibool os_has_said_disk_full = FALSE;
|
UNIV_INTERN ibool os_has_said_disk_full = FALSE;
|
||||||
|
|
||||||
#if !defined(UNIV_HOTBACKUP) \
|
|
||||||
&& (!defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8)
|
|
||||||
/** The mutex protecting the following counts of pending I/O operations */
|
|
||||||
static os_ib_mutex_t os_file_count_mutex;
|
|
||||||
#endif /* !UNIV_HOTBACKUP && (!HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8) */
|
|
||||||
|
|
||||||
/** Number of pending os_file_pread() operations */
|
|
||||||
UNIV_INTERN ulint os_file_n_pending_preads = 0;
|
|
||||||
/** Number of pending os_file_pwrite() operations */
|
|
||||||
UNIV_INTERN ulint os_file_n_pending_pwrites = 0;
|
|
||||||
/** Number of pending write operations */
|
|
||||||
UNIV_INTERN ulint os_n_pending_writes = 0;
|
|
||||||
/** Number of pending read operations */
|
|
||||||
UNIV_INTERN ulint os_n_pending_reads = 0;
|
|
||||||
|
|
||||||
#ifdef UNIV_DEBUG
|
#ifdef UNIV_DEBUG
|
||||||
# ifndef UNIV_HOTBACKUP
|
# ifndef UNIV_HOTBACKUP
|
||||||
/**********************************************************************//**
|
/**********************************************************************//**
|
||||||
@ -887,10 +872,6 @@ void
|
|||||||
os_io_init_simple(void)
|
os_io_init_simple(void)
|
||||||
/*===================*/
|
/*===================*/
|
||||||
{
|
{
|
||||||
#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
|
|
||||||
os_file_count_mutex = os_mutex_create();
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */
|
|
||||||
|
|
||||||
for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
|
for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
|
||||||
os_file_seek_mutexes[i] = os_mutex_create();
|
os_file_seek_mutexes[i] = os_mutex_create();
|
||||||
}
|
}
|
||||||
@ -2580,10 +2561,6 @@ os_file_pread(
|
|||||||
trx_t* trx)
|
trx_t* trx)
|
||||||
{
|
{
|
||||||
off_t offs;
|
off_t offs;
|
||||||
#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
|
|
||||||
ssize_t n_bytes;
|
|
||||||
ssize_t n_read;
|
|
||||||
#endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */
|
|
||||||
ulint sec;
|
ulint sec;
|
||||||
ulint ms;
|
ulint ms;
|
||||||
ib_uint64_t start_time;
|
ib_uint64_t start_time;
|
||||||
@ -2613,22 +2590,16 @@ os_file_pread(
|
|||||||
} else {
|
} else {
|
||||||
start_time = 0;
|
start_time = 0;
|
||||||
}
|
}
|
||||||
#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
|
||||||
(void) os_atomic_increment_ulint(&os_n_pending_reads, 1);
|
#ifdef HAVE_PREAD
|
||||||
(void) os_atomic_increment_ulint(&os_file_n_pending_preads, 1);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
#else
|
ssize_t n_bytes;
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_file_n_pending_preads++;
|
|
||||||
os_n_pending_reads++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */
|
|
||||||
|
|
||||||
/* Handle partial reads and signal interruptions correctly */
|
/* Handle partial reads and signal interruptions correctly */
|
||||||
for (n_bytes = 0; n_bytes < (ssize_t) n; ) {
|
for (n_bytes = 0; n_bytes < (ssize_t) n; ) {
|
||||||
n_read = pread(file, buf, (ssize_t)n - n_bytes, offs);
|
ssize_t n_read = pread(file, buf, (ssize_t)n - n_bytes, offs);
|
||||||
if (n_read > 0) {
|
if (n_read > 0) {
|
||||||
n_bytes += n_read;
|
n_bytes += n_read;
|
||||||
offs += n_read;
|
offs += n_read;
|
||||||
@ -2640,17 +2611,7 @@ os_file_pread(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
(void) os_atomic_decrement_ulint(&os_n_pending_reads, 1);
|
|
||||||
(void) os_atomic_decrement_ulint(&os_file_n_pending_preads, 1);
|
|
||||||
MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
#else
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_file_n_pending_preads--;
|
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD == 8 */
|
|
||||||
|
|
||||||
if (UNIV_UNLIKELY(start_time != 0))
|
if (UNIV_UNLIKELY(start_time != 0))
|
||||||
{
|
{
|
||||||
@ -2669,15 +2630,7 @@ os_file_pread(
|
|||||||
ulint i;
|
ulint i;
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
(void) os_atomic_increment_ulint(&os_n_pending_reads, 1);
|
|
||||||
MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
#else
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_n_pending_reads++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
/* Protect the seek / read operation with a mutex */
|
/* Protect the seek / read operation with a mutex */
|
||||||
i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES;
|
i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES;
|
||||||
@ -2707,15 +2660,7 @@ os_file_pread(
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
(void) os_atomic_decrement_ulint(&os_n_pending_reads, 1);
|
|
||||||
MONITOR_ATOIC_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
#else
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD_SIZE == 8 */
|
|
||||||
|
|
||||||
if (UNIV_UNLIKELY(start_time != 0)
|
if (UNIV_UNLIKELY(start_time != 0)
|
||||||
{
|
{
|
||||||
@ -2761,18 +2706,9 @@ os_file_pwrite(
|
|||||||
|
|
||||||
os_n_file_writes++;
|
os_n_file_writes++;
|
||||||
|
|
||||||
#if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD)
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES);
|
||||||
#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
|
#ifdef HAVE_PWRITE
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_file_n_pending_pwrites++;
|
|
||||||
os_n_pending_writes++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#else
|
|
||||||
(void) os_atomic_increment_ulint(&os_n_pending_writes, 1);
|
|
||||||
(void) os_atomic_increment_ulint(&os_file_n_pending_pwrites, 1);
|
|
||||||
MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */
|
|
||||||
|
|
||||||
/* Handle partial writes and signal interruptions correctly */
|
/* Handle partial writes and signal interruptions correctly */
|
||||||
for (ret = 0; ret < (ssize_t) n; ) {
|
for (ret = 0; ret < (ssize_t) n; ) {
|
||||||
@ -2791,17 +2727,7 @@ os_file_pwrite(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_mutex_enter(os_file_count_mutex);
|
|
||||||
os_file_n_pending_pwrites--;
|
|
||||||
os_n_pending_writes--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
#else
|
|
||||||
(void) os_atomic_decrement_ulint(&os_n_pending_writes, 1);
|
|
||||||
(void) os_atomic_decrement_ulint(&os_file_n_pending_pwrites, 1);
|
|
||||||
MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */
|
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
#else
|
#else
|
||||||
@ -2811,10 +2737,7 @@ os_file_pwrite(
|
|||||||
ulint i;
|
ulint i;
|
||||||
# endif /* !UNIV_HOTBACKUP */
|
# endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
# ifndef UNIV_HOTBACKUP
|
# ifndef UNIV_HOTBACKUP
|
||||||
/* Protect the seek / write operation with a mutex */
|
/* Protect the seek / write operation with a mutex */
|
||||||
@ -2848,14 +2771,10 @@ func_exit:
|
|||||||
os_mutex_exit(os_file_seek_mutexes[i]);
|
os_mutex_exit(os_file_seek_mutexes[i]);
|
||||||
# endif /* !UNIV_HOTBACKUP */
|
# endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* HAVE_PWRITE */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2887,15 +2806,13 @@ os_file_read_func(
|
|||||||
|
|
||||||
os_n_file_reads++;
|
os_n_file_reads++;
|
||||||
os_bytes_read_since_printout += n;
|
os_bytes_read_since_printout += n;
|
||||||
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
ut_ad(buf);
|
ut_ad(buf);
|
||||||
ut_ad(n > 0);
|
ut_ad(n > 0);
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
memset (&overlapped, 0, sizeof (overlapped));
|
memset (&overlapped, 0, sizeof (overlapped));
|
||||||
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
|
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
|
||||||
@ -2908,10 +2825,7 @@ try_again:
|
|||||||
else if(GetLastError() == ERROR_IO_PENDING) {
|
else if(GetLastError() == ERROR_IO_PENDING) {
|
||||||
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
|
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
|
||||||
}
|
}
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
if (ret && len == n) {
|
if (ret && len == n) {
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
@ -2995,15 +2909,13 @@ os_file_read_no_error_handling_func(
|
|||||||
|
|
||||||
os_n_file_reads++;
|
os_n_file_reads++;
|
||||||
os_bytes_read_since_printout += n;
|
os_bytes_read_since_printout += n;
|
||||||
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
ut_ad(buf);
|
ut_ad(buf);
|
||||||
ut_ad(n > 0);
|
ut_ad(n > 0);
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
memset (&overlapped, 0, sizeof (overlapped));
|
memset (&overlapped, 0, sizeof (overlapped));
|
||||||
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
|
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
|
||||||
@ -3016,10 +2928,7 @@ try_again:
|
|||||||
else if(GetLastError() == ERROR_IO_PENDING) {
|
else if(GetLastError() == ERROR_IO_PENDING) {
|
||||||
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
|
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
|
||||||
}
|
}
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
|
||||||
os_n_pending_reads--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_READS);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
if (ret && len == n) {
|
if (ret && len == n) {
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
@ -3113,12 +3022,10 @@ os_file_write_func(
|
|||||||
|
|
||||||
ut_ad(buf);
|
ut_ad(buf);
|
||||||
ut_ad(n > 0);
|
ut_ad(n > 0);
|
||||||
|
const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES);
|
||||||
retry:
|
retry:
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes++;
|
|
||||||
MONITOR_INC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
memset (&overlapped, 0, sizeof (overlapped));
|
memset (&overlapped, 0, sizeof (overlapped));
|
||||||
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
|
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
|
||||||
@ -3133,10 +3040,7 @@ retry:
|
|||||||
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
|
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
os_mutex_enter(os_file_count_mutex);
|
MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
|
||||||
os_n_pending_writes--;
|
|
||||||
MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
|
|
||||||
os_mutex_exit(os_file_count_mutex);
|
|
||||||
|
|
||||||
if (ret && len == n) {
|
if (ret && len == n) {
|
||||||
|
|
||||||
@ -4230,10 +4134,6 @@ os_aio_free(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
|
|
||||||
os_mutex_free(os_file_count_mutex);
|
|
||||||
#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */
|
|
||||||
|
|
||||||
for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
|
for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
|
||||||
os_mutex_free(os_file_seek_mutexes[i]);
|
os_mutex_free(os_file_seek_mutexes[i]);
|
||||||
}
|
}
|
||||||
@ -5909,19 +5809,24 @@ os_aio_print(
|
|||||||
time_elapsed = 0.001 + difftime(current_time, os_last_printout);
|
time_elapsed = 0.001 + difftime(current_time, os_last_printout);
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
|
"Pending flushes (fsync) log: " ULINTPF
|
||||||
"%lu OS file reads, %lu OS file writes, %lu OS fsyncs\n",
|
"; buffer pool: " ULINTPF "\n"
|
||||||
(ulong) fil_n_pending_log_flushes,
|
ULINTPF " OS file reads, "
|
||||||
(ulong) fil_n_pending_tablespace_flushes,
|
ULINTPF " OS file writes, "
|
||||||
(ulong) os_n_file_reads,
|
ULINTPF " OS fsyncs\n",
|
||||||
(ulong) os_n_file_writes,
|
fil_n_pending_log_flushes,
|
||||||
(ulong) os_n_fsyncs);
|
fil_n_pending_tablespace_flushes,
|
||||||
|
os_n_file_reads,
|
||||||
|
os_n_file_writes,
|
||||||
|
os_n_fsyncs);
|
||||||
|
|
||||||
if (os_file_n_pending_preads != 0 || os_file_n_pending_pwrites != 0) {
|
const ulint n_reads = MONITOR_VALUE(MONITOR_OS_PENDING_READS);
|
||||||
|
const ulint n_writes = MONITOR_VALUE(MONITOR_OS_PENDING_WRITES);
|
||||||
|
|
||||||
|
if (n_reads != 0 || n_writes != 0) {
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"%lu pending preads, %lu pending pwrites\n",
|
ULINTPF " pending reads, " ULINTPF " pending writes\n",
|
||||||
(ulong) os_file_n_pending_preads,
|
n_reads, n_writes);
|
||||||
(ulong) os_file_n_pending_pwrites);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (os_n_file_reads == os_n_file_reads_old) {
|
if (os_n_file_reads == os_n_file_reads_old) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
Copyright (c) 2012, Facebook Inc.
|
Copyright (c) 2012, Facebook Inc.
|
||||||
|
Copyright (c) 2017, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
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
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -643,11 +644,11 @@ static monitor_info_t innodb_counter_info[] =
|
|||||||
MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC},
|
MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC},
|
||||||
|
|
||||||
{"os_pending_reads", "os", "Number of reads pending",
|
{"os_pending_reads", "os", "Number of reads pending",
|
||||||
MONITOR_NONE,
|
MONITOR_DEFAULT_ON,
|
||||||
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS},
|
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS},
|
||||||
|
|
||||||
{"os_pending_writes", "os", "Number of writes pending",
|
{"os_pending_writes", "os", "Number of writes pending",
|
||||||
MONITOR_NONE,
|
MONITOR_DEFAULT_ON,
|
||||||
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES},
|
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES},
|
||||||
|
|
||||||
{"os_log_bytes_written", "os",
|
{"os_log_bytes_written", "os",
|
||||||
|
@ -1735,10 +1735,10 @@ srv_export_innodb_status(void)
|
|||||||
mutex_enter(&srv_innodb_monitor_mutex);
|
mutex_enter(&srv_innodb_monitor_mutex);
|
||||||
|
|
||||||
export_vars.innodb_data_pending_reads =
|
export_vars.innodb_data_pending_reads =
|
||||||
os_n_pending_reads;
|
MONITOR_VALUE(MONITOR_OS_PENDING_READS);
|
||||||
|
|
||||||
export_vars.innodb_data_pending_writes =
|
export_vars.innodb_data_pending_writes =
|
||||||
os_n_pending_writes;
|
MONITOR_VALUE(MONITOR_OS_PENDING_WRITES);
|
||||||
|
|
||||||
export_vars.innodb_data_pending_fsyncs =
|
export_vars.innodb_data_pending_fsyncs =
|
||||||
fil_n_pending_log_flushes
|
fil_n_pending_log_flushes
|
||||||
|
@ -1161,9 +1161,10 @@ sync_array_print_long_waits(
|
|||||||
now the values of pending calls of these. */
|
now the values of pending calls of these. */
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"InnoDB: Pending preads %lu, pwrites %lu\n",
|
"InnoDB: Pending reads " UINT64PF
|
||||||
(ulong) os_file_n_pending_preads,
|
", writes " UINT64PF "\n",
|
||||||
(ulong) os_file_n_pending_pwrites);
|
MONITOR_VALUE(MONITOR_OS_PENDING_READS),
|
||||||
|
MONITOR_VALUE(MONITOR_OS_PENDING_WRITES));
|
||||||
|
|
||||||
srv_print_innodb_monitor = TRUE;
|
srv_print_innodb_monitor = TRUE;
|
||||||
os_event_set(srv_monitor_event);
|
os_event_set(srv_monitor_event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user