Commit fd80d140 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: fix scheduling while atomic in break_cycle()

parent 6f692b16
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ static noinline int break_cycle(struct lock_graph *g, struct printbuf *cycle)
			prt_newline(&buf);
		}

		bch2_print_string_as_lines(KERN_ERR, buf.buf);
		bch2_print_string_as_lines_nonblocking(KERN_ERR, buf.buf);
		printbuf_exit(&buf);
		BUG();
	}
+22 −3
Original line number Diff line number Diff line
@@ -252,8 +252,10 @@ void bch2_prt_u64_base2(struct printbuf *out, u64 v)
	bch2_prt_u64_base2_nbits(out, v, fls64(v) ?: 1);
}

void bch2_print_string_as_lines(const char *prefix, const char *lines)
static void __bch2_print_string_as_lines(const char *prefix, const char *lines,
					 bool nonblocking)
{
	bool locked = false;
	const char *p;

	if (!lines) {
@@ -261,7 +263,13 @@ void bch2_print_string_as_lines(const char *prefix, const char *lines)
		return;
	}

	if (!nonblocking) {
		console_lock();
		locked = true;
	} else {
		locked = console_trylock();
	}

	while (1) {
		p = strchrnul(lines, '\n');
		printk("%s%.*s\n", prefix, (int) (p - lines), lines);
@@ -269,9 +277,20 @@ void bch2_print_string_as_lines(const char *prefix, const char *lines)
			break;
		lines = p + 1;
	}
	if (locked)
		console_unlock();
}

void bch2_print_string_as_lines(const char *prefix, const char *lines)
{
	return __bch2_print_string_as_lines(prefix, lines, false);
}

void bch2_print_string_as_lines_nonblocking(const char *prefix, const char *lines)
{
	return __bch2_print_string_as_lines(prefix, lines, true);
}

int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *task, unsigned skipnr,
			gfp_t gfp)
{
+1 −0
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ void bch2_prt_u64_base2_nbits(struct printbuf *, u64, unsigned);
void bch2_prt_u64_base2(struct printbuf *, u64);

void bch2_print_string_as_lines(const char *prefix, const char *lines);
void bch2_print_string_as_lines_nonblocking(const char *prefix, const char *lines);

typedef DARRAY(unsigned long) bch_stacktrace;
int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *, unsigned, gfp_t);