Skip to contentSkip to conversation

dm-writecache: fix uncommitted_blocks underflow

PATCH New Mikulas Patocka 1 participant 1 message Sep 30 Device mapper

lore
Share & tools
lore

Mikulas Patocka

author maintainer
#0 lore raw

PATCH 4/5 dm-writecache: fix uncommitted_blocks underflow

writecache_bio_copy_ssd sets wc->uncommitted_blocks = 0; and then queues the flush work: queue_work(wc->writeback_wq, &wc->flush_work);

It may be possible that discard is dispatched in this window, and the discard would decrement wc->uncommitted_blocks to -1U.

Note that this bug is benign - wc->uncommitted_blocks is only used to trigged autocommit, so decrementing it to -1U will trigger a spurious autocommit, but won't cause any data corruption.

Assisted-by Claude:claude-opus-5
---
 drivers/md/dm-writecache.c |    2 --
 1 file changed, 2 deletions(-)
drivers/md/dm-writecache.c +0 -2
Index: linux-2.6/drivers/md/dm-writecache.c
===================================================================
@@ -899,8 +899,6 @@ static void writecache_discard(struct dm
 				}
 				discarded_something = true;
 			}
-			if (!writecache_entry_is_committed(wc, e))
-				wc->uncommitted_blocks--;
 			writecache_free_entry(wc, e);
 		}