Commit adce4649 authored by Joe Thornber's avatar Joe Thornber Committed by Trond Myklebust

[PATCH] dm: rwlock_t -> rw_semaphore (fluff)

Use a rw_semaphore in dm_target.c rather than a rwlock_t, just to keep
in line with dm.c
parent 659a1d12
......@@ -19,7 +19,7 @@ struct tt_internal {
};
static LIST_HEAD(_targets);
static rwlock_t _lock = RW_LOCK_UNLOCKED;
static DECLARE_RWSEM(_lock);
#define DM_MOD_NAME_SIZE 32
......@@ -42,7 +42,7 @@ static struct tt_internal *get_target_type(const char *name)
{
struct tt_internal *ti;
read_lock(&_lock);
down_read(&_lock);
ti = __find_target_type(name);
if (ti) {
......@@ -52,7 +52,7 @@ static struct tt_internal *get_target_type(const char *name)
ti->use++;
}
read_unlock(&_lock);
up_read(&_lock);
return ti;
}
......@@ -86,13 +86,13 @@ void dm_put_target_type(struct target_type *t)
{
struct tt_internal *ti = (struct tt_internal *) t;
read_lock(&_lock);
down_read(&_lock);
if (--ti->use == 0)
module_put(ti->tt.module);
if (ti->use < 0)
BUG();
read_unlock(&_lock);
up_read(&_lock);
return;
}
......@@ -117,13 +117,13 @@ int dm_register_target(struct target_type *t)
if (!ti)
return -ENOMEM;
write_lock(&_lock);
down_write(&_lock);
if (__find_target_type(t->name))
rv = -EEXIST;
else
list_add(&ti->list, &_targets);
write_unlock(&_lock);
up_write(&_lock);
return rv;
}
......@@ -131,21 +131,21 @@ int dm_unregister_target(struct target_type *t)
{
struct tt_internal *ti;
write_lock(&_lock);
down_write(&_lock);
if (!(ti = __find_target_type(t->name))) {
write_unlock(&_lock);
up_write(&_lock);
return -EINVAL;
}
if (ti->use) {
write_unlock(&_lock);
up_write(&_lock);
return -ETXTBSY;
}
list_del(&ti->list);
kfree(ti);
write_unlock(&_lock);
up_write(&_lock);
return 0;
}
......
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