[PATCH] blk-mq: ensure polled hctx is valid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Keith Busch <kbusch@xxxxxxxxxx>

Imagine two threads polling the same queue while that queue is trying to
reallocate its hardware contexts. Both threads see their bios' valid
cookie value. The first polling thread completes all outstanding bios,
then the queue rebalances the hctx's. The 2nd polling thread attempts to
poll its now outdated cookie which may not have an hctx, or may not be a
polling type anymore. Check for both.

Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
---
 block/blk-mq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 932d2e95392e6..37d8a2f4d5da8 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4721,6 +4721,9 @@ int blk_mq_poll(struct request_queue *q, blk_qc_t cookie, struct io_comp_batch *
 	long state = get_current_state();
 	int ret;
 
+	if (!hctx || hctx->type != HCTX_TYPE_POLL)
+		return 0;
+
 	do {
 		ret = q->mq_ops->poll(hctx, iob);
 		if (ret > 0) {
-- 
2.34.1





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux