According to the manpages io_submit() can return the value:
EAGAIN Insufficient resources are available to queue any iocbs.
We should handle this opportunely trying to re-submit the AIO request
again. Maybe an even better approach could be to just sleep a bit before
trying to re-submit the request.
In any case this would resolve a never-ending loop in aio01.c, where
io_getevents() can be continuously called without having issued any
actual request if io_submit() failed with -EAGAIN.
Signed-off-by: Andrea Righi <[EMAIL PROTECTED]>
---
diff -urpN ltp/testcases/kernel/io/aio/aio01/aio01.c
ltp-mod/testcases/kernel/io/aio/aio01/aio01.c
--- ltp/testcases/kernel/io/aio/aio01/aio01.c 2008-07-12 13:48:56.000000000
+0200
+++ ltp-mod/testcases/kernel/io/aio/aio01/aio01.c 2008-07-12
13:50:22.000000000 +0200
@@ -131,8 +131,10 @@ int main(int argc, char **argv) {
for(i = 0; i< nr; i++) {
ts.tv_sec = 30;
ts.tv_nsec = 0;
- TEST(io_submit(io_ctx, 1, iocbs));
- if (TEST_RETURN == -1) {
+ do {
+ TEST(io_submit(io_ctx, 1, iocbs));
+ } while (TEST_RETURN == -EAGAIN);
+ if (TEST_RETURN < 0) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "Test 1: io_submit failed - retval=%d, "
"errno=%d", TEST_RETURN, TEST_ERRNO);
@@ -161,8 +163,10 @@ int main(int argc, char **argv) {
for(i = 0; i< nr; i++) {
ts.tv_sec = 30;
ts.tv_nsec = 0;
- TEST(io_submit(io_ctx, 1, iocbs));
- if (TEST_RETURN == -1) {
+ do {
+ TEST(io_submit(io_ctx, 1, iocbs));
+ } while (TEST_RETURN == -EAGAIN);
+ if (TEST_RETURN < 0) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "Test 2: io_submit failed - retval=%d, "
"errno=%d", TEST_RETURN, TEST_ERRNO);
@@ -191,8 +195,10 @@ int main(int argc, char **argv) {
io_prep_pwrite(iocbs[0], fd, srcbuf, bufsize, pos);
ts.tv_sec = 30;
ts.tv_nsec = 0;
- TEST(io_submit(io_ctx, 1, iocbs));
- if (TEST_RETURN == -1) {
+ do {
+ TEST(io_submit(io_ctx, 1, iocbs));
+ } while (TEST_RETURN == -EAGAIN);
+ if (TEST_RETURN < 0) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "Test 3: io_submit failed - retval=%d, "
"errno=%d", TEST_RETURN, TEST_ERRNO);
@@ -221,8 +227,10 @@ int main(int argc, char **argv) {
io_prep_pread(iocbs[0], fd, dstbuf, bufsize, pos);
ts.tv_sec = 30;
ts.tv_nsec = 0;
- TEST(io_submit(io_ctx, 1, iocbs));
- if (TEST_RETURN == -1) {
+ do {
+ TEST(io_submit(io_ctx, 1, iocbs));
+ } while (TEST_RETURN == -EAGAIN);
+ if (TEST_RETURN < 0) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "Test 4: io_submit failed - retval=%d, "
"errno=%d", TEST_RETURN, TEST_ERRNO);
@@ -251,8 +259,10 @@ int main(int argc, char **argv) {
io_prep_pwrite(iocbs[0], fd, srcbuf, bufsize, pos);
ts.tv_sec = 30;
ts.tv_nsec = 0;
- TEST(io_submit(io_ctx, 1, iocbs));
- if (TEST_RETURN == -1) {
+ do {
+ TEST(io_submit(io_ctx, 1, iocbs));
+ } while (TEST_RETURN == -EAGAIN);
+ if (TEST_RETURN < 0) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "Test 5: write io_submit failed - "
"retval=%d, errno=%d", TEST_RETURN,
@@ -264,8 +274,10 @@ int main(int argc, char **argv) {
io_prep_pread(iocbs[0], fd, dstbuf, bufsize, pos);
ts.tv_sec = 30;
ts.tv_nsec = 0;
- TEST(io_submit(io_ctx, 1, iocbs));
- if (TEST_RETURN == -1) {
+ do {
+ TEST(io_submit(io_ctx, 1, iocbs));
+ } while (TEST_RETURN == -EAGAIN);
+ if (TEST_RETURN < 0) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "Test 5: read io_submit failed - "
"retval=%d, errno=%d", TEST_RETURN,
@@ -295,8 +307,10 @@ int main(int argc, char **argv) {
io_prep_pwrite(iocbs[0], fd, srcbuf, bufsize, pos);
ts.tv_sec = 30;
ts.tv_nsec = 0;
- TEST(io_submit(io_ctx, 1, iocbs));
- if (TEST_RETURN == -1) {
+ do {
+ TEST(io_submit(io_ctx, 1, iocbs));
+ } while (TEST_RETURN == -EAGAIN);
+ if (TEST_RETURN < 0) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "Test 6: write io_submit failed - "
"retval=%d, errno=%d", TEST_RETURN,
@@ -308,8 +322,10 @@ int main(int argc, char **argv) {
io_prep_pread(iocbs[0], fd, dstbuf, bufsize, pos);
ts.tv_sec = 30;
ts.tv_nsec = 0;
- TEST(io_submit(io_ctx, 1, iocbs));
- if (TEST_RETURN == -1) {
+ do {
+ TEST(io_submit(io_ctx, 1, iocbs));
+ } while (TEST_RETURN == -EAGAIN);
+ if (TEST_RETURN < 0) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "Test 6: read io_submit failed - "
"retval=%d, errno=%d", TEST_RETURN,
diff -urpN ltp/testcases/kernel/io/aio/aio02/cases/aio_tio.c
ltp-mod/testcases/kernel/io/aio/aio02/cases/aio_tio.c
--- ltp/testcases/kernel/io/aio/aio02/cases/aio_tio.c 2008-07-12
13:48:56.000000000 +0200
+++ ltp-mod/testcases/kernel/io/aio/aio02/cases/aio_tio.c 2008-07-12
14:10:49.000000000 +0200
@@ -153,7 +153,10 @@ int io_tio(char *pathname , int flag , i
}
}
- if (( res = io_submit ( myctx , AIO_MAXIO , iocbps )) < 0 ) {
+ do {
+ res = io_submit(myctx , AIO_MAXIO , iocbps);
+ } while (res == -EAGAIN);
+ if (res < 0 ) {
io_error("io_submit tio", res);
}
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list