From 9c55f83eaedc4fdb1c1e5538646b0a9325f670fb Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 4 Jun 2020 23:54:19 +0200 Subject: Cleanup - remove HAVE_AIOWAIT and associated code from mysys HAVE_AIOWAIT had not been disabled and unused for at least 10 years. --- config.h.cmake | 1 - configure.cmake | 1 - include/my_sys.h | 21 ----- mysys/mf_iocache.c | 250 ----------------------------------------------------- 4 files changed, 273 deletions(-) diff --git a/config.h.cmake b/config.h.cmake index 942998b0544..5cced0f646f 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -125,7 +125,6 @@ /* Functions we may want to use. */ #cmakedefine HAVE_ACCEPT4 1 #cmakedefine HAVE_ACCESS 1 -#cmakedefine HAVE_AIOWAIT 1 #cmakedefine HAVE_ALARM 1 #cmakedefine HAVE_ALLOCA 1 #cmakedefine HAVE_BFILL 1 diff --git a/configure.cmake b/configure.cmake index 4e198132f52..a7e044b13d2 100644 --- a/configure.cmake +++ b/configure.cmake @@ -316,7 +316,6 @@ ENDIF() # CHECK_FUNCTION_EXISTS (accept4 HAVE_ACCEPT4) CHECK_FUNCTION_EXISTS (access HAVE_ACCESS) -#CHECK_FUNCTION_EXISTS (aiowait HAVE_AIOWAIT) CHECK_FUNCTION_EXISTS (alarm HAVE_ALARM) SET(HAVE_ALLOCA 1) CHECK_FUNCTION_EXISTS (backtrace HAVE_BACKTRACE) diff --git a/include/my_sys.h b/include/my_sys.h index a344e88c093..7fca0ed676a 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -22,13 +22,6 @@ C_MODE_START -#ifdef HAVE_AIOWAIT -#include /* Used by record-cache */ -typedef struct my_aio_result { - aio_result_t result; - int pending; -} my_aio_result; -#endif #include @@ -311,10 +304,6 @@ typedef struct st_record_cache /* Used when caching records */ uint rc_length,read_length,reclength; my_off_t rc_record_pos,end_of_file; uchar *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; -#ifdef HAVE_AIOWAIT - int use_async_io; - my_aio_result aio_result; -#endif enum cache_type type; } RECORD_CACHE; @@ -483,15 +472,6 @@ typedef struct st_io_cache /* Used when caching files */ somewhere else */ my_bool alloced_buffer; -#ifdef HAVE_AIOWAIT - /* - As inidicated by ifdef, this is for async I/O, which is not currently - used (because it's not reliable on all systems) - */ - uint inited; - my_off_t aio_read_pos; - my_aio_result aio_result; -#endif } IO_CACHE; typedef int (*qsort2_cmp)(const void *, const void *, const void *); @@ -810,7 +790,6 @@ void end_slave_io_cache(IO_CACHE *cache); void seek_io_cache(IO_CACHE *cache, my_off_t needed_offset); extern void remove_io_thread(IO_CACHE *info); -extern int _my_b_async_read(IO_CACHE *info,uchar *Buffer,size_t Count); extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count); extern int my_b_safe_write(IO_CACHE *info,const uchar *Buffer,size_t Count); diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index c7cb7510b60..d222dd8c99c 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -50,10 +50,6 @@ TODO: #include "mysys_priv.h" #include -#ifdef HAVE_AIOWAIT -#include "mysys_err.h" -static void my_aiowait(my_aio_result *result); -#endif #include #include "mysql/psi/mysql_file.h" @@ -295,16 +291,6 @@ int init_io_cache_ext(IO_CACHE *info, File file, size_t cachesize, info->error=0; info->type= type; init_functions(info); -#ifdef HAVE_AIOWAIT - if (use_async_io && ! my_disable_async_io) - { - DBUG_PRINT("info",("Using async io")); - DBUG_ASSERT(!(cache_myflags & MY_ENCRYPT)); - info->read_length/=2; - info->read_function=_my_b_async_read; - } - info->inited=info->aio_result.pending=0; -#endif DBUG_RETURN(0); } @@ -420,33 +406,6 @@ void seek_io_cache(IO_CACHE *cache, my_off_t needed_offset) } } - /* Wait until current request is ready */ - -#ifdef HAVE_AIOWAIT -static void my_aiowait(my_aio_result *result) -{ - if (result->pending) - { - struct aio_result_t *tmp; - for (;;) - { - if ((int) (tmp=aiowait((struct timeval *) 0)) == -1) - { - if (errno == EINTR) - continue; - DBUG_PRINT("error",("No aio request, error: %d",errno)); - result->pending=0; /* Assume everything is ok */ - break; - } - ((my_aio_result*) tmp)->pending=0; - if ((my_aio_result*) tmp == result) - break; - } - } - return; -} -#endif - /* Use this to reset cache to re-start reading or to change the type @@ -499,9 +458,6 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, info->write_pos=pos; else info->read_pos= pos; -#ifdef HAVE_AIOWAIT - my_aiowait(&info->aio_result); /* Wait for outstanding req */ -#endif } else { @@ -556,18 +512,6 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, info->type=type; info->error=0; init_functions(info); - -#ifdef HAVE_AIOWAIT - if (use_async_io && ! my_disable_async_io && - ((ulong) info->buffer_length < - (ulong) (info->end_of_file - seek_offset))) - { - DBUG_ASSERT(!(cache_myflags & MY_ENCRYPT)); - info->read_length=info->buffer_length/2; - info->read_function=_my_b_async_read; - } - info->inited=0; -#endif DBUG_RETURN(0); } /* reinit_io_cache */ @@ -1533,193 +1477,6 @@ read_append_buffer: } -#ifdef HAVE_AIOWAIT - -/* - Read from the IO_CACHE into a buffer and feed asynchronously - from disk when needed. - - SYNOPSIS - _my_b_async_read() - info IO_CACHE pointer - Buffer Buffer to retrieve count bytes from file - Count Number of bytes to read into Buffer - - RETURN VALUE - -1 An error has occurred; my_errno is set. - 0 Success - 1 An error has occurred; IO_CACHE to error state. -*/ - -int _my_b_async_read(IO_CACHE *info, uchar *Buffer, size_t Count) -{ - size_t length, read_length, diff_length, left_length=0, use_length, org_Count; - size_t max_length; - my_off_t next_pos_in_file; - uchar *read_buffer; - - org_Count=Count; - - if (info->inited) - { /* wait for read block */ - info->inited=0; /* No more block to read */ - my_aiowait(&info->aio_result); /* Wait for outstanding req */ - if (info->aio_result.result.aio_errno) - { - if (info->myflags & MY_WME) - my_error(EE_READ, MYF(ME_BELL), my_filename(info->file), - info->aio_result.result.aio_errno); - my_errno=info->aio_result.result.aio_errno; - info->error= -1; - return(1); - } - if (! (read_length= (size_t) info->aio_result.result.aio_return) || - read_length == (size_t) -1) - { - my_errno=0; /* For testing */ - info->error= (read_length == (size_t) -1 ? -1 : - (int) (read_length+left_length)); - return(1); - } - info->pos_in_file+= (size_t) (info->read_end - info->request_pos); - - if (info->request_pos != info->buffer) - info->request_pos=info->buffer; - else - info->request_pos=info->buffer+info->read_length; - info->read_pos=info->request_pos; - next_pos_in_file=info->aio_read_pos+read_length; - - /* Check if pos_in_file is changed - (_ni_read_cache may have skipped some bytes) */ - - if (info->aio_read_pos < info->pos_in_file) - { /* Fix if skipped bytes */ - if (info->aio_read_pos + read_length < info->pos_in_file) - { - read_length=0; /* Skip block */ - next_pos_in_file=info->pos_in_file; - } - else - { - my_off_t offset= (info->pos_in_file - info->aio_read_pos); - info->pos_in_file=info->aio_read_pos; /* Whe are here */ - info->read_pos=info->request_pos+offset; - read_length-=offset; /* Bytes left from read_pos */ - } - } -#ifndef DBUG_OFF - if (info->aio_read_pos > info->pos_in_file) - { - my_errno=EINVAL; - return(info->read_length= (size_t) -1); - } -#endif - /* Copy found bytes to buffer */ - length=MY_MIN(Count,read_length); - memcpy(Buffer,info->read_pos,(size_t) length); - Buffer+=length; - Count-=length; - left_length+=length; - info->read_end=info->rc_pos+read_length; - info->read_pos+=length; - } - else - next_pos_in_file=(info->pos_in_file+ (size_t) - (info->read_end - info->request_pos)); - - /* If reading large blocks, or first read or read with skip */ - if (Count) - { - if (next_pos_in_file == info->end_of_file) - { - info->error=(int) (read_length+left_length); - return 1; - } - - if (mysql_file_seek(info->file, next_pos_in_file, MY_SEEK_SET, MYF(0)) - == MY_FILEPOS_ERROR) - { - info->error= -1; - return (1); - } - - read_length=IO_SIZE*2- (size_t) (next_pos_in_file & (IO_SIZE-1)); - if (Count < read_length) - { /* Small block, read to cache */ - if ((read_length=mysql_file_read(info->file,info->request_pos, - read_length, info->myflags)) == (size_t) -1) - return info->error= -1; - use_length=MY_MIN(Count,read_length); - memcpy(Buffer,info->request_pos,(size_t) use_length); - info->read_pos=info->request_pos+Count; - info->read_end=info->request_pos+read_length; - info->pos_in_file=next_pos_in_file; /* Start of block in cache */ - next_pos_in_file+=read_length; - - if (Count != use_length) - { /* Didn't find hole block */ - if (info->myflags & (MY_WME | MY_FAE | MY_FNABP) && Count != org_Count) - my_error(EE_EOFERR, MYF(ME_BELL), my_filename(info->file), my_errno); - info->error=(int) (read_length+left_length); - return 1; - } - } - else - { /* Big block, don't cache it */ - if ((read_length= mysql_file_read(info->file, Buffer, Count,info->myflags)) - != Count) - { - info->error= read_length == (size_t) -1 ? -1 : read_length+left_length; - return 1; - } - info->read_pos=info->read_end=info->request_pos; - info->pos_in_file=(next_pos_in_file+=Count); - } - } - - /* Read next block with asyncronic io */ - diff_length=(next_pos_in_file & (IO_SIZE-1)); - max_length= info->read_length - diff_length; - if (max_length > info->end_of_file - next_pos_in_file) - max_length= (size_t) (info->end_of_file - next_pos_in_file); - - if (info->request_pos != info->buffer) - read_buffer=info->buffer; - else - read_buffer=info->buffer+info->read_length; - info->aio_read_pos=next_pos_in_file; - if (max_length) - { - info->aio_result.result.aio_errno=AIO_INPROGRESS; /* Marker for test */ - DBUG_PRINT("aioread",("filepos: %ld length: %lu", - (ulong) next_pos_in_file, (ulong) max_length)); - if (aioread(info->file,read_buffer, max_length, - (my_off_t) next_pos_in_file,MY_SEEK_SET, - &info->aio_result.result)) - { /* Skip async io */ - my_errno=errno; - DBUG_PRINT("error",("got error: %d, aio_result: %d from aioread, async skipped", - errno, info->aio_result.result.aio_errno)); - if (info->request_pos != info->buffer) - { - bmove(info->buffer,info->request_pos, - (size_t) (info->read_end - info->read_pos)); - info->request_pos=info->buffer; - info->read_pos-=info->read_length; - info->read_end-=info->read_length; - } - info->read_length=info->buffer_length; /* Use hole buffer */ - info->read_function=_my_b_cache_read; /* Use normal IO_READ next */ - } - else - info->inited=info->aio_result.pending=1; - } - return 0; /* Block read, async in use */ -} /* _my_b_async_read */ -#endif - - /* Read one byte when buffer is empty */ int _my_b_get(IO_CACHE *info) @@ -1978,13 +1735,6 @@ int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) DBUG_RETURN(info->error); } } -#ifdef HAVE_AIOWAIT - else if (info->type != READ_NET) - { - my_aiowait(&info->aio_result); /* Wait for outstanding req */ - info->inited=0; - } -#endif UNLOCK_APPEND_BUFFER; DBUG_RETURN(0); } -- cgit v1.2.1