|
|
7a865b |
From fa3f0ed47f3e6dbee485722d13713ad495571b7e Mon Sep 17 00:00:00 2001
|
|
|
7a865b |
From: Lianbo Jiang <lijiang@redhat.com>
|
|
|
7a865b |
Date: Fri, 23 Aug 2019 20:05:39 +0800
|
|
|
7a865b |
Subject: [PATCH 4/5] Limit the size of vmcore-dmesg.txt to 2G
|
|
|
7a865b |
|
|
|
7a865b |
With some corrupted vmcore files, the vmcore-dmesg.txt file may grow
|
|
|
7a865b |
forever till the kdump disk becomes full, and also probably causes
|
|
|
7a865b |
the disk error messages as follow:
|
|
|
7a865b |
...
|
|
|
7a865b |
sd 0:0:0:0: [sda] tag#6 FAILED Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
|
|
|
7a865b |
sd 0:0:0:0: [sda] tag#6 CDB: Read(10) 28 00 08 06 4c 98 00 00 08 00
|
|
|
7a865b |
blk_update_request: I/O error, dev sda, sector 134630552
|
|
|
7a865b |
sd 0:0:0:0: [sda] tag#7 FAILED Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
|
|
|
7a865b |
sd 0:0:0:0: [sda] tag#7 CDB: Read(10) 28 00 08 06 4c 98 00 00 08 00
|
|
|
7a865b |
blk_update_request: I/O error, dev sda, sector 134630552
|
|
|
7a865b |
...
|
|
|
7a865b |
|
|
|
7a865b |
If vmcore-dmesg.txt occupies the whole disk, the vmcore can not be
|
|
|
7a865b |
saved, this is also a problem.
|
|
|
7a865b |
|
|
|
7a865b |
Lets limit the size of vmcore-dmesg.txt to avoid such problems.
|
|
|
7a865b |
|
|
|
7a865b |
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
|
|
7a865b |
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
|
7a865b |
---
|
|
|
7a865b |
vmcore-dmesg/vmcore-dmesg.c | 10 ++++++++++
|
|
|
7a865b |
1 file changed, 10 insertions(+)
|
|
|
7a865b |
|
|
|
7a865b |
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
|
|
|
7a865b |
index fe7df8ec372c..81c2a58c9d86 100644
|
|
|
7a865b |
--- a/vmcore-dmesg/vmcore-dmesg.c
|
|
|
7a865b |
+++ b/vmcore-dmesg/vmcore-dmesg.c
|
|
|
7a865b |
@@ -5,9 +5,19 @@ typedef Elf32_Nhdr Elf_Nhdr;
|
|
|
7a865b |
|
|
|
7a865b |
extern const char *fname;
|
|
|
7a865b |
|
|
|
7a865b |
+/* stole this macro from kernel printk.c */
|
|
|
7a865b |
+#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31)
|
|
|
7a865b |
+
|
|
|
7a865b |
static void write_to_stdout(char *buf, unsigned int nr)
|
|
|
7a865b |
{
|
|
|
7a865b |
ssize_t ret;
|
|
|
7a865b |
+ static uint32_t n_bytes = 0;
|
|
|
7a865b |
+
|
|
|
7a865b |
+ n_bytes += nr;
|
|
|
7a865b |
+ if (n_bytes > LOG_BUF_LEN_MAX) {
|
|
|
7a865b |
+ fprintf(stderr, "The vmcore-dmesg.txt over 2G in size is not supported.\n");
|
|
|
7a865b |
+ exit(53);
|
|
|
7a865b |
+ }
|
|
|
7a865b |
|
|
|
7a865b |
ret = write(STDOUT_FILENO, buf, nr);
|
|
|
7a865b |
if (ret != nr) {
|
|
|
7a865b |
--
|
|
|
7a865b |
2.17.1
|
|
|
7a865b |
|