@@ -3951,7 +3951,7 @@ aio_io_poll(void *arg)
3951
3951
{
3952
3952
struct aio_fsdev_io * vfsdev_io , * tmp ;
3953
3953
struct aio_io_channel * ch = arg ;
3954
- TAILQ_HEAD (, aio_fsdev_io ) ios = TAILQ_HEAD_INITIALIZER (ios );
3954
+ TAILQ_HEAD (aio_tmp_list , aio_fsdev_io ) ios = TAILQ_HEAD_INITIALIZER (ios );
3955
3955
struct io_event events [32 ];
3956
3956
struct iocb * iocbs [32 ];
3957
3957
long to_submit = 0 ;
@@ -3978,29 +3978,30 @@ aio_io_poll(void *arg)
3978
3978
struct spdk_fsdev_io * fsdev_io = aio_to_fsdev_io (vfsdev_io );
3979
3979
enum spdk_fsdev_io_type type = spdk_fsdev_io_get_type (fsdev_io );
3980
3980
3981
- TAILQ_REMOVE (& ios , vfsdev_io , link );
3982
-
3983
3981
rc = - EOPNOTSUPP ;
3984
3982
res = SPDK_POLLER_BUSY ;
3985
3983
3986
3984
switch (type ) {
3987
3985
case SPDK_FSDEV_IO_READ :
3988
3986
case SPDK_FSDEV_IO_WRITE :
3989
- TAILQ_INSERT_TAIL (& ch -> ios_in_progress , vfsdev_io , link );
3990
3987
iocbs [to_submit ++ ] = & vfsdev_io -> io ;
3991
3988
rc = IO_STATUS_ASYNC ;
3992
3989
break ;
3993
3990
case SPDK_FSDEV_IO_POLL :
3991
+ TAILQ_REMOVE (& ios , vfsdev_io , link );
3994
3992
rc = fsdev_aio_do_poll (ch , fsdev_io );
3995
3993
break ;
3996
3994
case SPDK_FSDEV_IO_SETLK :
3995
+ TAILQ_REMOVE (& ios , vfsdev_io , link );
3997
3996
rc = fsdev_aio_do_setlk (ch , fsdev_io );
3998
3997
break ;
3999
3998
default :
3999
+ TAILQ_REMOVE (& ios , vfsdev_io , link );
4000
4000
break ;
4001
4001
}
4002
4002
4003
4003
if (rc != IO_STATUS_ASYNC ) {
4004
+ vfsdev_io -> status = rc ;
4004
4005
TAILQ_INSERT_TAIL (& ch -> ios_to_complete , vfsdev_io , link );
4005
4006
}
4006
4007
@@ -4011,9 +4012,42 @@ aio_io_poll(void *arg)
4011
4012
4012
4013
if (to_submit > 0 ) {
4013
4014
rc = io_submit (ch -> io_ctx , to_submit , iocbs );
4014
- if (rc < to_submit ) {
4015
- /* TODO: Need to handle this error. Just blow up for now. */
4016
- assert (false);
4015
+ if (rc < 0 ) {
4016
+ res = rc ;
4017
+ rc = 0 ; /* 0 were submitted. This will get them all queued back up. */
4018
+
4019
+ if (res != - EAGAIN ) {
4020
+ /* The failures typically apply to the first iocb. Fail that one, but let the others
4021
+ * queue back up to be resubmitted. */
4022
+ SPDK_ERRLOG ("Failed io_submit: %s (%d)\n" , spdk_strerror (- res ), res );
4023
+ vfsdev_io = TAILQ_FIRST (& ios );
4024
+ TAILQ_REMOVE (& ios , vfsdev_io , link );
4025
+ vfsdev_io -> status = res ;
4026
+ TAILQ_INSERT_TAIL (& ch -> ios_to_complete , vfsdev_io , link );
4027
+ }
4028
+ }
4029
+
4030
+ /* For each request actually submitted, shift it into the in progress list. */
4031
+ i = 0 ;
4032
+ TAILQ_FOREACH_SAFE (vfsdev_io , & ios , link , tmp ) {
4033
+ if (i == rc ) {
4034
+ break ;
4035
+ }
4036
+
4037
+ assert (& vfsdev_io -> io == iocbs [i ]);
4038
+
4039
+ TAILQ_REMOVE (& ios , vfsdev_io , link );
4040
+ TAILQ_INSERT_TAIL (& ch -> ios_in_progress , vfsdev_io , link );
4041
+
4042
+ i ++ ;
4043
+ }
4044
+
4045
+ /* For all remaining requests, put them back into the ios_for_submit list */
4046
+ vfsdev_io = TAILQ_LAST (& ios , aio_tmp_list );
4047
+ while (vfsdev_io != NULL ) {
4048
+ TAILQ_REMOVE (& ios , vfsdev_io , link );
4049
+ TAILQ_INSERT_HEAD (& ch -> ios_for_submit , vfsdev_io , link );
4050
+ vfsdev_io = TAILQ_LAST (& ios , aio_tmp_list );
4017
4051
}
4018
4052
}
4019
4053
0 commit comments