Skip to contentSkip to conversation

block: avoid incorrect bdi_unregiter call in blk_cleanup_queue

PATCH Superseded Masayoshi Mizuma 2 participants 3 messages Dec 1, 2016 – Dec 2, 2016 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: avoid incorrect bdi_unregiter call in blk_cleanup_queue

blk_cleanup_queue() should call bdi_unregister() only if WB_registered is set to bdi->wb.state. Because, blk_cleanup_queue() may be called before bdi_register() is called, for example, error path.

---
 block/blk-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-core.c +2 -1
index 14d7c07..c1ab17e 100644
@@ -595,7 +595,8 @@ void blk_cleanup_queue(struct request_queue *q)
 		q->queue_lock = &q->__queue_lock;
 	spin_unlock_irq(lock);
 
-	bdi_unregister(&q->backing_dev_info);
+	if (test_bit(WB_registered, &q->backing_dev_info.wb.state))
+		bdi_unregister(&q->backing_dev_info);
 
 	/* @q is and will stay empty, shutdown and put */
 	blk_put_queue(q);
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 3 lines · Masayoshi Mizuma

blk_cleanup_queue() should call bdi_unregister() only if WB_registered is set to bdi->wb.state. Because, blk_cleanup_queue() may be called before bdi_register() is called, for example, error path.

Should this logic be in bdi_unregister() instead?

Signature · 1 line
Jens Axboe
#2 lore raw

Hi Jens,

Quoted 6 lines · On Thu, 1 Dec 2016 08:04:33 -0700 Jens Axboe wrote:
Quoted 3 lines · Masayoshi Mizuma

blk_cleanup_queue() should call bdi_unregister() only if WB_registered is set to bdi->wb.state. Because, blk_cleanup_queue() may be called before bdi_register() is called, for example, error path.

Should this logic be in bdi_unregister() instead?

Thank you for pointed it out! I think your suggestion is better. I will rewrite the patch.

- Masayoshi Mizuma

Quoted 1 line