[PATCH] printk: kmsg_dump: revert msg_print_text() workaround

From: John Ogness
Date: Thu Jan 14 2021 - 04:06:14 EST


The old msg_print_text() function only filled up to size-1 bytes of
the buffer. A workaround for this quirky behavior was implemented
with commit c9dccacfccc7 ("printk: Do not lose last line in kmsg
buffer dump").

However, with commit 896fbe20b4e2 ("printk: use the lockless
ringbuffer"), msg_print_text() was replaced by record_print_text(),
which will fill the full buffer. Therefore, the workaround is now
incorrectly assuming less data can fit into the buffer. Revert the
workaround.

Fixes: 896fbe20b4e2 ("printk: use the lockless ringbuffer")
Signed-off-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
---
This patch is on top of https://lkml.kernel.org/r/20210113164413.1599-1-john.ogness@xxxxxxxxxxxxx
and possibly could be squashed into that patch. However I recommend
keeping them separate since they affect kmsg_dump_get_buffer() in
different ways.

kernel/printk/printk.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 848b56efc9d7..489b9330f7f7 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3433,8 +3433,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,

/* move first record forward until length fits into the buffer */
seq = dumper->cur_seq;
- while (l >= size && prb_read_valid_info(prb, seq,
- &info, &line_count)) {
+ while (l > size && prb_read_valid_info(prb, seq, &info, &line_count)) {
if (r.info->seq >= dumper->next_seq)
break;
l -= get_record_print_text_size(&info, line_count, syslog, time);
--
2.20.1