diff options
Diffstat (limited to 'drivers/block/elevator.c')
-rw-r--r-- | drivers/block/elevator.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/block/elevator.c b/drivers/block/elevator.c index c744d2a13062..4f69d222b183 100644 --- a/drivers/block/elevator.c +++ b/drivers/block/elevator.c | |||
@@ -97,7 +97,6 @@ static struct elevator_type *elevator_find(const char *name) | |||
97 | struct elevator_type *e = NULL; | 97 | struct elevator_type *e = NULL; |
98 | struct list_head *entry; | 98 | struct list_head *entry; |
99 | 99 | ||
100 | spin_lock_irq(&elv_list_lock); | ||
101 | list_for_each(entry, &elv_list) { | 100 | list_for_each(entry, &elv_list) { |
102 | struct elevator_type *__e; | 101 | struct elevator_type *__e; |
103 | 102 | ||
@@ -108,7 +107,6 @@ static struct elevator_type *elevator_find(const char *name) | |||
108 | break; | 107 | break; |
109 | } | 108 | } |
110 | } | 109 | } |
111 | spin_unlock_irq(&elv_list_lock); | ||
112 | 110 | ||
113 | return e; | 111 | return e; |
114 | } | 112 | } |
@@ -120,12 +118,15 @@ static void elevator_put(struct elevator_type *e) | |||
120 | 118 | ||
121 | static struct elevator_type *elevator_get(const char *name) | 119 | static struct elevator_type *elevator_get(const char *name) |
122 | { | 120 | { |
123 | struct elevator_type *e = elevator_find(name); | 121 | struct elevator_type *e; |
124 | 122 | ||
125 | if (!e) | 123 | spin_lock_irq(&elv_list_lock); |
126 | return NULL; | 124 | |
127 | if (!try_module_get(e->elevator_owner)) | 125 | e = elevator_find(name); |
128 | return NULL; | 126 | if (e && !try_module_get(e->elevator_owner)) |
127 | e = NULL; | ||
128 | |||
129 | spin_unlock_irq(&elv_list_lock); | ||
129 | 130 | ||
130 | return e; | 131 | return e; |
131 | } | 132 | } |
@@ -153,11 +154,15 @@ static char chosen_elevator[16]; | |||
153 | 154 | ||
154 | static void elevator_setup_default(void) | 155 | static void elevator_setup_default(void) |
155 | { | 156 | { |
157 | struct elevator_type *e; | ||
158 | |||
156 | /* | 159 | /* |
157 | * check if default is set and exists | 160 | * check if default is set and exists |
158 | */ | 161 | */ |
159 | if (chosen_elevator[0] && elevator_find(chosen_elevator)) | 162 | if (chosen_elevator[0] && (e = elevator_get(chosen_elevator))) { |
163 | elevator_put(e); | ||
160 | return; | 164 | return; |
165 | } | ||
161 | 166 | ||
162 | #if defined(CONFIG_IOSCHED_AS) | 167 | #if defined(CONFIG_IOSCHED_AS) |
163 | strcpy(chosen_elevator, "anticipatory"); | 168 | strcpy(chosen_elevator, "anticipatory"); |
@@ -555,10 +560,9 @@ void elv_unregister_queue(struct request_queue *q) | |||
555 | 560 | ||
556 | int elv_register(struct elevator_type *e) | 561 | int elv_register(struct elevator_type *e) |
557 | { | 562 | { |
563 | spin_lock_irq(&elv_list_lock); | ||
558 | if (elevator_find(e->elevator_name)) | 564 | if (elevator_find(e->elevator_name)) |
559 | BUG(); | 565 | BUG(); |
560 | |||
561 | spin_lock_irq(&elv_list_lock); | ||
562 | list_add_tail(&e->list, &elv_list); | 566 | list_add_tail(&e->list, &elv_list); |
563 | spin_unlock_irq(&elv_list_lock); | 567 | spin_unlock_irq(&elv_list_lock); |
564 | 568 | ||