Skip to content

Commit

Permalink
dm space map disk: fix some book keeping in the disk space map
Browse files Browse the repository at this point in the history
BugLink: http://bugs.launchpad.net/bugs/1694621

commit 0377a07 upstream.

When decrementing the reference count for a block, the free count wasn't
being updated if the reference count went to zero.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
  • Loading branch information
jthornber authored and ksacilotto committed Jun 20, 2017
1 parent 3b4c0f3 commit 289f5a6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion drivers/md/persistent-data/dm-space-map-disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,23 @@ static int sm_disk_inc_block(struct dm_space_map *sm, dm_block_t b)

static int sm_disk_dec_block(struct dm_space_map *sm, dm_block_t b)
{
int r;
uint32_t old_count;
enum allocation_event ev;
struct sm_disk *smd = container_of(sm, struct sm_disk, sm);

return sm_ll_dec(&smd->ll, b, &ev);
r = sm_ll_dec(&smd->ll, b, &ev);
if (!r && (ev == SM_FREE)) {
/*
* It's only free if it's also free in the last
* transaction.
*/
r = sm_ll_lookup(&smd->old_ll, b, &old_count);
if (!r && !old_count)
smd->nr_allocated_this_transaction--;
}

return r;
}

static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b)
Expand Down

0 comments on commit 289f5a6

Please sign in to comment.