Skip to content

Commit 0acb385

Browse files
alanskindKent Overstreet
authored andcommitted
bcachefs: Fix possible console lock involved deadlock
Link: https://lore.kernel.org/all/[email protected]/T/ Reported-by: [email protected] Signed-off-by: Alan Huang <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 3315113 commit 0acb385

File tree

6 files changed

+8
-20
lines changed

6 files changed

+8
-20
lines changed

fs/bcachefs/bcachefs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ do { \
296296
#define bch2_fmt(_c, fmt) bch2_log_msg(_c, fmt "\n")
297297

298298
void bch2_print_str(struct bch_fs *, const char *, const char *);
299-
void bch2_print_str_nonblocking(struct bch_fs *, const char *, const char *);
300299

301300
__printf(2, 3)
302301
void bch2_print_opts(struct bch_opts *, const char *, ...);

fs/bcachefs/btree_locking.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static noinline __noreturn void break_cycle_fail(struct lock_graph *g)
213213
prt_newline(&buf);
214214
}
215215

216-
bch2_print_str_nonblocking(g->g->trans->c, KERN_ERR, buf.buf);
216+
bch2_print_str(g->g->trans->c, KERN_ERR, buf.buf);
217217
printbuf_exit(&buf);
218218
BUG();
219219
}

fs/bcachefs/error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static bool bch2_fs_trans_inconsistent(struct bch_fs *c, struct btree_trans *tra
6969
if (trans)
7070
bch2_trans_updates_to_text(&buf, trans);
7171
bool ret = __bch2_inconsistent_error(c, &buf);
72-
bch2_print_str_nonblocking(c, KERN_ERR, buf.buf);
72+
bch2_print_str(c, KERN_ERR, buf.buf);
7373

7474
printbuf_exit(&buf);
7575
return ret;

fs/bcachefs/super.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const char * const bch2_dev_write_refs[] = {
104104
#undef x
105105

106106
static void __bch2_print_str(struct bch_fs *c, const char *prefix,
107-
const char *str, bool nonblocking)
107+
const char *str)
108108
{
109109
#ifdef __KERNEL__
110110
struct stdio_redirect *stdio = bch2_fs_stdio_redirect(c);
@@ -114,17 +114,12 @@ static void __bch2_print_str(struct bch_fs *c, const char *prefix,
114114
return;
115115
}
116116
#endif
117-
bch2_print_string_as_lines(KERN_ERR, str, nonblocking);
117+
bch2_print_string_as_lines(KERN_ERR, str);
118118
}
119119

120120
void bch2_print_str(struct bch_fs *c, const char *prefix, const char *str)
121121
{
122-
__bch2_print_str(c, prefix, str, false);
123-
}
124-
125-
void bch2_print_str_nonblocking(struct bch_fs *c, const char *prefix, const char *str)
126-
{
127-
__bch2_print_str(c, prefix, str, true);
122+
__bch2_print_str(c, prefix, str);
128123
}
129124

130125
__printf(2, 0)

fs/bcachefs/util.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ static bool string_is_spaces(const char *str)
262262
return true;
263263
}
264264

265-
void bch2_print_string_as_lines(const char *prefix, const char *lines,
266-
bool nonblocking)
265+
void bch2_print_string_as_lines(const char *prefix, const char *lines)
267266
{
268267
bool locked = false;
269268
const char *p;
@@ -273,12 +272,7 @@ void bch2_print_string_as_lines(const char *prefix, const char *lines,
273272
return;
274273
}
275274

276-
if (!nonblocking) {
277-
console_lock();
278-
locked = true;
279-
} else {
280-
locked = console_trylock();
281-
}
275+
locked = console_trylock();
282276

283277
while (*lines) {
284278
p = strchrnul(lines, '\n');

fs/bcachefs/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ u64 bch2_read_flag_list(const char *, const char * const[]);
214214
void bch2_prt_u64_base2_nbits(struct printbuf *, u64, unsigned);
215215
void bch2_prt_u64_base2(struct printbuf *, u64);
216216

217-
void bch2_print_string_as_lines(const char *, const char *, bool);
217+
void bch2_print_string_as_lines(const char *, const char *);
218218

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

0 commit comments

Comments
 (0)