Blame SOURCES/kexec-tools-2.0.20-makedumpfile-Show-write-byte-size-in-report-messages.patch

e8a34c
From 0ef2ca6c9fa2f61f217a4bf5d7fd70f24e12b2eb Mon Sep 17 00:00:00 2001
e8a34c
From: Kazuhito Hagio <k-hagio-ab@nec.com>
e8a34c
Date: Thu, 4 Feb 2021 16:29:06 +0900
e8a34c
Subject: [PATCH] [PATCH] Show write byte size in report messages
e8a34c
e8a34c
Show write byte size in report messages.  This value can be different
e8a34c
from the size of the actual file because of some holes on dumpfile
e8a34c
data structure.
e8a34c
e8a34c
  $ makedumpfile --show-stats -l -d 1 vmcore dump.ld1
e8a34c
  ...
e8a34c
  Total pages     : 0x0000000000080000
e8a34c
  Write bytes     : 377686445
e8a34c
  ...
e8a34c
  # ls -l dump.ld1
e8a34c
  -rw------- 1 root root 377691573 Feb  4 16:28 dump.ld1
e8a34c
e8a34c
Note that this value should not be used with /proc/kcore to determine
e8a34c
how much disk space is needed for crash dump, because the real memory
e8a34c
usage when a crash occurs can vary widely.
e8a34c
e8a34c
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
e8a34c
---
e8a34c
 makedumpfile.c | 5 +++++
e8a34c
 1 file changed, 5 insertions(+)
e8a34c
e8a34c
diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c
e8a34c
index fcd766b..894c88e 100644
e8a34c
--- a/makedumpfile-1.6.8/makedumpfile.c
e8a34c
+++ b/makedumpfile-1.6.8/makedumpfile.c
e8a34c
@@ -48,6 +48,8 @@ char filename_stdout[] = FILENAME_STDOUT;
e8a34c
 static unsigned long long	cache_hit;
e8a34c
 static unsigned long long	cache_miss;
e8a34c
 
e8a34c
+static unsigned long long	write_bytes;
e8a34c
+
e8a34c
 static void first_cycle(mdf_pfn_t start, mdf_pfn_t max, struct cycle *cycle)
e8a34c
 {
e8a34c
 	cycle->start_pfn = round(start, info->pfn_cyclic);
e8a34c
@@ -4715,6 +4717,8 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name)
e8a34c
 {
e8a34c
 	int status, written_size = 0;
e8a34c
 
e8a34c
+	write_bytes += buf_size;
e8a34c
+
e8a34c
 	if (info->flag_dry_run)
e8a34c
 		return TRUE;
e8a34c
 
e8a34c
@@ -10002,6 +10006,7 @@ print_report(void)
e8a34c
 	REPORT_MSG("Memory Hole     : 0x%016llx\n", pfn_memhole);
e8a34c
 	REPORT_MSG("--------------------------------------------------\n");
e8a34c
 	REPORT_MSG("Total pages     : 0x%016llx\n", info->max_mapnr);
e8a34c
+	REPORT_MSG("Write bytes     : %llu\n", write_bytes);
e8a34c
 	REPORT_MSG("\n");
e8a34c
 	REPORT_MSG("Cache hit: %lld, miss: %lld", cache_hit, cache_miss);
e8a34c
 	if (cache_hit + cache_miss)
e8a34c
-- 
e8a34c
2.29.2
e8a34c