Skip to content

Commit 7f3922a

Browse files
committed
aio-stress: fix opened fd leak
In cases where worker completes specified number of `iterations` before oper completes all `total_ios`, such oper remains on active_list. This is a problem because cleanup only walks over finished list, and closes fds only for items on this list. So it's possible for test to exhaust ulimit for open files and fail: $ ./aio-stress -a1 -I100 -o2 -r4 -f1 -d1^ aio-stress.c:1347: TPASS: Test passed aio-stress.c:1285: TINFO: starting with random write aio-stress.c:1296: TINFO: file size 1024MB, record size 0KB, depth 1, I/O per iteration 1 aio-stress.c:1298: TINFO: max io_submit 1, buffer alignment set to 4KB aio-stress.c:1300: TINFO: threads 1 files 1 contexts 1 context offset 2MB verification off aio-stress.c:1314: TBROK: open(file0.bin,1052738,0600) failed: EMFILE (24) Clean/free also items from active_list. Also don't let `status` from cleanup be set to zero once it becomes non-zero. Signed-off-by: Jan Stancek <[email protected]> Acked-by: Andrea Cervesato <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]>
1 parent 325f519 commit 7f3922a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

testcases/kernel/io/ltp-aiodio/aio-stress.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,12 @@ static int *worker(struct thread_info *t)
11221122
while (t->finished_opers) {
11231123
oper = t->finished_opers;
11241124
oper_list_del(oper, &t->finished_opers);
1125-
status = finish_oper(t, oper);
1125+
status = finish_oper(t, oper) ? : status;
1126+
}
1127+
while (t->active_opers) {
1128+
oper = t->active_opers;
1129+
oper_list_del(oper, &t->active_opers);
1130+
status = finish_oper(t, oper) ? : status;
11261131
}
11271132

11281133
if (t->num_global_pending)

0 commit comments

Comments
 (0)