Skip to content

Commit 40ef875

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
dm writecache: allow allocations larger than 2GiB
The function kvmalloc_node limits the allocation size to INT_MAX. This limit will be overflowed if dm-writecache attempts to map a device with 1TiB or larger length. This commit changes kvmalloc_array to vmalloc_array to avoid the limit. The commit also changes vmalloc(array_size()) to vmalloc_array(). Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent 9cf11ce commit 40ef875

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/md/dm-writecache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static int persistent_memory_claim(struct dm_writecache *wc)
299299
long i;
300300

301301
wc->memory_map = NULL;
302-
pages = kvmalloc_array(p, sizeof(struct page *), GFP_KERNEL);
302+
pages = vmalloc_array(p, sizeof(struct page *));
303303
if (!pages) {
304304
r = -ENOMEM;
305305
goto err2;
@@ -330,7 +330,7 @@ static int persistent_memory_claim(struct dm_writecache *wc)
330330
r = -ENOMEM;
331331
goto err3;
332332
}
333-
kvfree(pages);
333+
vfree(pages);
334334
wc->memory_vmapped = true;
335335
}
336336

@@ -341,7 +341,7 @@ static int persistent_memory_claim(struct dm_writecache *wc)
341341

342342
return 0;
343343
err3:
344-
kvfree(pages);
344+
vfree(pages);
345345
err2:
346346
dax_read_unlock(id);
347347
err1:
@@ -962,7 +962,7 @@ static int writecache_alloc_entries(struct dm_writecache *wc)
962962

963963
if (wc->entries)
964964
return 0;
965-
wc->entries = vmalloc(array_size(sizeof(struct wc_entry), wc->n_blocks));
965+
wc->entries = vmalloc_array(wc->n_blocks, sizeof(struct wc_entry));
966966
if (!wc->entries)
967967
return -ENOMEM;
968968
for (b = 0; b < wc->n_blocks; b++) {

0 commit comments

Comments
 (0)