3232
3333#include " P_AIO.h"
3434
35- #if AIO_MODE == AIO_MODE_NATIVE
36-
37- #ifdef HAVE_EVENTFD
38- #include < sys/eventfd.h>
39- #endif
40-
41- #define AIO_PERIOD -HRTIME_MSECONDS(10 )
42- #else
43-
4435#define MAX_DISKS_POSSIBLE 100
4536
4637// globals
@@ -51,7 +42,6 @@ namespace
5142{
5243void setup_prep_ops (IOUringContext *);
5344}
54-
5545#endif
5646
5747/* structure to hold information about each file descriptor */
@@ -64,7 +54,6 @@ int num_filedes = 1;
6454static ink_mutex insert_mutex;
6555
6656int thread_is_created = 0 ;
67- #endif // AIO_MODE == AIO_MODE_NATIVE
6857
6958RecInt cache_config_threads_per_disk = 12 ;
7059RecInt api_config_threads_per_disk = 12 ;
@@ -189,17 +178,12 @@ ink_aio_init(ts::ModuleVersion v, AIOBackend backend)
189178 RecRegisterRawStat (aio_rsb, RECT_PROCESS, " proxy.process.io_uring.completed" , RECD_FLOAT, RECP_PERSISTENT,
190179 (int )AIO_STAT_IO_URING_COMPLETED, aio_stats_cb);
191180#endif
192- # if AIO_MODE == AIO_MODE_DEFAULT
181+
193182 memset (&aio_reqs, 0 , MAX_DISKS_POSSIBLE * sizeof (AIO_Reqs *));
194183 ink_mutex_init (&insert_mutex);
195- # endif
184+
196185 REC_ReadConfigInteger (cache_config_threads_per_disk, " proxy.config.cache.threads_per_disk" );
197- #if TS_USE_LINUX_NATIVE_AIO
198- Warning (
199- " Running with Linux libaio is deprecated. There are known issues with this feature and it is being replaced with io_uring" );
200- #endif
201186
202- #if AIO_MODE == AIO_MODE_DEFAULT
203187#if TS_USE_LINUX_IO_URING
204188 // If the caller specified auto backend, check for config to force a backend
205189 if (backend == AIOBackend::AIO_BACKEND_AUTO) {
@@ -250,11 +234,8 @@ ink_aio_init(ts::ModuleVersion v, AIOBackend backend)
250234 Note (" Using thread for AIO" );
251235 }
252236#endif
253- #endif
254237}
255238
256- #if AIO_MODE == AIO_MODE_DEFAULT
257-
258239struct AIOThreadInfo : public Continuation {
259240 AIO_Reqs *req;
260241 int sleep_wait;
@@ -706,162 +687,3 @@ ink_aio_write(AIOCallback *op_in, int fromAPI)
706687
707688 return 1 ;
708689}
709- #endif
710-
711- #if AIO_MODE == AIO_MODE_NATIVE
712- int
713- DiskHandler::startAIOEvent (int /* event ATS_UNUSED */ , Event *e)
714- {
715- SET_HANDLER (&DiskHandler::mainAIOEvent);
716- e->schedule_every (AIO_PERIOD);
717- trigger_event = e;
718- return EVENT_CONT;
719- }
720-
721- int
722- DiskHandler::mainAIOEvent (int event, Event *e)
723- {
724- AIOCallback *op = nullptr ;
725- Lagain:
726- int ret = io_getevents (ctx, 0 , MAX_AIO_EVENTS, events, nullptr );
727- for (int i = 0 ; i < ret; i++) {
728- op = (AIOCallback *)events[i].data ;
729- op->aio_result = events[i].res ;
730- ink_assert (op->action .continuation );
731- complete_list.enqueue (op);
732- }
733-
734- if (ret == MAX_AIO_EVENTS) {
735- goto Lagain;
736- }
737-
738- if (ret < 0 ) {
739- if (errno == EINTR)
740- goto Lagain;
741- if (errno == EFAULT || errno == ENOSYS)
742- Dbg (_dbg_ctl_aio, " io_getevents failed: %s (%d)" , strerror (-ret), -ret);
743- }
744-
745- ink_aiocb *cbs[MAX_AIO_EVENTS];
746- int num = 0 ;
747-
748- for (; num < MAX_AIO_EVENTS && ((op = ready_list.dequeue ()) != nullptr ); ++num) {
749- cbs[num] = &op->aiocb ;
750- ink_assert (op->action .continuation );
751- }
752-
753- if (num > 0 ) {
754- int ret;
755- do {
756- ret = io_submit (ctx, num, cbs);
757- } while (ret < 0 && ret == -EAGAIN);
758-
759- if (ret != num) {
760- if (ret < 0 ) {
761- Dbg (_dbg_ctl_aio, " io_submit failed: %s (%d)" , strerror (-ret), -ret);
762- } else {
763- Fatal (" could not submit IOs, io_submit(%p, %d, %p) returned %d" , ctx, num, cbs, ret);
764- }
765- }
766- }
767-
768- while ((op = complete_list.dequeue ()) != nullptr ) {
769- op->mutex = op->action .mutex ;
770- MUTEX_TRY_LOCK (lock, op->mutex , trigger_event->ethread );
771- if (!lock.is_locked ()) {
772- trigger_event->ethread ->schedule_imm (op);
773- } else {
774- op->handleEvent (EVENT_NONE, nullptr );
775- }
776- }
777- return EVENT_CONT;
778- }
779-
780- int
781- ink_aio_read (AIOCallback *op, int /* fromAPI ATS_UNUSED */ )
782- {
783- op->aiocb .aio_lio_opcode = IO_CMD_PREAD;
784- op->aiocb .data = op;
785- EThread *t = this_ethread ();
786- #ifdef HAVE_EVENTFD
787- io_set_eventfd (&op->aiocb , t->evfd );
788- #endif
789- t->diskHandler ->ready_list .enqueue (op);
790-
791- return 1 ;
792- }
793-
794- int
795- ink_aio_write (AIOCallback *op, int /* fromAPI ATS_UNUSED */ )
796- {
797- op->aiocb .aio_lio_opcode = IO_CMD_PWRITE;
798- op->aiocb .data = op;
799- EThread *t = this_ethread ();
800- #ifdef HAVE_EVENTFD
801- io_set_eventfd (&op->aiocb , t->evfd );
802- #endif
803- t->diskHandler ->ready_list .enqueue (op);
804-
805- return 1 ;
806- }
807-
808- int
809- ink_aio_readv (AIOCallback *op, int /* fromAPI ATS_UNUSED */ )
810- {
811- EThread *t = this_ethread ();
812- DiskHandler *dh = t->diskHandler ;
813- AIOCallback *io = op;
814- int sz = 0 ;
815-
816- while (io) {
817- io->aiocb .aio_lio_opcode = IO_CMD_PREAD;
818- io->aiocb .data = io;
819- #ifdef HAVE_EVENTFD
820- io_set_eventfd (&op->aiocb , t->evfd );
821- #endif
822- dh->ready_list .enqueue (io);
823- ++sz;
824- io = io->then ;
825- }
826-
827- if (sz > 1 ) {
828- ink_assert (op->action .continuation );
829- AIOVec *vec = new AIOVec (sz, op);
830- while (--sz >= 0 ) {
831- op->action = vec;
832- op = op->then ;
833- }
834- }
835- return 1 ;
836- }
837-
838- int
839- ink_aio_writev (AIOCallback *op, int /* fromAPI ATS_UNUSED */ )
840- {
841- EThread *t = this_ethread ();
842- DiskHandler *dh = t->diskHandler ;
843- AIOCallback *io = op;
844- int sz = 0 ;
845-
846- while (io) {
847- io->aiocb .aio_lio_opcode = IO_CMD_PWRITE;
848- io->aiocb .data = io;
849- #ifdef HAVE_EVENTFD
850- io_set_eventfd (&op->aiocb , t->evfd );
851- #endif
852- dh->ready_list .enqueue (io);
853- ++sz;
854- io = io->then ;
855- }
856-
857- if (sz > 1 ) {
858- ink_assert (op->action .continuation );
859- AIOVec *vec = new AIOVec (sz, op);
860- while (--sz >= 0 ) {
861- op->action = vec;
862- op = op->then ;
863- }
864- }
865- return 1 ;
866- }
867- #endif // AIO_MODE != AIO_MODE_NATIVE
0 commit comments