Commit 702a6204 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Mike Snitzer

dm integrity: use kvmalloc() instead of dm_integrity_kvmalloc()

Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent f52236e0
...@@ -2374,21 +2374,6 @@ static void dm_integrity_set(struct dm_target *ti, struct dm_integrity_c *ic) ...@@ -2374,21 +2374,6 @@ static void dm_integrity_set(struct dm_target *ti, struct dm_integrity_c *ic)
blk_queue_max_integrity_segments(disk->queue, UINT_MAX); blk_queue_max_integrity_segments(disk->queue, UINT_MAX);
} }
/* FIXME: use new kvmalloc */
static void *dm_integrity_kvmalloc(size_t size, gfp_t gfp)
{
void *ptr = NULL;
if (size <= PAGE_SIZE)
ptr = kmalloc(size, GFP_KERNEL | gfp);
if (!ptr && size <= KMALLOC_MAX_SIZE)
ptr = kmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY | gfp);
if (!ptr)
ptr = __vmalloc(size, GFP_KERNEL | gfp, PAGE_KERNEL);
return ptr;
}
static void dm_integrity_free_page_list(struct dm_integrity_c *ic, struct page_list *pl) static void dm_integrity_free_page_list(struct dm_integrity_c *ic, struct page_list *pl)
{ {
unsigned i; unsigned i;
...@@ -2407,7 +2392,7 @@ static struct page_list *dm_integrity_alloc_page_list(struct dm_integrity_c *ic) ...@@ -2407,7 +2392,7 @@ static struct page_list *dm_integrity_alloc_page_list(struct dm_integrity_c *ic)
struct page_list *pl; struct page_list *pl;
unsigned i; unsigned i;
pl = dm_integrity_kvmalloc(page_list_desc_size, __GFP_ZERO); pl = kvmalloc(page_list_desc_size, GFP_KERNEL | __GFP_ZERO);
if (!pl) if (!pl)
return NULL; return NULL;
...@@ -2437,7 +2422,7 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int ...@@ -2437,7 +2422,7 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int
struct scatterlist **sl; struct scatterlist **sl;
unsigned i; unsigned i;
sl = dm_integrity_kvmalloc(ic->journal_sections * sizeof(struct scatterlist *), __GFP_ZERO); sl = kvmalloc(ic->journal_sections * sizeof(struct scatterlist *), GFP_KERNEL | __GFP_ZERO);
if (!sl) if (!sl)
return NULL; return NULL;
...@@ -2453,7 +2438,7 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int ...@@ -2453,7 +2438,7 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int
n_pages = (end_index - start_index + 1); n_pages = (end_index - start_index + 1);
s = dm_integrity_kvmalloc(n_pages * sizeof(struct scatterlist), 0); s = kvmalloc(n_pages * sizeof(struct scatterlist), GFP_KERNEL);
if (!s) { if (!s) {
dm_integrity_free_journal_scatterlist(ic, sl); dm_integrity_free_journal_scatterlist(ic, sl);
return NULL; return NULL;
...@@ -2617,7 +2602,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error) ...@@ -2617,7 +2602,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
goto bad; goto bad;
} }
sg = dm_integrity_kvmalloc((ic->journal_pages + 1) * sizeof(struct scatterlist), 0); sg = kvmalloc((ic->journal_pages + 1) * sizeof(struct scatterlist), GFP_KERNEL);
if (!sg) { if (!sg) {
*error = "Unable to allocate sg list"; *error = "Unable to allocate sg list";
r = -ENOMEM; r = -ENOMEM;
...@@ -2673,7 +2658,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error) ...@@ -2673,7 +2658,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
r = -ENOMEM; r = -ENOMEM;
goto bad; goto bad;
} }
ic->sk_requests = dm_integrity_kvmalloc(ic->journal_sections * sizeof(struct skcipher_request *), __GFP_ZERO); ic->sk_requests = kvmalloc(ic->journal_sections * sizeof(struct skcipher_request *), GFP_KERNEL | __GFP_ZERO);
if (!ic->sk_requests) { if (!ic->sk_requests) {
*error = "Unable to allocate sk requests"; *error = "Unable to allocate sk requests";
r = -ENOMEM; r = -ENOMEM;
...@@ -2740,7 +2725,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error) ...@@ -2740,7 +2725,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
r = -ENOMEM; r = -ENOMEM;
goto bad; goto bad;
} }
ic->journal_tree = dm_integrity_kvmalloc(journal_tree_size, 0); ic->journal_tree = kvmalloc(journal_tree_size, GFP_KERNEL);
if (!ic->journal_tree) { if (!ic->journal_tree) {
*error = "Could not allocate memory for journal tree"; *error = "Could not allocate memory for journal tree";
r = -ENOMEM; r = -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment