Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'io_uring-5.12-2021-04-02' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:
"Nothing really major in here, and finally nothing really related to
signals. A few minor fixups related to the threading changes, and some
general fixes, that's it.

There's the pending gdb-get-confused-about-arch, but that's more of a
cosmetic issue, nothing that hinder use of it. And given that other
archs will likely be affected by that oddity too, better to postpone
any changes there until 5.13 imho"

* tag 'io_uring-5.12-2021-04-02' of git://git.kernel.dk/linux-block:
io_uring: move reissue into regular IO path
io_uring: fix EIOCBQUEUED iter revert
io_uring/io-wq: protect against sprintf overflow
io_uring: don't mark S_ISBLK async work as unbounded
io_uring: drop sqd lock before handling signals for SQPOLL
io_uring: handle setup-failed ctx in kill_timeouts
io_uring: always go for cancellation spin on exec

+32 -22
+2 -2
fs/io-wq.c
··· 484 484 worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING); 485 485 io_wqe_inc_running(worker); 486 486 487 - sprintf(buf, "iou-wrk-%d", wq->task_pid); 487 + snprintf(buf, sizeof(buf), "iou-wrk-%d", wq->task_pid); 488 488 set_task_comm(current, buf); 489 489 490 490 while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)) { ··· 711 711 char buf[TASK_COMM_LEN]; 712 712 int node; 713 713 714 - sprintf(buf, "iou-mgr-%d", wq->task_pid); 714 + snprintf(buf, sizeof(buf), "iou-mgr-%d", wq->task_pid); 715 715 set_task_comm(current, buf); 716 716 717 717 do {
+30 -20
fs/io_uring.c
··· 697 697 REQ_F_NO_FILE_TABLE_BIT, 698 698 REQ_F_LTIMEOUT_ACTIVE_BIT, 699 699 REQ_F_COMPLETE_INLINE_BIT, 700 + REQ_F_REISSUE_BIT, 700 701 701 702 /* not a real bit, just to check we're not overflowing the space */ 702 703 __REQ_F_LAST_BIT, ··· 741 740 REQ_F_LTIMEOUT_ACTIVE = BIT(REQ_F_LTIMEOUT_ACTIVE_BIT), 742 741 /* completion is deferred through io_comp_state */ 743 742 REQ_F_COMPLETE_INLINE = BIT(REQ_F_COMPLETE_INLINE_BIT), 743 + /* caller should reissue async */ 744 + REQ_F_REISSUE = BIT(REQ_F_REISSUE_BIT), 744 745 }; 745 746 746 747 struct async_poll { ··· 1216 1213 if (req->flags & REQ_F_ISREG) { 1217 1214 if (def->hash_reg_file || (ctx->flags & IORING_SETUP_IOPOLL)) 1218 1215 io_wq_hash_work(&req->work, file_inode(req->file)); 1219 - } else { 1216 + } else if (!req->file || !S_ISBLK(file_inode(req->file)->i_mode)) { 1220 1217 if (def->unbound_nonreg_file) 1221 1218 req->work.flags |= IO_WQ_WORK_UNBOUND; 1222 1219 } ··· 2506 2503 2507 2504 if (req->rw.kiocb.ki_flags & IOCB_WRITE) 2508 2505 kiocb_end_write(req); 2509 - if ((res == -EAGAIN || res == -EOPNOTSUPP) && io_rw_reissue(req)) 2506 + if ((res == -EAGAIN || res == -EOPNOTSUPP) && io_rw_should_reissue(req)) { 2507 + req->flags |= REQ_F_REISSUE; 2510 2508 return; 2509 + } 2511 2510 if (res != req->result) 2512 2511 req_set_fail_links(req); 2513 2512 if (req->flags & REQ_F_BUFFER_SELECTED) ··· 3288 3283 3289 3284 ret = io_iter_do_read(req, iter); 3290 3285 3291 - if (ret == -EIOCBQUEUED) { 3292 - if (req->async_data) 3293 - iov_iter_revert(iter, io_size - iov_iter_count(iter)); 3294 - goto out_free; 3295 - } else if (ret == -EAGAIN) { 3286 + if (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) { 3296 3287 /* IOPOLL retry should happen for io-wq threads */ 3297 3288 if (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL)) 3298 3289 goto done; ··· 3298 3297 /* some cases will consume bytes even on error returns */ 3299 3298 iov_iter_revert(iter, io_size - iov_iter_count(iter)); 3300 3299 ret = 0; 3300 + } else if (ret == -EIOCBQUEUED) { 3301 + goto out_free; 3301 3302 } else if (ret <= 0 || ret == io_size || !force_nonblock || 3302 3303 (req->flags & REQ_F_NOWAIT) || !(req->flags & REQ_F_ISREG)) { 3303 3304 /* read all, failed, already did sync or don't want to retry */ ··· 3412 3409 else 3413 3410 ret2 = -EINVAL; 3414 3411 3412 + if (req->flags & REQ_F_REISSUE) 3413 + ret2 = -EAGAIN; 3414 + 3415 3415 /* 3416 3416 * Raw bdev writes will return -EOPNOTSUPP for IOCB_NOWAIT. Just 3417 3417 * retry them without IOCB_NOWAIT. ··· 3424 3418 /* no retry on NONBLOCK nor RWF_NOWAIT */ 3425 3419 if (ret2 == -EAGAIN && (req->flags & REQ_F_NOWAIT)) 3426 3420 goto done; 3427 - if (ret2 == -EIOCBQUEUED && req->async_data) 3428 - iov_iter_revert(iter, io_size - iov_iter_count(iter)); 3429 3421 if (!force_nonblock || ret2 != -EAGAIN) { 3430 3422 /* IOPOLL retry should happen for io-wq threads */ 3431 3423 if ((req->ctx->flags & IORING_SETUP_IOPOLL) && ret2 == -EAGAIN) ··· 6168 6164 ret = -ECANCELED; 6169 6165 6170 6166 if (!ret) { 6167 + req->flags &= ~REQ_F_REISSUE; 6171 6168 do { 6172 6169 ret = io_issue_sqe(req, 0); 6173 6170 /* ··· 6723 6718 char buf[TASK_COMM_LEN]; 6724 6719 DEFINE_WAIT(wait); 6725 6720 6726 - sprintf(buf, "iou-sqp-%d", sqd->task_pid); 6721 + snprintf(buf, sizeof(buf), "iou-sqp-%d", sqd->task_pid); 6727 6722 set_task_comm(current, buf); 6728 6723 current->pf_io_worker = NULL; 6729 6724 ··· 6738 6733 int ret; 6739 6734 bool cap_entries, sqt_spin, needs_sched; 6740 6735 6741 - if (test_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state)) { 6736 + if (test_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state) || 6737 + signal_pending(current)) { 6738 + bool did_sig = false; 6739 + 6742 6740 mutex_unlock(&sqd->lock); 6741 + if (signal_pending(current)) { 6742 + struct ksignal ksig; 6743 + 6744 + did_sig = get_signal(&ksig); 6745 + } 6743 6746 cond_resched(); 6744 6747 mutex_lock(&sqd->lock); 6748 + if (did_sig) 6749 + break; 6745 6750 io_run_task_work(); 6746 6751 io_run_task_work_head(&sqd->park_task_work); 6747 6752 timeout = jiffies + sqd->sq_thread_idle; 6748 6753 continue; 6749 - } 6750 - if (signal_pending(current)) { 6751 - struct ksignal ksig; 6752 - 6753 - if (!get_signal(&ksig)) 6754 - continue; 6755 - break; 6756 6754 } 6757 6755 sqt_spin = false; 6758 6756 cap_entries = !list_is_singular(&sqd->ctx_list); ··· 8611 8603 canceled++; 8612 8604 } 8613 8605 } 8614 - io_commit_cqring(ctx); 8606 + if (canceled != 0) 8607 + io_commit_cqring(ctx); 8615 8608 spin_unlock_irq(&ctx->completion_lock); 8616 - 8617 8609 if (canceled != 0) 8618 8610 io_cqring_ev_posted(ctx); 8619 8611 return canceled != 0; ··· 9010 9002 9011 9003 /* make sure overflow events are dropped */ 9012 9004 atomic_inc(&tctx->in_idle); 9005 + __io_uring_files_cancel(NULL); 9006 + 9013 9007 do { 9014 9008 /* read completions before cancelations */ 9015 9009 inflight = tctx_inflight(tctx);