mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
o wu macro was doing a read unlock
o added dm_fs_add/remveove
This commit is contained in:
parent
75d6c8c9f6
commit
71d325549f
@ -111,13 +111,41 @@ void dm_fin_fs(void)
|
||||
devfs_unregister(_dev_dir);
|
||||
}
|
||||
|
||||
int dm_fs_add(struct mapped_device *md)
|
||||
{
|
||||
struct pf_data *pfd = kmalloc(sizeof(*pfd), GFP_KERNEL);
|
||||
|
||||
if (!pfd)
|
||||
return -ENOMEM;
|
||||
|
||||
pfd->fn = _process_table;
|
||||
pfd->minor = MINOR(md->dev);
|
||||
|
||||
if (!(md->pde = create_proc_entry(md->name, 0, _proc_dir))) {
|
||||
kfree(pfd);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
md->pde->write_proc = _line_splitter;
|
||||
md->pde->data = pfd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_fs_remove(struct mapped_device *md)
|
||||
{
|
||||
if (md->pde) {
|
||||
kfree(md->pde->data);
|
||||
remove_proc_entry(md->name, _proc_dir);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _process_control(const char *b, const char *e, int minor)
|
||||
{
|
||||
const char *wb, *we;
|
||||
char name[64];
|
||||
int create = 0;
|
||||
struct pf_data *pfd;
|
||||
struct proc_dir_entry *pde;
|
||||
|
||||
/*
|
||||
* create <name> [minor]
|
||||
@ -139,7 +167,10 @@ int _process_control(const char *b, const char *e, int minor)
|
||||
|
||||
_tok_cpy(name, sizeof(name), wb, we);
|
||||
|
||||
if (create) {
|
||||
if (!create)
|
||||
return dm_remove(name);
|
||||
|
||||
else {
|
||||
if (_get_word(b, e, &wb, &we)) {
|
||||
minor = simple_strtol(wb, (char **) &we, 10);
|
||||
|
||||
@ -147,28 +178,7 @@ int _process_control(const char *b, const char *e, int minor)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* FIXME: quick hack */
|
||||
pfd = kmalloc(sizeof(*pfd), GFP_KERNEL);
|
||||
|
||||
if (!pfd)
|
||||
return -ENOMEM;
|
||||
pfd->fn = _process_table;
|
||||
pfd->minor = minor;
|
||||
|
||||
if (!(pde = create_proc_entry(name, 0, _proc_dir)))
|
||||
return -ENOMEM;
|
||||
|
||||
pde->write_proc = _line_splitter;
|
||||
pde->data = pfd;
|
||||
|
||||
return dm_create(name, minor);
|
||||
|
||||
} else {
|
||||
if (!_get_word(b, e, &wb, &we))
|
||||
return -EINVAL;
|
||||
|
||||
_tok_cpy(name, sizeof(name), wb, we);
|
||||
return dm_remove(name);
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
|
@ -122,7 +122,7 @@ int _version[3] = {1, 0, 0};
|
||||
#define rl down_read(&_dev_lock)
|
||||
#define ru up_read(&_dev_lock)
|
||||
#define wl down_write(&_dev_lock)
|
||||
#define wu up_read(&_dev_lock)
|
||||
#define wu up_write(&_dev_lock)
|
||||
|
||||
struct rw_semaphore _dev_lock;
|
||||
static struct mapped_device *_devs[MAX_DEVICES];
|
||||
@ -361,6 +361,7 @@ static inline int __any_old_dev(void)
|
||||
static struct mapped_device *_alloc_dev(int minor)
|
||||
{
|
||||
struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL);
|
||||
memset(md, 0, sizeof(*md));
|
||||
|
||||
wl;
|
||||
minor = (minor < 0) ? __any_old_dev() : __specific_dev(minor);
|
||||
@ -449,6 +450,7 @@ struct mapped_device *dm_find_minor(int minor)
|
||||
|
||||
int dm_create(const char *name, int minor)
|
||||
{
|
||||
int r;
|
||||
struct mapped_device *md;
|
||||
|
||||
if (minor >= MAX_DEVICES)
|
||||
@ -467,6 +469,11 @@ int dm_create(const char *name, int minor)
|
||||
|
||||
strcpy(md->name, name);
|
||||
_devs[minor] = md;
|
||||
|
||||
if ((r = dm_fs_add(md))) {
|
||||
wu;
|
||||
return r;
|
||||
}
|
||||
wu;
|
||||
|
||||
return 0;
|
||||
@ -476,7 +483,7 @@ int dm_remove(const char *name)
|
||||
{
|
||||
struct mapped_device *md;
|
||||
struct dev_list *d, *n;
|
||||
int minor;
|
||||
int minor, r;
|
||||
|
||||
wl;
|
||||
if (!(md = __find_name(name))) {
|
||||
@ -484,7 +491,12 @@ int dm_remove(const char *name)
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dm_free_table(md);
|
||||
if ((r = dm_fs_remove(md))) {
|
||||
wu;
|
||||
return r;
|
||||
}
|
||||
|
||||
//dm_free_table(md);
|
||||
for (d = md->devices; d; d = n) {
|
||||
n = d->next;
|
||||
kfree(d);
|
||||
|
@ -80,6 +80,7 @@ struct mapped_device {
|
||||
|
||||
/* used by dm-fs.c */
|
||||
devfs_handle_t devfs_entry;
|
||||
struct proc_dir_entry *pde;
|
||||
|
||||
/* a list of devices used by this md */
|
||||
struct dev_list *devices;
|
||||
@ -121,6 +122,9 @@ void dm_free_table(struct mapped_device *md);
|
||||
int dm_init_fs(void);
|
||||
void dm_fin_fs(void);
|
||||
|
||||
int dm_fs_add(struct mapped_device *md);
|
||||
int dm_fs_remove(struct mapped_device *md);
|
||||
|
||||
|
||||
#define WARN(f, x...) printk(KERN_WARNING "device-mapper: " f "\n" , ## x)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user