Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm persistent data: fix memory allocation failure

kmalloc is unreliable when allocating more than 8 pages of memory. It may
fail when there is plenty of free memory but the memory is fragmented.
Zdenek Kabelac observed such failure in his tests.

This commit changes kmalloc to kvmalloc - kvmalloc will fall back to
vmalloc if the large allocation fails.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Cc: stable@vger.kernel.org

+2 -2
+2 -2
drivers/md/persistent-data/dm-space-map-metadata.c
··· 277 277 { 278 278 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); 279 279 280 - kfree(smm); 280 + kvfree(smm); 281 281 } 282 282 283 283 static int sm_metadata_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count) ··· 772 772 { 773 773 struct sm_metadata *smm; 774 774 775 - smm = kmalloc(sizeof(*smm), GFP_KERNEL); 775 + smm = kvmalloc(sizeof(*smm), GFP_KERNEL); 776 776 if (!smm) 777 777 return ERR_PTR(-ENOMEM); 778 778