Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 802934b2 authored by Mike Snitzer's avatar Mike Snitzer
Browse files

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: default avatarBenjamin Block <bblock@linux.vnet.ibm.com>
Fixes: b0b477c7 ("dm round robin: use percpu 'repeat_count' and 'current_path'")
Cc: stable@vger.kernel.org # 4.6+
Suggested-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 694d0d0b
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -210,14 +210,17 @@ static struct dm_path *rr_select_path(struct path_selector *ps, size_t nr_bytes)
	struct path_info *pi = NULL;
	struct path_info *pi = NULL;
	struct dm_path *current_path = NULL;
	struct dm_path *current_path = NULL;


	local_irq_save(flags);
	current_path = *this_cpu_ptr(s->current_path);
	current_path = *this_cpu_ptr(s->current_path);
	if (current_path) {
	if (current_path) {
		percpu_counter_dec(&s->repeat_count);
		percpu_counter_dec(&s->repeat_count);
		if (percpu_counter_read_positive(&s->repeat_count) > 0)
		if (percpu_counter_read_positive(&s->repeat_count) > 0) {
			local_irq_restore(flags);
			return current_path;
			return current_path;
		}
		}
	}


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