diff options
-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) |