Commit 938e284b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] dm: remove dynamic table resizing

From: Joe Thornber <thornber@sistina.com>

The dm table size is always known in advance, so we can specify it in
dm_table_create(), rather than relying on dynamic resizing.
parent ecb24581
...@@ -566,7 +566,7 @@ static int create(struct dm_ioctl *param, struct dm_ioctl *user) ...@@ -566,7 +566,7 @@ static int create(struct dm_ioctl *param, struct dm_ioctl *user)
if (r) if (r)
return r; return r;
r = dm_table_create(&t, get_mode(param)); r = dm_table_create(&t, get_mode(param), param->target_count);
if (r) if (r)
return r; return r;
...@@ -894,7 +894,7 @@ static int reload(struct dm_ioctl *param, struct dm_ioctl *user) ...@@ -894,7 +894,7 @@ static int reload(struct dm_ioctl *param, struct dm_ioctl *user)
struct mapped_device *md; struct mapped_device *md;
struct dm_table *t; struct dm_table *t;
r = dm_table_create(&t, get_mode(param)); r = dm_table_create(&t, get_mode(param), param->target_count);
if (r) if (r)
return r; return r;
......
...@@ -872,7 +872,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size) ...@@ -872,7 +872,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
struct hash_cell *hc; struct hash_cell *hc;
struct dm_table *t; struct dm_table *t;
r = dm_table_create(&t, get_mode(param)); r = dm_table_create(&t, get_mode(param), param->target_count);
if (r) if (r)
return r; return r;
......
...@@ -202,7 +202,7 @@ static int alloc_targets(struct dm_table *t, unsigned int num) ...@@ -202,7 +202,7 @@ static int alloc_targets(struct dm_table *t, unsigned int num)
return 0; return 0;
} }
int dm_table_create(struct dm_table **result, int mode) int dm_table_create(struct dm_table **result, int mode, unsigned num_targets)
{ {
struct dm_table *t = kmalloc(sizeof(*t), GFP_NOIO); struct dm_table *t = kmalloc(sizeof(*t), GFP_NOIO);
...@@ -213,8 +213,12 @@ int dm_table_create(struct dm_table **result, int mode) ...@@ -213,8 +213,12 @@ int dm_table_create(struct dm_table **result, int mode)
INIT_LIST_HEAD(&t->devices); INIT_LIST_HEAD(&t->devices);
atomic_set(&t->holders, 1); atomic_set(&t->holders, 1);
/* allocate a single nodes worth of targets to begin with */ if (!num_targets)
if (alloc_targets(t, KEYS_PER_NODE)) { num_targets = KEYS_PER_NODE;
num_targets = dm_round_up(num_targets, KEYS_PER_NODE);
if (alloc_targets(t, num_targets)) {
kfree(t); kfree(t);
t = NULL; t = NULL;
return -ENOMEM; return -ENOMEM;
......
...@@ -95,7 +95,7 @@ int dm_suspended(struct mapped_device *md); ...@@ -95,7 +95,7 @@ int dm_suspended(struct mapped_device *md);
* Functions for manipulating a table. Tables are also reference * Functions for manipulating a table. Tables are also reference
* counted. * counted.
*---------------------------------------------------------------*/ *---------------------------------------------------------------*/
int dm_table_create(struct dm_table **result, int mode); int dm_table_create(struct dm_table **result, int mode, unsigned num_targets);
void dm_table_get(struct dm_table *t); void dm_table_get(struct dm_table *t);
void dm_table_put(struct dm_table *t); void dm_table_put(struct dm_table *t);
......
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