c++ - io_getevents returns less number of jobs than requested in time shorter than timout -
i reading ssd, requesting 20 async jobs. io_getevents returned value 7 indicating timed out. timeout set 10 seconds seen below. elapsed time of call 4.89e-05 seconds, eg, there still 10 seconds left. question: had incident that? if did have found solution?
here part of code:
struct timespec ts = { 10, 0 } ; /* ten seconds delay */ const long ec = io_getevents( ctx, num_jobs, num_jobs, &events[ 0 ], &ts ) ;
when ec returned 7, ts.tv_sec = 10
, ts.tv_nsec = 0
linux kernel:
linux vtl80-g-1j4-823-21 2.6.18-274.18.1.el5 #1 smp thu feb 9 12:20:03 est 2012 x86_64 x86_64 x86_64 gnu/linux
your appreciated! btw. not able check post earlier in few hours.
by putting steps, , debugging outputs figure out there problem aio driver on our linux (5.3 carthage, 2.6.18-128.el5)
solution applied (i'm putting in in case runs in the same problem) this:
(we count elapsed seconds call outselves.)
1) if see error returned io_getevents()
report it. done.
2) if see 0 jobs finished , elapsed seconds count ourselves went above expected 1 report error. done. otherwise continue (we not change timeout on io_getevents()
)
3) if jobs finished, analyze res
error (negative value), , if there failing job report it. done.
4) if there remaining jobs, reset timer (yes, again wait 'expected' time) , continue.
with method report error if io_getevents()
reported error or of jobs reported error. in worst case scenario, when each job returns ok after whole t-epsilon wait time, whole process take n * t time complete.
i hope find useful.
blessings,
greg.
example:
struct timespec tmcountstart ; unsigned seconds_delay = seconds_delay ; clock_gettime( clock_realtime, &tmcountstart ) ; while ( num_remaining_jobs > 0 ) { struct timespec ts = { seconds_delay, 0 } ; struct io_event events[ num_remaining_jobs ] ; long ec ; { ec = io_getevents( ctx, num_remaining_jobs, num_remaining_jobs, &events[ 0 ], &ts ) ; } while( ec == -eintr ) ; if ( ec < 0 ) throw exception reporting error ec. cancel remaining jobs else if ( ec == 0 ) { const double elapsed = count elapsed seconds tmcountstart seconds_delay = seconds_delay - static_cast< unsigned >( elapsed ) ; if ( seconds_delay > seconds_delay ) throw exception reporting timeout. cancel remaining jobs } else // got jobs back. may not of them { ( int = 0 ; < ec ; i++ ) if (( int64_t )events[ ].res < 0 ) throw exception reporting failing job. cancel remaining jobs. num_remaining_jobs -= ec ; if ( num_remaining_jobs > 0 ) { clock_gettime( clock_realtime, &tmcountstart ) ; // reset timer. seconds_delay = seconds_delay ; } } }
Comments
Post a Comment