Pull io_uring fixes from Jens Axboe: - fix for async buffered reads if read-ahead is fully disabled (Hao) - double poll match fix - ->show_fdinfo() potential ABBA deadlock complaint fix * tag 'io_uring-5.9-2020-10-02' of git://git.kernel.dk/linux-block: io_uring: fix async buffered reads when readahead is disabled io_uring: fix potential ABBA deadlock in ->show_fdinfo() io_uring: always delete double poll wait entry on match
Unified · Split
| @@ -3049,6 +3049,7 @@ static int io_async_buf_func(struct wait_queue_entry *wait, unsigned mode, · 3048 unmodified lines | |||
| 3049 | if (!wake_page_match(wpq, key)) | 3049 | if (!wake_page_match(wpq, key)) |
| 3050 | return 0; | 3050 | return 0; |
| 3051 | 3051 | ||
| 3052 | req->rw.kiocb.ki_flags &= ~IOCB_WAITQ; | ||
| 3052 | list_del_init(&wait->entry); | 3053 | list_del_init(&wait->entry); |
| 3053 | 3054 | ||
| 3054 | init_task_work(&req->task_work, io_req_task_submit); | 3055 | init_task_work(&req->task_work, io_req_task_submit); |
| @@ -3106,6 +3107,7 @@ static bool io_rw_should_retry(struct io_kiocb *req) · 51 unmodified lines | |||
| 3106 | wait->wait.flags = 0; | 3107 | wait->wait.flags = 0; |
| 3107 | INIT_LIST_HEAD(&wait->wait.entry); | 3108 | INIT_LIST_HEAD(&wait->wait.entry); |
| 3108 | kiocb->ki_flags |= IOCB_WAITQ; | 3109 | kiocb->ki_flags |= IOCB_WAITQ; |
| 3110 | kiocb->ki_flags &= ~IOCB_NOWAIT; | ||
| 3109 | kiocb->ki_waitq = wait; | 3111 | kiocb->ki_waitq = wait; |
| 3110 | 3112 | ||
| 3111 | io_get_req_task(req); | 3113 | io_get_req_task(req); |
| @@ -4743,6 +4745,8 @@ static int io_poll_double_wake(struct wait_queue_entry *wait, unsigned mode, · 1631 unmodified lines | |||
| 4743 | if (mask && !(mask & poll->events)) | 4745 | if (mask && !(mask & poll->events)) |
| 4744 | return 0; | 4746 | return 0; |
| 4745 | 4747 | ||
| 4748 | list_del_init(&wait->entry); | ||
| 4749 | |||
| 4746 | if (poll && poll->head) { | 4750 | if (poll && poll->head) { |
| 4747 | bool done; | 4751 | bool done; |
| 4748 | 4752 | ||
| @@ -8412,11 +8416,19 @@ static int io_uring_show_cred(int id, void *p, void *data) · 3663 unmodified lines | |||
| 8412 | 8416 | ||
| 8413 | static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) | 8417 | static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) |
| 8414 | { | 8418 | { |
| 8419 | bool has_lock; | ||
| 8415 | int i; | 8420 | int i; |
| 8416 | 8421 | ||
| 8417 | mutex_lock(&ctx->uring_lock); | 8422 | /* |
| 8423 | * Avoid ABBA deadlock between the seq lock and the io_uring mutex, | ||
| 8424 | * since fdinfo case grabs it in the opposite direction of normal use | ||
| 8425 | * cases. If we fail to get the lock, we just don't iterate any | ||
| 8426 | * structures that could be going away outside the io_uring mutex. | ||
| 8427 | */ | ||
| 8428 | has_lock = mutex_trylock(&ctx->uring_lock); | ||
| 8429 | |||
| 8418 | seq_printf(m, "UserFiles:\t%u\n", ctx->nr_user_files); | 8430 | seq_printf(m, "UserFiles:\t%u\n", ctx->nr_user_files); |
| 8419 | for (i = 0; i < ctx->nr_user_files; i++) { | 8431 | for (i = 0; has_lock && i < ctx->nr_user_files; i++) { |
| 8420 | struct fixed_file_table *table; | 8432 | struct fixed_file_table *table; |
| 8421 | struct file *f; | 8433 | struct file *f; |
| 8422 | 8434 | ||
| @@ -8428,13 +8440,13 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) · 5 unmodified lines | |||
| 8428 | seq_printf(m, "%5u: <none>\n", i); | 8440 | seq_printf(m, "%5u: <none>\n", i); |
| 8429 | } | 8441 | } |
| 8430 | seq_printf(m, "UserBufs:\t%u\n", ctx->nr_user_bufs); | 8442 | seq_printf(m, "UserBufs:\t%u\n", ctx->nr_user_bufs); |
| 8431 | for (i = 0; i < ctx->nr_user_bufs; i++) { | 8443 | for (i = 0; has_lock && i < ctx->nr_user_bufs; i++) { |
| 8432 | struct io_mapped_ubuf *buf = &ctx->user_bufs[i]; | 8444 | struct io_mapped_ubuf *buf = &ctx->user_bufs[i]; |
| 8433 | 8445 | ||
| 8434 | seq_printf(m, "%5u: 0x%llx/%u\n", i, buf->ubuf, | 8446 | seq_printf(m, "%5u: 0x%llx/%u\n", i, buf->ubuf, |
| 8435 | (unsigned int) buf->len); | 8447 | (unsigned int) buf->len); |
| 8436 | } | 8448 | } |
| 8437 | if (!idr_is_empty(&ctx->personality_idr)) { | 8449 | if (has_lock && !idr_is_empty(&ctx->personality_idr)) { |
| 8438 | seq_printf(m, "Personalities:\n"); | 8450 | seq_printf(m, "Personalities:\n"); |
| 8439 | idr_for_each(&ctx->personality_idr, io_uring_show_cred, m); | 8451 | idr_for_each(&ctx->personality_idr, io_uring_show_cred, m); |
| 8440 | } | 8452 | } |
| @@ -8449,7 +8461,8 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) · 8 unmodified lines | |||
| 8449 | req->task->task_works != NULL); | 8461 | req->task->task_works != NULL); |
| 8450 | } | 8462 | } |
| 8451 | spin_unlock_irq(&ctx->completion_lock); | 8463 | spin_unlock_irq(&ctx->completion_lock); |
| 8452 | mutex_unlock(&ctx->uring_lock); | 8464 | if (has_lock) |
| 8465 | mutex_unlock(&ctx->uring_lock); | ||
| 8453 | } | 8466 | } |
| 8454 | 8467 | ||
| 8455 | static void io_uring_show_fdinfo(struct seq_file *m, struct file *f) | 8468 | static void io_uring_show_fdinfo(struct seq_file *m, struct file *f) |
| @@ -2365,7 +2365,11 @@ readpage: · 2364 unmodified lines | |||
| 2365 | } | 2365 | } |
| 2366 | 2366 | ||
| 2367 | if (!PageUptodate(page)) { | 2367 | if (!PageUptodate(page)) { |
| 2368 | error = lock_page_killable(page); | 2368 | if (iocb->ki_flags & IOCB_WAITQ) |
| 2369 | error = lock_page_async(page, iocb->ki_waitq); | ||
| 2370 | else | ||
| 2371 | error = lock_page_killable(page); | ||
| 2372 | |||
| 2369 | if (unlikely(error)) | 2373 | if (unlikely(error)) |
| 2370 | goto readpage_error; | 2374 | goto readpage_error; |
| 2371 | if (!PageUptodate(page)) { | 2375 | if (!PageUptodate(page)) { |