Skip to content

Commit faada21

Browse files
author
Mikulas Patocka
committed
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 <[email protected]> Reported-by: Zdenek Kabelac <[email protected]> Reviewed-by: Mike Snitzer <[email protected]> Cc: [email protected]
1 parent 86cfa9a commit faada21

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/md/persistent-data/dm-space-map-metadata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static void sm_metadata_destroy(struct dm_space_map *sm)
277277
{
278278
struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
279279

280-
kfree(smm);
280+
kvfree(smm);
281281
}
282282

283283
static int sm_metadata_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count)
@@ -772,7 +772,7 @@ struct dm_space_map *dm_sm_metadata_init(void)
772772
{
773773
struct sm_metadata *smm;
774774

775-
smm = kmalloc(sizeof(*smm), GFP_KERNEL);
775+
smm = kvmalloc(sizeof(*smm), GFP_KERNEL);
776776
if (!smm)
777777
return ERR_PTR(-ENOMEM);
778778

0 commit comments

Comments
 (0)