Commit 6bf9c47
committed
io_uring: defer file assignment
If an application uses direct open or accept, it knows in advance what
direct descriptor value it will get as it picks it itself. This allows
combined requests such as:
sqe = io_uring_get_sqe(ring);
io_uring_prep_openat_direct(sqe, ..., file_slot);
sqe->flags |= IOSQE_IO_LINK | IOSQE_CQE_SKIP_SUCCESS;
sqe = io_uring_get_sqe(ring);
io_uring_prep_read(sqe,file_slot, buf, buf_size, 0);
sqe->flags |= IOSQE_FIXED_FILE;
io_uring_submit(ring);
where we prepare both a file open and read, and only get a completion
event for the read when both have completed successfully.
Currently links are fully prepared before the head is issued, but that
fails if the dependent link needs a file assigned that isn't valid until
the head has completed.
Conversely, if the same chain is performed but the fixed file slot is
already valid, then we would be unexpectedly returning data from the
old file slot rather than the newly opened one. Make sure we're
consistent here.
Allow deferral of file setup, which makes this documented case work.
Cc: [email protected] # v5.15+
Signed-off-by: Jens Axboe <[email protected]>1 parent 5106dd6 commit 6bf9c47
2 files changed
+30
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7240 | 7240 | | |
7241 | 7241 | | |
7242 | 7242 | | |
| 7243 | + | |
| 7244 | + | |
| 7245 | + | |
| 7246 | + | |
| 7247 | + | |
| 7248 | + | |
| 7249 | + | |
| 7250 | + | |
| 7251 | + | |
| 7252 | + | |
| 7253 | + | |
| 7254 | + | |
| 7255 | + | |
| 7256 | + | |
| 7257 | + | |
| 7258 | + | |
| 7259 | + | |
7243 | 7260 | | |
7244 | 7261 | | |
7245 | 7262 | | |
| |||
7250 | 7267 | | |
7251 | 7268 | | |
7252 | 7269 | | |
| 7270 | + | |
| 7271 | + | |
7253 | 7272 | | |
7254 | 7273 | | |
7255 | 7274 | | |
| |||
7394 | 7413 | | |
7395 | 7414 | | |
7396 | 7415 | | |
| 7416 | + | |
7397 | 7417 | | |
7398 | 7418 | | |
7399 | 7419 | | |
7400 | | - | |
| 7420 | + | |
7401 | 7421 | | |
7402 | 7422 | | |
7403 | 7423 | | |
| |||
7409 | 7429 | | |
7410 | 7430 | | |
7411 | 7431 | | |
| 7432 | + | |
| 7433 | + | |
| 7434 | + | |
| 7435 | + | |
| 7436 | + | |
7412 | 7437 | | |
7413 | 7438 | | |
7414 | | - | |
| 7439 | + | |
7415 | 7440 | | |
7416 | 7441 | | |
7417 | 7442 | | |
7418 | 7443 | | |
7419 | | - | |
7420 | 7444 | | |
7421 | 7445 | | |
7422 | 7446 | | |
| |||
7749 | 7773 | | |
7750 | 7774 | | |
7751 | 7775 | | |
| 7776 | + | |
| 7777 | + | |
7752 | 7778 | | |
7753 | 7779 | | |
7754 | 7780 | | |
| |||
7758 | 7784 | | |
7759 | 7785 | | |
7760 | 7786 | | |
7761 | | - | |
7762 | | - | |
7763 | | - | |
7764 | | - | |
7765 | | - | |
7766 | | - | |
7767 | | - | |
7768 | 7787 | | |
7769 | 7788 | | |
7770 | 7789 | | |
| |||
0 commit comments