From 2d393f435b21fc8db3fdbd63e8171b65f162909b Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 31 Mar 2021 16:04:34 -0700 Subject: [PATCH] Warn on leaked block refs on unmount By the time we get to destroying the block cache we should have put all our block references. Warn as we tear down the blocks if we see any blocks that still have references, implying a ref leak. This caught a leak caused by srch compaction forgetting to put allocator list block refs. Signed-off-by: Zach Brown --- kmod/src/block.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kmod/src/block.c b/kmod/src/block.c index e13aa8e0..60a1f030 100644 --- a/kmod/src/block.c +++ b/kmod/src/block.c @@ -396,6 +396,7 @@ static void block_remove_all(struct super_block *sb) if (block_get_if_inserted(bp)) { block_remove(sb, bp); + WARN_ON_ONCE(atomic_read(&bp->refcount) != 1); block_put(sb, bp); } }