|
50 | 50 |
|
51 | 51 | #include "mysys_priv.h"
|
52 | 52 | #include <m_string.h>
|
53 |
| -#ifdef HAVE_AIOWAIT |
54 |
| -#include "mysys_err.h" |
55 |
| -static void my_aiowait(my_aio_result *result); |
56 |
| -#endif |
57 | 53 | #include <errno.h>
|
58 | 54 | #include "mysql/psi/mysql_file.h"
|
59 | 55 |
|
@@ -295,16 +291,6 @@ int init_io_cache_ext(IO_CACHE *info, File file, size_t cachesize,
|
295 | 291 | info->error=0;
|
296 | 292 | info->type= type;
|
297 | 293 | init_functions(info);
|
298 |
| -#ifdef HAVE_AIOWAIT |
299 |
| - if (use_async_io && ! my_disable_async_io) |
300 |
| - { |
301 |
| - DBUG_PRINT("info",("Using async io")); |
302 |
| - DBUG_ASSERT(!(cache_myflags & MY_ENCRYPT)); |
303 |
| - info->read_length/=2; |
304 |
| - info->read_function=_my_b_async_read; |
305 |
| - } |
306 |
| - info->inited=info->aio_result.pending=0; |
307 |
| -#endif |
308 | 294 | DBUG_RETURN(0);
|
309 | 295 | }
|
310 | 296 |
|
@@ -420,33 +406,6 @@ void seek_io_cache(IO_CACHE *cache, my_off_t needed_offset)
|
420 | 406 | }
|
421 | 407 | }
|
422 | 408 |
|
423 |
| - /* Wait until current request is ready */ |
424 |
| - |
425 |
| -#ifdef HAVE_AIOWAIT |
426 |
| -static void my_aiowait(my_aio_result *result) |
427 |
| -{ |
428 |
| - if (result->pending) |
429 |
| - { |
430 |
| - struct aio_result_t *tmp; |
431 |
| - for (;;) |
432 |
| - { |
433 |
| - if ((int) (tmp=aiowait((struct timeval *) 0)) == -1) |
434 |
| - { |
435 |
| - if (errno == EINTR) |
436 |
| - continue; |
437 |
| - DBUG_PRINT("error",("No aio request, error: %d",errno)); |
438 |
| - result->pending=0; /* Assume everything is ok */ |
439 |
| - break; |
440 |
| - } |
441 |
| - ((my_aio_result*) tmp)->pending=0; |
442 |
| - if ((my_aio_result*) tmp == result) |
443 |
| - break; |
444 |
| - } |
445 |
| - } |
446 |
| - return; |
447 |
| -} |
448 |
| -#endif |
449 |
| - |
450 | 409 |
|
451 | 410 | /*
|
452 | 411 | 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,
|
499 | 458 | info->write_pos=pos;
|
500 | 459 | else
|
501 | 460 | info->read_pos= pos;
|
502 |
| -#ifdef HAVE_AIOWAIT |
503 |
| - my_aiowait(&info->aio_result); /* Wait for outstanding req */ |
504 |
| -#endif |
505 | 461 | }
|
506 | 462 | else
|
507 | 463 | {
|
@@ -556,18 +512,6 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
|
556 | 512 | info->type=type;
|
557 | 513 | info->error=0;
|
558 | 514 | init_functions(info);
|
559 |
| - |
560 |
| -#ifdef HAVE_AIOWAIT |
561 |
| - if (use_async_io && ! my_disable_async_io && |
562 |
| - ((ulong) info->buffer_length < |
563 |
| - (ulong) (info->end_of_file - seek_offset))) |
564 |
| - { |
565 |
| - DBUG_ASSERT(!(cache_myflags & MY_ENCRYPT)); |
566 |
| - info->read_length=info->buffer_length/2; |
567 |
| - info->read_function=_my_b_async_read; |
568 |
| - } |
569 |
| - info->inited=0; |
570 |
| -#endif |
571 | 515 | DBUG_RETURN(0);
|
572 | 516 | } /* reinit_io_cache */
|
573 | 517 |
|
@@ -1533,193 +1477,6 @@ static int _my_b_seq_read(IO_CACHE *info, uchar *Buffer, size_t Count)
|
1533 | 1477 | }
|
1534 | 1478 |
|
1535 | 1479 |
|
1536 |
| -#ifdef HAVE_AIOWAIT |
1537 |
| - |
1538 |
| -/* |
1539 |
| - Read from the IO_CACHE into a buffer and feed asynchronously |
1540 |
| - from disk when needed. |
1541 |
| -
|
1542 |
| - SYNOPSIS |
1543 |
| - _my_b_async_read() |
1544 |
| - info IO_CACHE pointer |
1545 |
| - Buffer Buffer to retrieve count bytes from file |
1546 |
| - Count Number of bytes to read into Buffer |
1547 |
| -
|
1548 |
| - RETURN VALUE |
1549 |
| - -1 An error has occurred; my_errno is set. |
1550 |
| - 0 Success |
1551 |
| - 1 An error has occurred; IO_CACHE to error state. |
1552 |
| -*/ |
1553 |
| - |
1554 |
| -int _my_b_async_read(IO_CACHE *info, uchar *Buffer, size_t Count) |
1555 |
| -{ |
1556 |
| - size_t length, read_length, diff_length, left_length=0, use_length, org_Count; |
1557 |
| - size_t max_length; |
1558 |
| - my_off_t next_pos_in_file; |
1559 |
| - uchar *read_buffer; |
1560 |
| - |
1561 |
| - org_Count=Count; |
1562 |
| - |
1563 |
| - if (info->inited) |
1564 |
| - { /* wait for read block */ |
1565 |
| - info->inited=0; /* No more block to read */ |
1566 |
| - my_aiowait(&info->aio_result); /* Wait for outstanding req */ |
1567 |
| - if (info->aio_result.result.aio_errno) |
1568 |
| - { |
1569 |
| - if (info->myflags & MY_WME) |
1570 |
| - my_error(EE_READ, MYF(ME_BELL), my_filename(info->file), |
1571 |
| - info->aio_result.result.aio_errno); |
1572 |
| - my_errno=info->aio_result.result.aio_errno; |
1573 |
| - info->error= -1; |
1574 |
| - return(1); |
1575 |
| - } |
1576 |
| - if (! (read_length= (size_t) info->aio_result.result.aio_return) || |
1577 |
| - read_length == (size_t) -1) |
1578 |
| - { |
1579 |
| - my_errno=0; /* For testing */ |
1580 |
| - info->error= (read_length == (size_t) -1 ? -1 : |
1581 |
| - (int) (read_length+left_length)); |
1582 |
| - return(1); |
1583 |
| - } |
1584 |
| - info->pos_in_file+= (size_t) (info->read_end - info->request_pos); |
1585 |
| - |
1586 |
| - if (info->request_pos != info->buffer) |
1587 |
| - info->request_pos=info->buffer; |
1588 |
| - else |
1589 |
| - info->request_pos=info->buffer+info->read_length; |
1590 |
| - info->read_pos=info->request_pos; |
1591 |
| - next_pos_in_file=info->aio_read_pos+read_length; |
1592 |
| - |
1593 |
| - /* Check if pos_in_file is changed |
1594 |
| - (_ni_read_cache may have skipped some bytes) */ |
1595 |
| - |
1596 |
| - if (info->aio_read_pos < info->pos_in_file) |
1597 |
| - { /* Fix if skipped bytes */ |
1598 |
| - if (info->aio_read_pos + read_length < info->pos_in_file) |
1599 |
| - { |
1600 |
| - read_length=0; /* Skip block */ |
1601 |
| - next_pos_in_file=info->pos_in_file; |
1602 |
| - } |
1603 |
| - else |
1604 |
| - { |
1605 |
| - my_off_t offset= (info->pos_in_file - info->aio_read_pos); |
1606 |
| - info->pos_in_file=info->aio_read_pos; /* Whe are here */ |
1607 |
| - info->read_pos=info->request_pos+offset; |
1608 |
| - read_length-=offset; /* Bytes left from read_pos */ |
1609 |
| - } |
1610 |
| - } |
1611 |
| -#ifndef DBUG_OFF |
1612 |
| - if (info->aio_read_pos > info->pos_in_file) |
1613 |
| - { |
1614 |
| - my_errno=EINVAL; |
1615 |
| - return(info->read_length= (size_t) -1); |
1616 |
| - } |
1617 |
| -#endif |
1618 |
| - /* Copy found bytes to buffer */ |
1619 |
| - length=MY_MIN(Count,read_length); |
1620 |
| - memcpy(Buffer,info->read_pos,(size_t) length); |
1621 |
| - Buffer+=length; |
1622 |
| - Count-=length; |
1623 |
| - left_length+=length; |
1624 |
| - info->read_end=info->rc_pos+read_length; |
1625 |
| - info->read_pos+=length; |
1626 |
| - } |
1627 |
| - else |
1628 |
| - next_pos_in_file=(info->pos_in_file+ (size_t) |
1629 |
| - (info->read_end - info->request_pos)); |
1630 |
| - |
1631 |
| - /* If reading large blocks, or first read or read with skip */ |
1632 |
| - if (Count) |
1633 |
| - { |
1634 |
| - if (next_pos_in_file == info->end_of_file) |
1635 |
| - { |
1636 |
| - info->error=(int) (read_length+left_length); |
1637 |
| - return 1; |
1638 |
| - } |
1639 |
| - |
1640 |
| - if (mysql_file_seek(info->file, next_pos_in_file, MY_SEEK_SET, MYF(0)) |
1641 |
| - == MY_FILEPOS_ERROR) |
1642 |
| - { |
1643 |
| - info->error= -1; |
1644 |
| - return (1); |
1645 |
| - } |
1646 |
| - |
1647 |
| - read_length=IO_SIZE*2- (size_t) (next_pos_in_file & (IO_SIZE-1)); |
1648 |
| - if (Count < read_length) |
1649 |
| - { /* Small block, read to cache */ |
1650 |
| - if ((read_length=mysql_file_read(info->file,info->request_pos, |
1651 |
| - read_length, info->myflags)) == (size_t) -1) |
1652 |
| - return info->error= -1; |
1653 |
| - use_length=MY_MIN(Count,read_length); |
1654 |
| - memcpy(Buffer,info->request_pos,(size_t) use_length); |
1655 |
| - info->read_pos=info->request_pos+Count; |
1656 |
| - info->read_end=info->request_pos+read_length; |
1657 |
| - info->pos_in_file=next_pos_in_file; /* Start of block in cache */ |
1658 |
| - next_pos_in_file+=read_length; |
1659 |
| - |
1660 |
| - if (Count != use_length) |
1661 |
| - { /* Didn't find hole block */ |
1662 |
| - if (info->myflags & (MY_WME | MY_FAE | MY_FNABP) && Count != org_Count) |
1663 |
| - my_error(EE_EOFERR, MYF(ME_BELL), my_filename(info->file), my_errno); |
1664 |
| - info->error=(int) (read_length+left_length); |
1665 |
| - return 1; |
1666 |
| - } |
1667 |
| - } |
1668 |
| - else |
1669 |
| - { /* Big block, don't cache it */ |
1670 |
| - if ((read_length= mysql_file_read(info->file, Buffer, Count,info->myflags)) |
1671 |
| - != Count) |
1672 |
| - { |
1673 |
| - info->error= read_length == (size_t) -1 ? -1 : read_length+left_length; |
1674 |
| - return 1; |
1675 |
| - } |
1676 |
| - info->read_pos=info->read_end=info->request_pos; |
1677 |
| - info->pos_in_file=(next_pos_in_file+=Count); |
1678 |
| - } |
1679 |
| - } |
1680 |
| - |
1681 |
| - /* Read next block with asyncronic io */ |
1682 |
| - diff_length=(next_pos_in_file & (IO_SIZE-1)); |
1683 |
| - max_length= info->read_length - diff_length; |
1684 |
| - if (max_length > info->end_of_file - next_pos_in_file) |
1685 |
| - max_length= (size_t) (info->end_of_file - next_pos_in_file); |
1686 |
| - |
1687 |
| - if (info->request_pos != info->buffer) |
1688 |
| - read_buffer=info->buffer; |
1689 |
| - else |
1690 |
| - read_buffer=info->buffer+info->read_length; |
1691 |
| - info->aio_read_pos=next_pos_in_file; |
1692 |
| - if (max_length) |
1693 |
| - { |
1694 |
| - info->aio_result.result.aio_errno=AIO_INPROGRESS; /* Marker for test */ |
1695 |
| - DBUG_PRINT("aioread",("filepos: %ld length: %lu", |
1696 |
| - (ulong) next_pos_in_file, (ulong) max_length)); |
1697 |
| - if (aioread(info->file,read_buffer, max_length, |
1698 |
| - (my_off_t) next_pos_in_file,MY_SEEK_SET, |
1699 |
| - &info->aio_result.result)) |
1700 |
| - { /* Skip async io */ |
1701 |
| - my_errno=errno; |
1702 |
| - DBUG_PRINT("error",("got error: %d, aio_result: %d from aioread, async skipped", |
1703 |
| - errno, info->aio_result.result.aio_errno)); |
1704 |
| - if (info->request_pos != info->buffer) |
1705 |
| - { |
1706 |
| - bmove(info->buffer,info->request_pos, |
1707 |
| - (size_t) (info->read_end - info->read_pos)); |
1708 |
| - info->request_pos=info->buffer; |
1709 |
| - info->read_pos-=info->read_length; |
1710 |
| - info->read_end-=info->read_length; |
1711 |
| - } |
1712 |
| - info->read_length=info->buffer_length; /* Use hole buffer */ |
1713 |
| - info->read_function=_my_b_cache_read; /* Use normal IO_READ next */ |
1714 |
| - } |
1715 |
| - else |
1716 |
| - info->inited=info->aio_result.pending=1; |
1717 |
| - } |
1718 |
| - return 0; /* Block read, async in use */ |
1719 |
| -} /* _my_b_async_read */ |
1720 |
| -#endif |
1721 |
| - |
1722 |
| - |
1723 | 1480 | /* Read one byte when buffer is empty */
|
1724 | 1481 |
|
1725 | 1482 | 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)
|
1978 | 1735 | DBUG_RETURN(info->error);
|
1979 | 1736 | }
|
1980 | 1737 | }
|
1981 |
| -#ifdef HAVE_AIOWAIT |
1982 |
| - else if (info->type != READ_NET) |
1983 |
| - { |
1984 |
| - my_aiowait(&info->aio_result); /* Wait for outstanding req */ |
1985 |
| - info->inited=0; |
1986 |
| - } |
1987 |
| -#endif |
1988 | 1738 | UNLOCK_APPEND_BUFFER;
|
1989 | 1739 | DBUG_RETURN(0);
|
1990 | 1740 | }
|
|
0 commit comments