Skip to contentSkip to conversation

blk-wbt: fix IO hang in wbt_wait()

PATCH In review Ming Lei 2 participants 2 messages Aug 14, 2018 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 blk-wbt: fix IO hang in wbt_wait()

On wbt invariant is that if one IO is tracked via WBT_TRACKED, rqw->inflight should be updated for tracking this IO.

But commit c1c80384c8f ("block: remove external dependency on wbt_flags") forgets to remove the early handling of !rwb_enabled(rwb) inside wbt_wait(), then the inflight counter may not be increased in wbt_wait(), but decreased in wbt_done() for this kind of IO, so this counter may become negative, then wbt_wait() may wait forever.

This patch fixes the report in the following link:

	https://marc.info/?l=linux-block&m=153221542021033&w=2
Fixes c1c80384c8f ("block: remove external dependency on wbt_flags")
Cc Josef Bacik <[email protected]>
---
 block/blk-wbt.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
block/blk-wbt.c +1 -5
index 1d94a20374fc..bb93c7c2b182 100644
@@ -576,12 +576,8 @@ static void wbt_wait(struct rq_qos *rqos, struct bio *bio, spinlock_t *lock)
 	struct rq_wb *rwb = RQWB(rqos);
 	enum wbt_flags flags;
 
-	if (!rwb_enabled(rwb))
-		return;
-
 	flags = bio_to_wbt_flags(rwb, bio);
-
-	if (!wbt_should_throttle(rwb, bio)) {
+	if (!(flags & WBT_TRACKED)) {
 		if (flags & WBT_READ)
 			wb_timestamp(rwb, &rwb->last_issue);
 		return;
Signature · 1 line
2.9.5
maintainer
#1 lore raw
Quoted 9 lines · Ming Lei

On wbt invariant is that if one IO is tracked via WBT_TRACKED, rqw->inflight should be updated for tracking this IO.

But commit c1c80384c8f ("block: remove external dependency on wbt_flags") forgets to remove the early handling of !rwb_enabled(rwb) inside wbt_wait(), then the inflight counter may not be increased in wbt_wait(), but decreased in wbt_done() for this kind of IO, so this counter may become negative, then wbt_wait() may wait forever.

Quoted 3 lines

This patch fixes the report in the following link:

	https://marc.info/?l=linux-block&m=153221542021033&w=2

Looks good to me, thanks for fixing this. Applied.

Signature · 1 line
Jens Axboe