[PATCH] dm writecache: correct uncommitted_block when discarding uncommitted entry

From: Huaisheng Ye
Date: Fri Jun 12 2020 - 12:00:54 EST


From: Huaisheng Ye <yehs1@xxxxxxxxxx>

When uncommitted entry has been discarded, correct wc->uncommitted_block
for getting the exact number.

Signed-off-by: Huaisheng Ye <yehs1@xxxxxxxxxx>
---
drivers/md/dm-writecache.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
index 4367cc7..64b4527 100644
--- a/drivers/md/dm-writecache.c
+++ b/drivers/md/dm-writecache.c
@@ -855,6 +855,8 @@ static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_
}
discarded_something = true;
}
+ if (!writecache_entry_is_committed(wc, e))
+ wc->uncommitted_blocks--;
writecache_free_entry(wc, e);
}

--
1.8.3.1