Skip to content

Commit 838b35b

Browse files
committed
io_uring/rw: disable IOCB_DIO_CALLER_COMP
If an application does O_DIRECT writes with io_uring and the file system supports IOCB_DIO_CALLER_COMP, then completions of the dio write side is done from the task_work that will post the completion event for said write as well. Whenever a dio write is done against a file, the inode i_dio_count is elevated. This enables other callers to use inode_dio_wait() to wait for previous writes to complete. If we defer the full dio completion to task_work, we are dependent on that task_work being run before the inode i_dio_count can be decremented. If the same task that issues io_uring dio writes with IOCB_DIO_CALLER_COMP performs a synchronous system call that calls inode_dio_wait(), then we can deadlock as we're blocked sleeping on the event to become true, but not processing the completions that will result in the inode i_dio_count being decremented. Until we can guarantee that this is the case, then disable the deferred caller completions. Fixes: 099ada2 ("io_uring/rw: add write support for IOCB_DIO_CALLER_COMP") Reported-by: Andres Freund <andres@anarazel.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 7644b1a commit 838b35b

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

io_uring/rw.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -913,15 +913,6 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)
913913
kiocb_start_write(kiocb);
914914
kiocb->ki_flags |= IOCB_WRITE;
915915

916-
/*
917-
* For non-polled IO, set IOCB_DIO_CALLER_COMP, stating that our handler
918-
* groks deferring the completion to task context. This isn't
919-
* necessary and useful for polled IO as that can always complete
920-
* directly.
921-
*/
922-
if (!(kiocb->ki_flags & IOCB_HIPRI))
923-
kiocb->ki_flags |= IOCB_DIO_CALLER_COMP;
924-
925916
if (likely(req->file->f_op->write_iter))
926917
ret2 = call_write_iter(req->file, kiocb, &s->iter);
927918
else if (req->file->f_op->write)

0 commit comments

Comments
 (0)