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.19-2022-06-24' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:
"A few fixes that should go into the 5.19 release. All are fixing
issues that either happened in this release, or going to stable.

In detail:

- A small series of fixlets for the poll handling, all destined for
stable (Pavel)

- Fix a merge error from myself that caused a potential -EINVAL for
the recv/recvmsg flag setting (me)

- Fix a kbuf recycling issue for partial IO (me)

- Use the original request for the inflight tracking (me)

- Fix an issue introduced this merge window with trace points using a
custom decoder function, which won't work for perf (Dylan)"

* tag 'io_uring-5.19-2022-06-24' of git://git.kernel.dk/linux-block:
io_uring: use original request task for inflight tracking
io_uring: move io_uring_get_opcode out of TP_printk
io_uring: fix double poll leak on repolling
io_uring: fix wrong arm_poll error handling
io_uring: fail links when poll fails
io_uring: fix req->apoll_events
io_uring: fix merge error in checking send/recv addr2 flags
io_uring: mark reissue requests with REQ_F_PARTIAL_IO

+50 -18
+15 -11
fs/io_uring.c
··· 1975 1975 { 1976 1976 if (!(req->flags & REQ_F_INFLIGHT)) { 1977 1977 req->flags |= REQ_F_INFLIGHT; 1978 - atomic_inc(&current->io_uring->inflight_tracked); 1978 + atomic_inc(&req->task->io_uring->inflight_tracked); 1979 1979 } 1980 1980 } 1981 1981 ··· 3437 3437 if (unlikely(res != req->cqe.res)) { 3438 3438 if ((res == -EAGAIN || res == -EOPNOTSUPP) && 3439 3439 io_rw_should_reissue(req)) { 3440 - req->flags |= REQ_F_REISSUE; 3440 + req->flags |= REQ_F_REISSUE | REQ_F_PARTIAL_IO; 3441 3441 return true; 3442 3442 } 3443 3443 req_set_fail(req); ··· 3487 3487 kiocb_end_write(req); 3488 3488 if (unlikely(res != req->cqe.res)) { 3489 3489 if (res == -EAGAIN && io_rw_should_reissue(req)) { 3490 - req->flags |= REQ_F_REISSUE; 3490 + req->flags |= REQ_F_REISSUE | REQ_F_PARTIAL_IO; 3491 3491 return; 3492 3492 } 3493 3493 req->cqe.res = res; ··· 6077 6077 6078 6078 if (unlikely(sqe->file_index)) 6079 6079 return -EINVAL; 6080 - if (unlikely(sqe->addr2 || sqe->file_index)) 6081 - return -EINVAL; 6082 6080 6083 6081 sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr)); 6084 6082 sr->len = READ_ONCE(sqe->len); ··· 6312 6314 struct io_sr_msg *sr = &req->sr_msg; 6313 6315 6314 6316 if (unlikely(sqe->file_index)) 6315 - return -EINVAL; 6316 - if (unlikely(sqe->addr2 || sqe->file_index)) 6317 6317 return -EINVAL; 6318 6318 6319 6319 sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr)); ··· 6950 6954 io_req_complete_failed(req, ret); 6951 6955 } 6952 6956 6953 - static void __io_poll_execute(struct io_kiocb *req, int mask, __poll_t events) 6957 + static void __io_poll_execute(struct io_kiocb *req, int mask, 6958 + __poll_t __maybe_unused events) 6954 6959 { 6955 6960 req->cqe.res = mask; 6956 6961 /* ··· 6960 6963 * CPU. We want to avoid pulling in req->apoll->events for that 6961 6964 * case. 6962 6965 */ 6963 - req->apoll_events = events; 6964 6966 if (req->opcode == IORING_OP_POLL_ADD) 6965 6967 req->io_task_work.func = io_poll_task_func; 6966 6968 else ··· 7110 7114 io_init_poll_iocb(poll, mask, io_poll_wake); 7111 7115 poll->file = req->file; 7112 7116 7117 + req->apoll_events = poll->events; 7118 + 7113 7119 ipt->pt._key = mask; 7114 7120 ipt->req = req; 7115 7121 ipt->error = 0; ··· 7142 7144 7143 7145 if (mask) { 7144 7146 /* can't multishot if failed, just queue the event we've got */ 7145 - if (unlikely(ipt->error || !ipt->nr_entries)) 7147 + if (unlikely(ipt->error || !ipt->nr_entries)) { 7146 7148 poll->events |= EPOLLONESHOT; 7149 + req->apoll_events |= EPOLLONESHOT; 7150 + ipt->error = 0; 7151 + } 7147 7152 __io_poll_execute(req, mask, poll->events); 7148 7153 return 0; 7149 7154 } ··· 7208 7207 mask |= EPOLLEXCLUSIVE; 7209 7208 if (req->flags & REQ_F_POLLED) { 7210 7209 apoll = req->apoll; 7210 + kfree(apoll->double_poll); 7211 7211 } else if (!(issue_flags & IO_URING_F_UNLOCKED) && 7212 7212 !list_empty(&ctx->apoll_cache)) { 7213 7213 apoll = list_first_entry(&ctx->apoll_cache, struct async_poll, ··· 7394 7392 return -EINVAL; 7395 7393 7396 7394 io_req_set_refcount(req); 7397 - req->apoll_events = poll->events = io_poll_parse_events(sqe, flags); 7395 + poll->events = io_poll_parse_events(sqe, flags); 7398 7396 return 0; 7399 7397 } 7400 7398 ··· 7407 7405 ipt.pt._qproc = io_poll_queue_proc; 7408 7406 7409 7407 ret = __io_arm_poll_handler(req, &req->poll, &ipt, poll->events); 7408 + if (!ret && ipt.error) 7409 + req_set_fail(req); 7410 7410 ret = ret ?: ipt.error; 7411 7411 if (ret) 7412 7412 __io_req_complete(req, issue_flags, ret, 0);
+35 -7
include/trace/events/io_uring.h
··· 158 158 __field( unsigned int, flags ) 159 159 __field( struct io_wq_work *, work ) 160 160 __field( int, rw ) 161 + 162 + __string( op_str, io_uring_get_opcode(opcode) ) 161 163 ), 162 164 163 165 TP_fast_assign( ··· 170 168 __entry->opcode = opcode; 171 169 __entry->work = work; 172 170 __entry->rw = rw; 171 + 172 + __assign_str(op_str, io_uring_get_opcode(opcode)); 173 173 ), 174 174 175 175 TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s, flags 0x%x, %s queue, work %p", 176 176 __entry->ctx, __entry->req, __entry->user_data, 177 - io_uring_get_opcode(__entry->opcode), 177 + __get_str(op_str), 178 178 __entry->flags, __entry->rw ? "hashed" : "normal", __entry->work) 179 179 ); 180 180 ··· 202 198 __field( void *, req ) 203 199 __field( unsigned long long, data ) 204 200 __field( u8, opcode ) 201 + 202 + __string( op_str, io_uring_get_opcode(opcode) ) 205 203 ), 206 204 207 205 TP_fast_assign( ··· 211 205 __entry->req = req; 212 206 __entry->data = user_data; 213 207 __entry->opcode = opcode; 208 + 209 + __assign_str(op_str, io_uring_get_opcode(opcode)); 214 210 ), 215 211 216 212 TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s", 217 213 __entry->ctx, __entry->req, __entry->data, 218 - io_uring_get_opcode(__entry->opcode)) 214 + __get_str(op_str)) 219 215 ); 220 216 221 217 /** ··· 306 298 __field( unsigned long long, user_data ) 307 299 __field( u8, opcode ) 308 300 __field( void *, link ) 301 + 302 + __string( op_str, io_uring_get_opcode(opcode) ) 309 303 ), 310 304 311 305 TP_fast_assign( ··· 316 306 __entry->user_data = user_data; 317 307 __entry->opcode = opcode; 318 308 __entry->link = link; 309 + 310 + __assign_str(op_str, io_uring_get_opcode(opcode)); 319 311 ), 320 312 321 313 TP_printk("ring %p, request %p, user_data 0x%llx, opcode %s, link %p", 322 314 __entry->ctx, __entry->req, __entry->user_data, 323 - io_uring_get_opcode(__entry->opcode), __entry->link) 315 + __get_str(op_str), __entry->link) 324 316 ); 325 317 326 318 /** ··· 402 390 __field( u32, flags ) 403 391 __field( bool, force_nonblock ) 404 392 __field( bool, sq_thread ) 393 + 394 + __string( op_str, io_uring_get_opcode(opcode) ) 405 395 ), 406 396 407 397 TP_fast_assign( ··· 414 400 __entry->flags = flags; 415 401 __entry->force_nonblock = force_nonblock; 416 402 __entry->sq_thread = sq_thread; 403 + 404 + __assign_str(op_str, io_uring_get_opcode(opcode)); 417 405 ), 418 406 419 407 TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, flags 0x%x, " 420 408 "non block %d, sq_thread %d", __entry->ctx, __entry->req, 421 - __entry->user_data, io_uring_get_opcode(__entry->opcode), 409 + __entry->user_data, __get_str(op_str), 422 410 __entry->flags, __entry->force_nonblock, __entry->sq_thread) 423 411 ); 424 412 ··· 451 435 __field( u8, opcode ) 452 436 __field( int, mask ) 453 437 __field( int, events ) 438 + 439 + __string( op_str, io_uring_get_opcode(opcode) ) 454 440 ), 455 441 456 442 TP_fast_assign( ··· 462 444 __entry->opcode = opcode; 463 445 __entry->mask = mask; 464 446 __entry->events = events; 447 + 448 + __assign_str(op_str, io_uring_get_opcode(opcode)); 465 449 ), 466 450 467 451 TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, mask 0x%x, events 0x%x", 468 452 __entry->ctx, __entry->req, __entry->user_data, 469 - io_uring_get_opcode(__entry->opcode), 453 + __get_str(op_str), 470 454 __entry->mask, __entry->events) 471 455 ); 472 456 ··· 494 474 __field( unsigned long long, user_data ) 495 475 __field( u8, opcode ) 496 476 __field( int, mask ) 477 + 478 + __string( op_str, io_uring_get_opcode(opcode) ) 497 479 ), 498 480 499 481 TP_fast_assign( ··· 504 482 __entry->user_data = user_data; 505 483 __entry->opcode = opcode; 506 484 __entry->mask = mask; 485 + 486 + __assign_str(op_str, io_uring_get_opcode(opcode)); 507 487 ), 508 488 509 489 TP_printk("ring %p, req %p, user_data 0x%llx, opcode %s, mask %x", 510 490 __entry->ctx, __entry->req, __entry->user_data, 511 - io_uring_get_opcode(__entry->opcode), 491 + __get_str(op_str), 512 492 __entry->mask) 513 493 ); 514 494 ··· 547 523 __field( u64, pad1 ) 548 524 __field( u64, addr3 ) 549 525 __field( int, error ) 526 + 527 + __string( op_str, io_uring_get_opcode(sqe->opcode) ) 550 528 ), 551 529 552 530 TP_fast_assign( ··· 568 542 __entry->pad1 = sqe->__pad2[0]; 569 543 __entry->addr3 = sqe->addr3; 570 544 __entry->error = error; 545 + 546 + __assign_str(op_str, io_uring_get_opcode(sqe->opcode)); 571 547 ), 572 548 573 549 TP_printk("ring %p, req %p, user_data 0x%llx, " ··· 578 550 "personality=%d, file_index=%d, pad=0x%llx, addr3=%llx, " 579 551 "error=%d", 580 552 __entry->ctx, __entry->req, __entry->user_data, 581 - io_uring_get_opcode(__entry->opcode), 553 + __get_str(op_str), 582 554 __entry->flags, __entry->ioprio, 583 555 (unsigned long long)__entry->off, 584 556 (unsigned long long) __entry->addr, __entry->len,