On Wed, Nov 18, 2020 at 07:38:59AM -0800, Saranya Muruganandam wrote: > From: Li Xi <lixi@xxxxxxx> > > When multi-thread fsck is enabled, logs printed from multiple > threads could overlap with each other. The overlap sometimes > makes the logs unreadable because log_out() is used multiple times > for a single line. > > This patch adds leading [Thread XXX] to each logs if multi-thread > is enabed by -m option. Given that the leading "[Thread XXX]" is output using a separate printf, this is still going to result in potential overlapped messages: > +#ifdef CONFIG_PFSCK > +static void thread_log_out(struct e2fsck_thread *tinfo) > +{ > + printf("[Thread %d] %s", tinfo->et_thread_index, > + tinfo->et_log_buf); > + tinfo->et_log_length = 0; > + tinfo->et_log_buf[0] = '\0'; > +} > +#endif Instead of using a separate 2k buffer for each thread, why not just have a mutex so only one thread can be printing to the terminal and/or log files at one time? - Ted