Skip to content

Commit 802934b

Browse files
committed
dm round robin: do not use this_cpu_ptr() without having preemption disabled
Use local_irq_save() to disable preemption before calling this_cpu_ptr(). Reported-by: Benjamin Block <bblock@linux.vnet.ibm.com> Fixes: b0b477c ("dm round robin: use percpu 'repeat_count' and 'current_path'") Cc: stable@vger.kernel.org # 4.6+ Suggested-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent 694d0d0 commit 802934b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/md/dm-round-robin.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,17 @@ static struct dm_path *rr_select_path(struct path_selector *ps, size_t nr_bytes)
210210
struct path_info *pi = NULL;
211211
struct dm_path *current_path = NULL;
212212

213+
local_irq_save(flags);
213214
current_path = *this_cpu_ptr(s->current_path);
214215
if (current_path) {
215216
percpu_counter_dec(&s->repeat_count);
216-
if (percpu_counter_read_positive(&s->repeat_count) > 0)
217+
if (percpu_counter_read_positive(&s->repeat_count) > 0) {
218+
local_irq_restore(flags);
217219
return current_path;
220+
}
218221
}
219222

220-
spin_lock_irqsave(&s->lock, flags);
223+
spin_lock(&s->lock);
221224
if (!list_empty(&s->valid_paths)) {
222225
pi = list_entry(s->valid_paths.next, struct path_info, list);
223226
list_move_tail(&pi->list, &s->valid_paths);

0 commit comments

Comments
 (0)