Skip to content

test/open-direct-link: fix sporadic -EBADF failure#1621

Merged
axboe merged 1 commit into
axboe:masterfrom
Flowdalic:fix-open-direct-link
Jul 22, 2026
Merged

test/open-direct-link: fix sporadic -EBADF failure#1621
axboe merged 1 commit into
axboe:masterfrom
Flowdalic:fix-open-direct-link

Conversation

@Flowdalic

Copy link
Copy Markdown
Contributor

The test runs consecutive test iterations that chain openat_direct, read, and close_direct operations. Some iterations, like test(1, 0, 0) where skip_success=1, configure the openat and close operations to skip producing CQEs upon success. As a result, the test suite only waits on the CQE generated by the read operation before proceeding to the next test run.

Because the previous iteration's close_direct might still be in-flight or deferred to task_work, and all iterations were hardcoding file index 0, a race condition occurs: an asynchronous close_direct from a prior test run can inadvertently close the newly installed file from a subsequent test run. This causes the newly submitted read operation to unexpectedly fail with -EBADF ("bad read -9").

Fix this by passing an incrementally unique file_idx to each test iteration. This isolates the test iterations and prevents them from racing over the same fixed file descriptor slot.

The test runs consecutive test iterations that chain openat_direct,
read, and close_direct operations. Some iterations, like test(1, 0, 0)
where skip_success=1, configure the openat and close operations to skip
producing CQEs upon success. As a result, the test suite only waits on
the CQE generated by the read operation before proceeding to the next
test run.

Because the previous iteration's close_direct might still be in-flight
or deferred to task_work, and all iterations were hardcoding file index
0, a race condition occurs: an asynchronous close_direct from a prior
test run can inadvertently close the newly installed file from a
subsequent test run. This causes the newly submitted read operation to
unexpectedly fail with -EBADF ("bad read -9").

Fix this by passing an incrementally unique file_idx to each test
iteration. This isolates the test iterations and prevents them from
racing over the same fixed file descriptor slot.

Signed-off-by: Florian Schmaus <florian.schmaus@codasip.com>
@axboe
axboe merged commit d332e4d into axboe:master Jul 22, 2026
20 checks passed
@Flowdalic
Flowdalic deleted the fix-open-direct-link branch July 22, 2026 13:09
@Flowdalic

Copy link
Copy Markdown
Contributor Author

Thanks for the quick merge. Could you please also have a look at #1617 and #1605 which fix also issues we are seeing in our CI setup. Thanks

@axboe

axboe commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Sorry, a bit behind, vacation and still on vacation. Both those look good too, merged.

@Flowdalic

Copy link
Copy Markdown
Contributor Author

Sorry, a bit behind, vacation and still on vacation. Both those look good too, merged.

No worries. Thanks for merging and enjoy your vacation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants