bcachefs: Fix possible console lock involved deadlock
PATCH 1/1 bcachefs: Fix possible console lock involved deadlock
Reported-by [email protected]
Signed-off-by Alan Huang <[email protected]>
--- fs/bcachefs/bcachefs.h | 1 - fs/bcachefs/btree_locking.c | 2 +- fs/bcachefs/error.c | 2 +- fs/bcachefs/super.c | 11 +++-------- fs/bcachefs/util.c | 10 ++-------- fs/bcachefs/util.h | 2 +- 6 files changed, 8 insertions(+), 20 deletions(-)
fs/bcachefs/bcachefs.h +0 -1
@@ -271,7 +271,6 @@ do { \#define bch2_fmt (_c, fmt) bch2_log_msg(_c, fmt "\n")void bch2_print_str (struct bch_fs *,const char *,const char *); -void bch2_print_str_nonblocking (struct bch_fs *,const char *,const char *); __printf(2, 3)void bch2_print_opts (struct bch_opts *,const char *, ...);
fs/bcachefs/btree_locking.c +1 -1
@@ -237,7 +237,7 @@ static noinline int break_cycle(struct lock_graph *g, struct printbuf *cycle,prt_newline (&buf); } -bch2_print_str_nonblocking (g->g->trans->c,KERN_ERR , buf.buf); +bch2_print_str (g->g->trans->c,KERN_ERR , buf.buf);printbuf_exit (&buf);BUG (); }
fs/bcachefs/error.c +1 -1
@@ -69,7 +69,7 @@ static bool bch2_fs_trans_inconsistent(struct bch_fs *c, struct btree_trans *traif (trans)bch2_trans_updates_to_text (&buf, trans);bool ret =__bch2_inconsistent_error (c, &buf); -bch2_print_str_nonblocking (c,KERN_ERR , buf.buf); +bch2_print_str (c,KERN_ERR , buf.buf);printbuf_exit (&buf);return ret;
fs/bcachefs/super.c +3 -8
@@ -104,7 +104,7 @@ const char * const bch2_dev_write_refs[] = {#undef xstatic void __bch2_print_str (struct bch_fs *c,const char *prefix, -const char *str,bool nonblocking) +const char *str) {#ifdef __KERNEL__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, return; }#endif -bch2_print_string_as_lines (KERN_ERR , str, nonblocking); +bch2_print_string_as_lines (KERN_ERR , str); }void bch2_print_str (struct bch_fs *c,const char *prefix,const char *str) { -__bch2_print_str (c, prefix, str, false); -} - -void bch2_print_str_nonblocking (struct bch_fs *c,const char *prefix,const char *str) -{ -__bch2_print_str (c, prefix, str, true); +__bch2_print_str (c, prefix, str); }__printf (2 ,0 )
fs/bcachefs/util.c +2 -8
@@ -262,8 +262,7 @@ static bool string_is_spaces(const char *str)return true; } -void bch2_print_string_as_lines (const char *prefix,const char *lines, -bool nonblocking) +void bch2_print_string_as_lines (const char *prefix,const char *lines) {bool locked = false;const char *p;
@@ -273,12 +272,7 @@ void bch2_print_string_as_lines(const char *prefix, const char *lines,return ; } -if (!nonblocking) { -console_lock (); - locked = true; - }else { - locked =console_trylock (); - } + locked =console_trylock ();while (*lines) { p =strchrnul (lines,'\n' );
fs/bcachefs/util.h +1 -1
@@ -213,7 +213,7 @@ u64 bch2_read_flag_list(const char *, const char * const[]);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 *,const char *,bool ); +void bch2_print_string_as_lines (const char *,const char *);typedef DARRAY (unsigned long )bch_stacktrace ;int bch2_save_backtrace (bch_stacktrace *stack,struct task_struct *,unsigned ,gfp_t );
Signature · 1 line
2.48.1