1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-28 05:57:49 +03:00

o table creation works again.

This commit is contained in:
Joe Thornber 2001-09-26 19:48:20 +00:00
parent 4939053121
commit 47a8d7475f
7 changed files with 53 additions and 36 deletions

View File

@ -44,7 +44,8 @@ typedef int (*dm_err_fn)(struct buffer_head *bh, int rw, void *context);
* destination devices are handled correctly
* (ie. opened/closed).
*/
struct dm_dev *dm_table_get_device(struct dm_table *table, const char *path);
int dm_table_get_device(struct dm_table *t, const char *path,
struct dm_dev **result);
void dm_table_put_device(struct dm_table *table, struct dm_dev *d);
/*

View File

@ -506,7 +506,7 @@ static struct super_operations dm_ops = {
};
static struct super_block *_read_super(struct super_block *sb, void *data,
int silent)
int silent)
{
struct inode *inode;
struct dentry *root;

View File

@ -35,6 +35,7 @@ static int linear_ctr(struct dm_table *t, offset_t b, offset_t l,
struct linear_c *lc;
unsigned int start;
struct text_region word;
char path[256]; /* FIXME: magic */
int r = -EINVAL;
if (!(lc = kmalloc(sizeof(lc), GFP_KERNEL))) {
@ -47,14 +48,14 @@ static int linear_ctr(struct dm_table *t, offset_t b, offset_t l,
goto bad;
}
dm_txt_copy(lc->path, sizeof(lc->path) - 1, &word);
dm_txt_copy(path, sizeof(path) - 1, &word);
if (!dm_get_number(args, &start)) {
err("destination start not given", e_private);
goto bad;
}
if ((r = dm_table_add_device(t, lc->path, &lc->dev))) {
if ((r = dm_table_get_device(t, path, &lc->dev))) {
err("couldn't lookup device", e_private);
r = -ENXIO;
goto bad;
@ -72,7 +73,7 @@ static int linear_ctr(struct dm_table *t, offset_t b, offset_t l,
static void linear_dtr(struct dm_table *t, void *c)
{
struct linear_c *lc = (struct linear_c *) c;
dm_table_remove_device(t, lc->dev);
dm_table_put_device(t, lc->dev);
kfree(c);
}
@ -80,7 +81,7 @@ static int linear_map(struct buffer_head *bh, int rw, void *context)
{
struct linear_c *lc = (struct linear_c *) context;
bh->b_rdev = lc->rdev;
bh->b_rdev = lc->dev->dev;
bh->b_rsector = bh->b_rsector + lc->delta;
return 1;
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the GPL.
*/
/*
@ -113,6 +113,7 @@ struct dm_table *dm_table_create(void)
return 0;
memset(t, 0, sizeof(*t));
INIT_LIST_HEAD(&t->devices);
/* allocate a single nodes worth of targets to
begin with */
@ -152,11 +153,11 @@ void dm_table_destroy(struct dm_table *t)
}
/* free the device list */
if (t->devices) {
if (t->devices.next != &t->devices) {
WARN("there are still devices present, someone isn't "
"calling dm_table_remove_device");
free_devices(t->devices);
free_devices(&t->devices);
}
kfree(t);
@ -215,7 +216,7 @@ static struct dm_dev *find_device(struct list_head *l, kdev_t dev)
{
struct list_head *tmp;
for (tmp = l->next; tmp != l; l = l->next) {
for (tmp = l->next; tmp != l; tmp = tmp->next) {
struct dm_dev *dd = list_entry(tmp, struct dm_dev, list);
if (dd->dev == dev)
@ -229,7 +230,7 @@ static struct dm_dev *find_device(struct list_head *l, kdev_t dev)
* add a device to the list, or just increment the
* usage count if it's already present.
*/
int dm_table_add_device(struct dm_table *t, const char *path,
int dm_table_get_device(struct dm_table *t, const char *path,
struct dm_dev **result)
{
int r;
@ -240,7 +241,7 @@ int dm_table_add_device(struct dm_table *t, const char *path,
if ((r = lookup_device(path, &dev)))
return r;
dd = find_device(t->devices, dev);
dd = find_device(&t->devices, dev);
if (!dd) {
dd = kmalloc(sizeof(*dd), GFP_KERNEL);
if (!dd)
@ -249,7 +250,7 @@ int dm_table_add_device(struct dm_table *t, const char *path,
dd->dev = dev;
dd->bd = 0;
atomic_set(&dd->count, 0);
list_add(&dd->list, t->devices);
list_add(&dd->list, &t->devices);
}
atomic_inc(&dd->count);
*result = dd;
@ -260,7 +261,7 @@ int dm_table_add_device(struct dm_table *t, const char *path,
* decrement a devices use count and remove it if
* neccessary.
*/
void dm_table_remove_device(struct dm_table *t, struct dm_dev *dd)
void dm_table_put_device(struct dm_table *t, struct dm_dev *dd)
{
if (atomic_dec_and_test(&dd->count)) {
list_del(&dd->list);
@ -287,22 +288,12 @@ int dm_table_add_target(struct dm_table *t, offset_t high,
return 0;
}
/*
* builds the btree to index the map
*/
int dm_table_complete(struct dm_table *t)
static int setup_indexes(struct dm_table *t)
{
int i, leaf_nodes, total = 0;
int i, total = 0;
offset_t *indexes;
/* how many indexes will the btree have ? */
leaf_nodes = div_up(t->num_targets, KEYS_PER_NODE);
t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
/* leaf layer has already been set up */
t->counts[t->depth - 1] = leaf_nodes;
t->index[t->depth - 1] = t->highs;
/* allocate the space for *all* the indexes */
for (i = t->depth - 2; i >= 0; i--) {
t->counts[i] = div_up(t->counts[i + 1], CHILDREN_PER_NODE);
@ -321,6 +312,27 @@ int dm_table_complete(struct dm_table *t)
return 0;
}
EXPORT_SYMBOL(dm_table_add_device);
/*
* builds the btree to index the map
*/
int dm_table_complete(struct dm_table *t)
{
int leaf_nodes, r = 0;
/* how many indexes will the btree have ? */
leaf_nodes = div_up(t->num_targets, KEYS_PER_NODE);
t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
/* leaf layer has already been set up */
t->counts[t->depth - 1] = leaf_nodes;
t->index[t->depth - 1] = t->highs;
if (t->depth >= 2)
r = setup_indexes(t);
return r;
}
EXPORT_SYMBOL(dm_table_get_device);
EXPORT_SYMBOL(dm_table_put_device);

View File

@ -46,9 +46,12 @@ static struct tt_internal *get_target_type(const char *name)
read_lock(&_lock);
ti = __find_target_type(name);
if (ti->use == 0 && ti->tt.module)
__MOD_INC_USE_COUNT(ti->tt.module);
ti->use++;
if (ti) {
if (ti->use == 0 && ti->tt.module)
__MOD_INC_USE_COUNT(ti->tt.module);
ti->use++;
}
read_unlock(&_lock);
return ti;

View File

@ -746,7 +746,7 @@ void __bind(struct mapped_device *md, struct dm_table *t)
_block_size[minor] = (t->highs[t->num_targets - 1] + 1) >> 1;
_blksize_size[minor] = BLOCK_SIZE;
_hardsect_size[minor] = __find_hardsect_size(t->devices);
_hardsect_size[minor] = __find_hardsect_size(&t->devices);
register_disk(NULL, md->dev, 1, &dm_blk_dops, _block_size[minor]);
}
@ -788,7 +788,7 @@ int dm_activate(struct mapped_device *md, struct dm_table *table)
__bind(md, table);
if ((r = open_devices(md->map->devices))) {
if ((r = open_devices(&md->map->devices))) {
wu;
return r;
}
@ -823,7 +823,7 @@ int dm_deactivate(struct mapped_device *md)
return -EPERM;
}
close_devices(md->map->devices);
close_devices(&md->map->devices);
md->map = 0;
clear_bit(DM_ACTIVE, &md->state);
wu;
@ -868,7 +868,7 @@ void dm_suspend(struct mapped_device *md)
current->state = TASK_RUNNING;
remove_wait_queue(&md->wait, &wait);
close_devices(md->map->devices);
close_devices(&md->map->devices);
md->map = 0;
wu;

View File

@ -177,7 +177,7 @@ struct dm_table {
struct target *targets;
/* a list of devices used by this table */
struct list_head *devices;
struct list_head devices;
};
/*