Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost of in-progress I/Os upon io_uring exit #19

Open
jacklee-cuhk opened this issue Nov 27, 2022 · 0 comments
Open

Lost of in-progress I/Os upon io_uring exit #19

jacklee-cuhk opened this issue Nov 27, 2022 · 0 comments

Comments

@jacklee-cuhk
Copy link

The current copy_file() does not wait for all submitted I/O's to complete before returning to main() which the latter closes the files and calls io_uring_queue_exit(). Any I/Os which are still in progress will be lost. This manifests as the output file having fewer bytes than the input file. This is tested and is repeatable in Ubuntu 20 running in a VM under VMWare Workstation, using liburing2_2.1-2build1_amd64.deb.

One way to fix this is to add the following codes before the return statement at the end of copy_file() to wait for all I/Os to complete before returning:

int num_pending = reads + writes; // # of I/O requests still pending.
for (int i=0; i<num_pending; i++) { // Wait for them to complete or else some may be discarded upon premature io_uring exit.
    io_uring_wait_cqe(ring, &cqe);
    io_uring_cqe_get_data(cqe);
    io_uring_cqe_seen(ring, cqe);
}

Cheers,
Jack

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

No branches or pull requests

1 participant