diff options
author | Cheng Renquan <crquan@gmail.com> | 2009-04-02 14:55:27 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-04-02 14:55:27 -0400 |
commit | 5642b8a61a15436231adf27b2b1bd96901b623dd (patch) | |
tree | 2108366dbec955f71bc49795e3cf894d4dcd991c /drivers/md | |
parent | 35bf659b008e83e725dcd30f542e38461dbb867c (diff) |
dm target: use module refcount directly
The tt_internal's 'use' field is superfluous: the module's refcount can do
the work properly. An acceptable side-effect is that this increases the
reference counts reported by 'lsmod'.
Remove the superfluous test when removing a target module.
[Crash possible without this on SMP - agk]
Cc: stable@kernel.org
Signed-off-by: Cheng Renquan <crquan@gmail.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Reviewed-by: Alasdair G Kergon <agk@redhat.com>
Reviewed-by: Jonathan Brassow <jbrassow@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-target.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index 7decf10006e..db72c9497bb 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c | |||
@@ -18,7 +18,6 @@ struct tt_internal { | |||
18 | struct target_type tt; | 18 | struct target_type tt; |
19 | 19 | ||
20 | struct list_head list; | 20 | struct list_head list; |
21 | long use; | ||
22 | }; | 21 | }; |
23 | 22 | ||
24 | static LIST_HEAD(_targets); | 23 | static LIST_HEAD(_targets); |
@@ -44,12 +43,8 @@ static struct tt_internal *get_target_type(const char *name) | |||
44 | down_read(&_lock); | 43 | down_read(&_lock); |
45 | 44 | ||
46 | ti = __find_target_type(name); | 45 | ti = __find_target_type(name); |
47 | if (ti) { | 46 | if (ti && !try_module_get(ti->tt.module)) |
48 | if ((ti->use == 0) && !try_module_get(ti->tt.module)) | 47 | ti = NULL; |
49 | ti = NULL; | ||
50 | else | ||
51 | ti->use++; | ||
52 | } | ||
53 | 48 | ||
54 | up_read(&_lock); | 49 | up_read(&_lock); |
55 | return ti; | 50 | return ti; |
@@ -77,10 +72,7 @@ void dm_put_target_type(struct target_type *t) | |||
77 | struct tt_internal *ti = (struct tt_internal *) t; | 72 | struct tt_internal *ti = (struct tt_internal *) t; |
78 | 73 | ||
79 | down_read(&_lock); | 74 | down_read(&_lock); |
80 | if (--ti->use == 0) | 75 | module_put(ti->tt.module); |
81 | module_put(ti->tt.module); | ||
82 | |||
83 | BUG_ON(ti->use < 0); | ||
84 | up_read(&_lock); | 76 | up_read(&_lock); |
85 | 77 | ||
86 | return; | 78 | return; |
@@ -140,12 +132,6 @@ void dm_unregister_target(struct target_type *t) | |||
140 | BUG(); | 132 | BUG(); |
141 | } | 133 | } |
142 | 134 | ||
143 | if (ti->use) { | ||
144 | DMCRIT("Attempt to unregister target still in use: %s", | ||
145 | t->name); | ||
146 | BUG(); | ||
147 | } | ||
148 | |||
149 | list_del(&ti->list); | 135 | list_del(&ti->list); |
150 | kfree(ti); | 136 | kfree(ti); |
151 | 137 | ||