Commit f36afb39 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Mike Snitzer

dm: allocate buffer for messages with small number of arguments using GFP_NOIO

dm-mpath and dm-thin must process messages even if some device is
suspended, so we allocate argv buffer with GFP_NOIO. These messages have
a small fixed number of arguments.

On the other hand, dm-switch needs to process bulk data using messages
so excessive use of GFP_NOIO could cause trouble.

The patch also lowers the default number of arguments from 64 to 8, so
that there is smaller load on GFP_NOIO allocations.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Acked-by: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 61e6cfa8
...@@ -545,14 +545,28 @@ static int adjoin(struct dm_table *table, struct dm_target *ti) ...@@ -545,14 +545,28 @@ static int adjoin(struct dm_table *table, struct dm_target *ti)
/* /*
* Used to dynamically allocate the arg array. * Used to dynamically allocate the arg array.
*
* We do first allocation with GFP_NOIO because dm-mpath and dm-thin must
* process messages even if some device is suspended. These messages have a
* small fixed number of arguments.
*
* On the other hand, dm-switch needs to process bulk data using messages and
* excessive use of GFP_NOIO could cause trouble.
*/ */
static char **realloc_argv(unsigned *array_size, char **old_argv) static char **realloc_argv(unsigned *array_size, char **old_argv)
{ {
char **argv; char **argv;
unsigned new_size; unsigned new_size;
gfp_t gfp;
new_size = *array_size ? *array_size * 2 : 64; if (*array_size) {
argv = kmalloc(new_size * sizeof(*argv), GFP_KERNEL); new_size = *array_size * 2;
gfp = GFP_KERNEL;
} else {
new_size = 8;
gfp = GFP_NOIO;
}
argv = kmalloc(new_size * sizeof(*argv), gfp);
if (argv) { if (argv) {
memcpy(argv, old_argv, *array_size * sizeof(*argv)); memcpy(argv, old_argv, *array_size * sizeof(*argv));
*array_size = new_size; *array_size = new_size;
......
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