]>
Commit | Line | Data |
---|---|---|
208fc782 GKH |
1 | From 0377a07c7a035e0d033cd8b29f0cb15244c0916a Mon Sep 17 00:00:00 2001 |
2 | From: Joe Thornber <ejt@redhat.com> | |
3 | Date: Mon, 15 May 2017 09:45:40 -0400 | |
4 | Subject: dm space map disk: fix some book keeping in the disk space map | |
5 | ||
6 | From: Joe Thornber <ejt@redhat.com> | |
7 | ||
8 | commit 0377a07c7a035e0d033cd8b29f0cb15244c0916a upstream. | |
9 | ||
10 | When decrementing the reference count for a block, the free count wasn't | |
11 | being updated if the reference count went to zero. | |
12 | ||
13 | Signed-off-by: Joe Thornber <ejt@redhat.com> | |
14 | Signed-off-by: Mike Snitzer <snitzer@redhat.com> | |
15 | Signed-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) |