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

Pull block fixes from Jens Axboe:
"A few fixes that should go into this release:

- Small series of patches for ublk (ZiyangZhang)

- Remove dead function (Yu)

- Fix for running a block queue in case of resource starvation
(Yufen)"

* tag 'block-6.0-2022-08-19' of git://git.kernel.dk/linux-block:
blk-mq: run queue no matter whether the request is the last request
blk-mq: remove unused function blk_mq_queue_stopped()
ublk_drv: do not add a re-issued request aborted previously to ioucmd's task_work
ublk_drv: update comment for __ublk_fail_req()
ublk_drv: check ubq_daemon_is_dying() in __ublk_rq_task_work()
ublk_drv: update iod->addr for UBLK_IO_NEED_GET_DATA

+28 -28
+1 -21
block/blk-mq.c
··· 2229 2229 } 2230 2230 EXPORT_SYMBOL(blk_mq_delay_run_hw_queues); 2231 2231 2232 - /** 2233 - * blk_mq_queue_stopped() - check whether one or more hctxs have been stopped 2234 - * @q: request queue. 2235 - * 2236 - * The caller is responsible for serializing this function against 2237 - * blk_mq_{start,stop}_hw_queue(). 2238 - */ 2239 - bool blk_mq_queue_stopped(struct request_queue *q) 2240 - { 2241 - struct blk_mq_hw_ctx *hctx; 2242 - unsigned long i; 2243 - 2244 - queue_for_each_hw_ctx(q, hctx, i) 2245 - if (blk_mq_hctx_stopped(hctx)) 2246 - return true; 2247 - 2248 - return false; 2249 - } 2250 - EXPORT_SYMBOL(blk_mq_queue_stopped); 2251 - 2252 2232 /* 2253 2233 * This function is often used for pausing .queue_rq() by driver when 2254 2234 * there isn't enough resource or some conditions aren't satisfied, and ··· 2550 2570 break; 2551 2571 case BLK_STS_RESOURCE: 2552 2572 case BLK_STS_DEV_RESOURCE: 2553 - blk_mq_request_bypass_insert(rq, false, last); 2573 + blk_mq_request_bypass_insert(rq, false, true); 2554 2574 blk_mq_commit_rqs(hctx, &queued, from_schedule); 2555 2575 return; 2556 2576 default:
+27 -6
drivers/block/ublk_drv.c
··· 555 555 return (struct ublk_uring_cmd_pdu *)&ioucmd->pdu; 556 556 } 557 557 558 - static bool ubq_daemon_is_dying(struct ublk_queue *ubq) 558 + static inline bool ubq_daemon_is_dying(struct ublk_queue *ubq) 559 559 { 560 560 return ubq->ubq_daemon->flags & PF_EXITING; 561 561 } ··· 605 605 } 606 606 607 607 /* 608 - * __ublk_fail_req() may be called from abort context or ->ubq_daemon 609 - * context during exiting, so lock is required. 608 + * Since __ublk_rq_task_work always fails requests immediately during 609 + * exiting, __ublk_fail_req() is only called from abort context during 610 + * exiting. So lock is unnecessary. 610 611 * 611 612 * Also aborting may not be started yet, keep in mind that one failed 612 613 * request may be issued by block layer again. ··· 645 644 struct ublk_device *ub = ubq->dev; 646 645 int tag = req->tag; 647 646 struct ublk_io *io = &ubq->ios[tag]; 648 - bool task_exiting = current != ubq->ubq_daemon || 649 - (current->flags & PF_EXITING); 647 + bool task_exiting = current != ubq->ubq_daemon || ubq_daemon_is_dying(ubq); 650 648 unsigned int mapped_bytes; 651 649 652 650 pr_devel("%s: complete: op %d, qid %d tag %d io_flags %x addr %llx\n", ··· 680 680 * do the copy work. 681 681 */ 682 682 io->flags &= ~UBLK_IO_FLAG_NEED_GET_DATA; 683 + /* update iod->addr because ublksrv may have passed a new io buffer */ 684 + ublk_get_iod(ubq, req->tag)->addr = io->addr; 685 + pr_devel("%s: update iod->addr: op %d, qid %d tag %d io_flags %x addr %llx\n", 686 + __func__, io->cmd->cmd_op, ubq->q_id, req->tag, io->flags, 687 + ublk_get_iod(ubq, req->tag)->addr); 683 688 } 684 689 685 690 mapped_bytes = ublk_map_io(ubq, req, io); ··· 756 751 if (task_work_add(ubq->ubq_daemon, &data->work, notify_mode)) 757 752 goto fail; 758 753 } else { 759 - struct io_uring_cmd *cmd = ubq->ios[rq->tag].cmd; 754 + struct ublk_io *io = &ubq->ios[rq->tag]; 755 + struct io_uring_cmd *cmd = io->cmd; 760 756 struct ublk_uring_cmd_pdu *pdu = ublk_get_uring_cmd_pdu(cmd); 757 + 758 + /* 759 + * If the check pass, we know that this is a re-issued request aborted 760 + * previously in monitor_work because the ubq_daemon(cmd's task) is 761 + * PF_EXITING. We cannot call io_uring_cmd_complete_in_task() anymore 762 + * because this ioucmd's io_uring context may be freed now if no inflight 763 + * ioucmd exists. Otherwise we may cause null-deref in ctx->fallback_work. 764 + * 765 + * Note: monitor_work sets UBLK_IO_FLAG_ABORTED and ends this request(releasing 766 + * the tag). Then the request is re-started(allocating the tag) and we are here. 767 + * Since releasing/allocating a tag implies smp_mb(), finding UBLK_IO_FLAG_ABORTED 768 + * guarantees that here is a re-issued request aborted previously. 769 + */ 770 + if ((io->flags & UBLK_IO_FLAG_ABORTED)) 771 + goto fail; 761 772 762 773 pdu->req = rq; 763 774 io_uring_cmd_complete_in_task(cmd, ublk_rq_task_work_cb);
-1
include/linux/blk-mq.h
··· 857 857 void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs); 858 858 void blk_mq_complete_request(struct request *rq); 859 859 bool blk_mq_complete_request_remote(struct request *rq); 860 - bool blk_mq_queue_stopped(struct request_queue *q); 861 860 void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx); 862 861 void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx); 863 862 void blk_mq_stop_hw_queues(struct request_queue *q);