Commit ee3a7e26 authored by Joe Thornber's avatar Joe Thornber Committed by Greg Kroah-Hartman

[PATCH] dm: Lift dm_div_up()

Pull dm_div_up() out of dm-table.c into dm.h
parent 1d914277
...@@ -55,14 +55,6 @@ struct dm_table { ...@@ -55,14 +55,6 @@ struct dm_table {
wait_queue_head_t eventq; wait_queue_head_t eventq;
}; };
/*
* Ceiling(n / size)
*/
static inline unsigned long div_up(unsigned long n, unsigned long size)
{
return dm_round_up(n, size) / size;
}
/* /*
* Similar to ceiling(log_size(n)) * Similar to ceiling(log_size(n))
*/ */
...@@ -71,7 +63,7 @@ static unsigned int int_log(unsigned long n, unsigned long base) ...@@ -71,7 +63,7 @@ static unsigned int int_log(unsigned long n, unsigned long base)
int result = 0; int result = 0;
while (n > 1) { while (n > 1) {
n = div_up(n, base); n = dm_div_up(n, base);
result++; result++;
} }
...@@ -664,7 +656,7 @@ static int setup_indexes(struct dm_table *t) ...@@ -664,7 +656,7 @@ static int setup_indexes(struct dm_table *t)
/* allocate the space for *all* the indexes */ /* allocate the space for *all* the indexes */
for (i = t->depth - 2; i >= 0; i--) { for (i = t->depth - 2; i >= 0; i--) {
t->counts[i] = div_up(t->counts[i + 1], CHILDREN_PER_NODE); t->counts[i] = dm_div_up(t->counts[i + 1], CHILDREN_PER_NODE);
total += t->counts[i]; total += t->counts[i];
} }
...@@ -691,7 +683,7 @@ int dm_table_complete(struct dm_table *t) ...@@ -691,7 +683,7 @@ int dm_table_complete(struct dm_table *t)
unsigned int leaf_nodes; unsigned int leaf_nodes;
/* how many indexes will the btree have ? */ /* how many indexes will the btree have ? */
leaf_nodes = div_up(t->num_targets, KEYS_PER_NODE); leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE);
t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE); t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
/* leaf layer has already been set up */ /* leaf layer has already been set up */
......
...@@ -134,6 +134,14 @@ static inline unsigned long dm_round_up(unsigned long n, unsigned long size) ...@@ -134,6 +134,14 @@ static inline unsigned long dm_round_up(unsigned long n, unsigned long size)
return n + (r ? (size - r) : 0); return n + (r ? (size - r) : 0);
} }
/*
* Ceiling(n / size)
*/
static inline unsigned long dm_div_up(unsigned long n, unsigned long size)
{
return dm_round_up(n, size) / size;
}
/* /*
* The device-mapper can be driven through one of two interfaces; * The device-mapper can be driven through one of two interfaces;
* ioctl or filesystem, depending which patch you have applied. * ioctl or filesystem, depending which patch you have applied.
......
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