]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.30/dm-space-map-disk-fix-some-book-keeping-in-the-disk-space-map.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.9.30 / dm-space-map-disk-fix-some-book-keeping-in-the-disk-space-map.patch
CommitLineData
208fc782
GKH
1From 0377a07c7a035e0d033cd8b29f0cb15244c0916a Mon Sep 17 00:00:00 2001
2From: Joe Thornber <ejt@redhat.com>
3Date: Mon, 15 May 2017 09:45:40 -0400
4Subject: dm space map disk: fix some book keeping in the disk space map
5
6From: Joe Thornber <ejt@redhat.com>
7
8commit 0377a07c7a035e0d033cd8b29f0cb15244c0916a upstream.
9
10When decrementing the reference count for a block, the free count wasn't
11being updated if the reference count went to zero.
12
13Signed-off-by: Joe Thornber <ejt@redhat.com>
14Signed-off-by: Mike Snitzer <snitzer@redhat.com>
15Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16
17---
18 drivers/md/persistent-data/dm-space-map-disk.c | 15 ++++++++++++++-
19 1 file changed, 14 insertions(+), 1 deletion(-)
20
21--- a/drivers/md/persistent-data/dm-space-map-disk.c
22+++ b/drivers/md/persistent-data/dm-space-map-disk.c
23@@ -142,10 +142,23 @@ static int sm_disk_inc_block(struct dm_s
24
25 static int sm_disk_dec_block(struct dm_space_map *sm, dm_block_t b)
26 {
27+ int r;
28+ uint32_t old_count;
29 enum allocation_event ev;
30 struct sm_disk *smd = container_of(sm, struct sm_disk, sm);
31
32- return sm_ll_dec(&smd->ll, b, &ev);
33+ r = sm_ll_dec(&smd->ll, b, &ev);
34+ if (!r && (ev == SM_FREE)) {
35+ /*
36+ * It's only free if it's also free in the last
37+ * transaction.
38+ */
39+ r = sm_ll_lookup(&smd->old_ll, b, &old_count);
40+ if (!r && !old_count)
41+ smd->nr_allocated_this_transaction--;
42+ }
43+
44+ return r;
45 }
46
47 static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b)