diff options
author | Joe Thornber <ejt@redhat.com> | 2017-05-15 09:45:40 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-05-15 15:09:50 -0400 |
commit | 0377a07c7a035e0d033cd8b29f0cb15244c0916a (patch) | |
tree | d15b805b1765ee133b7def706aa00892f9443018 /drivers/md | |
parent | 91bcdb92d39711d1adb40c26b653b7978d93eb98 (diff) |
dm space map disk: fix some book keeping in the disk space map
When decrementing the reference count for a block, the free count wasn't
being updated if the reference count went to zero.
Cc: stable@vger.kernel.org
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/persistent-data/dm-space-map-disk.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c index ebb280a14325..32adf6b4a9c7 100644 --- a/drivers/md/persistent-data/dm-space-map-disk.c +++ b/drivers/md/persistent-data/dm-space-map-disk.c | |||
@@ -142,10 +142,23 @@ static int sm_disk_inc_block(struct dm_space_map *sm, dm_block_t b) | |||
142 | 142 | ||
143 | static int sm_disk_dec_block(struct dm_space_map *sm, dm_block_t b) | 143 | static int sm_disk_dec_block(struct dm_space_map *sm, dm_block_t b) |
144 | { | 144 | { |
145 | int r; | ||
146 | uint32_t old_count; | ||
145 | enum allocation_event ev; | 147 | enum allocation_event ev; |
146 | struct sm_disk *smd = container_of(sm, struct sm_disk, sm); | 148 | struct sm_disk *smd = container_of(sm, struct sm_disk, sm); |
147 | 149 | ||
148 | return sm_ll_dec(&smd->ll, b, &ev); | 150 | r = sm_ll_dec(&smd->ll, b, &ev); |
151 | if (!r && (ev == SM_FREE)) { | ||
152 | /* | ||
153 | * It's only free if it's also free in the last | ||
154 | * transaction. | ||
155 | */ | ||
156 | r = sm_ll_lookup(&smd->old_ll, b, &old_count); | ||
157 | if (!r && !old_count) | ||
158 | smd->nr_allocated_this_transaction--; | ||
159 | } | ||
160 | |||
161 | return r; | ||
149 | } | 162 | } |
150 | 163 | ||
151 | static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b) | 164 | static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b) |