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