]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dm space map common: fix division bug in sm_ll_find_free_block()
authorJoe Thornber <ejt@redhat.com>
Tue, 13 Apr 2021 08:11:53 +0000 (09:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:38:20 +0000 (10:38 +0200)
commit 5208692e80a1f3c8ce2063a22b675dd5589d1d80 upstream.

This division bug meant the search for free metadata space could skip
the final allocation bitmap's worth of entries. Fix affects DM thinp,
cache and era targets.

Cc: stable@vger.kernel.org
Signed-off-by: Joe Thornber <ejt@redhat.com>
Tested-by: Ming-Hung Tsai <mtsai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/persistent-data/dm-space-map-common.c

index 22729fd92a1b93afece3f7f2a727dec0b03bc739..ca09ad2a639c4e1e9cd68911809459401e5a91e3 100644 (file)
@@ -337,6 +337,8 @@ int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin,
         */
        begin = do_div(index_begin, ll->entries_per_block);
        end = do_div(end, ll->entries_per_block);
+       if (end == 0)
+               end = ll->entries_per_block;
 
        for (i = index_begin; i < index_end; i++, begin = 0) {
                struct dm_block *blk;