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)
if (r)
return r;
r = dm_table_create(&t, get_mode(param));
r = dm_table_create(&t, get_mode(param), param->target_count);
if (r)
return r;
......@@ -894,7 +894,7 @@ static int reload(struct dm_ioctl *param, struct dm_ioctl *user)
struct mapped_device *md;
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)
return r;
......
......@@ -872,7 +872,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
struct hash_cell *hc;
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)
return r;
......
......@@ -202,7 +202,7 @@ static int alloc_targets(struct dm_table *t, unsigned int num)
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);
......@@ -213,8 +213,12 @@ int dm_table_create(struct dm_table **result, int mode)
INIT_LIST_HEAD(&t->devices);
atomic_set(&t->holders, 1);
/* allocate a single nodes worth of targets to begin with */
if (alloc_targets(t, KEYS_PER_NODE)) {
if (!num_targets)
num_targets = KEYS_PER_NODE;
num_targets = dm_round_up(num_targets, KEYS_PER_NODE);
if (alloc_targets(t, num_targets)) {
kfree(t);
t = NULL;
return -ENOMEM;
......
......@@ -95,7 +95,7 @@ int dm_suspended(struct mapped_device *md);
* Functions for manipulating a table. Tables are also reference
* 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_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