makedumpfile: Fall back to read() when mmap() fails

This is a backport of the following upstream commit:

commit 7c770ed
Author: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Date:   Thu Dec 12 16:40:31 2013 +0900

    [PATCH] Fall back to read() when mmap() fails.

    This is a fall back path for mmap().
    This patch disables mmap() when facing the issues related to mmap(),
    and read() will be used to read vmcore instead.

    Signed-off-by: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>

mmap() file operation on vmcore is working properly when the page being
accessed has different attributes on different part (ie. two different type
of memory ranges are overlapping).

A fall back mechanism is introduced in this patch, in case mmap() fails,
switch to read() afterwards.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
WANG Chao 2014-01-07 15:01:04 +08:00
parent 89a4cb24e0
commit dd7eee7e4a
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,38 @@
From 7c770ed052d8452f5d7ce027b23d1b77cf6fbce7 Mon Sep 17 00:00:00 2001
From: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Date: Thu, 12 Dec 2013 16:40:31 +0900
Subject: [PATCH 2/2] [PATCH] Fall back to read() when mmap() fails.
This is a fall back path for mmap().
This patch disables mmap() when facing the issues related to mmap(),
and read() will be used to read vmcore instead.
Signed-off-by: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
---
makedumpfile.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c
index b3af28b..20f107e 100644
--- a/makedumpfile-1.5.4/makedumpfile.c
+++ b/makedumpfile-1.5.4/makedumpfile.c
@@ -324,7 +324,15 @@ read_from_vmcore(off_t offset, void *bufptr, unsigned long size)
if (!read_with_mmap(offset, bufptr, size)) {
ERRMSG("Can't read the dump memory(%s) with mmap().\n",
info->name_memory);
- return FALSE;
+
+ ERRMSG("This kernel might have some problems about mmap().\n");
+ ERRMSG("read() will be used instead of mmap() from now.\n");
+
+ /*
+ * Fall back to read().
+ */
+ info->flag_usemmap = MMAP_DISABLE;
+ read_from_vmcore(offset, bufptr, size);
}
} else {
if (lseek(info->fd_memory, offset, SEEK_SET) == failed) {
--
1.8.4.2

View File

@ -93,6 +93,7 @@ Patch612: kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch
Patch613: kexec-tools-2.0.4-makedumpfile-Assign-non-printable-value-as-short-option.patch
Patch614: kexec-tools-2.0.4-makedumpfile-Add-help-and-man-message-for-help.patch
Patch615: kexec-tools-2.0.4-makedumpfile-Add-non-mmap-option-to-disable-mmap-manually.patch
Patch616: kexec-tools-2.0.4-makedumpfile-Fall-back-to-read-when-mmap-fails.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
@ -139,6 +140,7 @@ tar -z -x -v -f %{SOURCE19}
%patch613 -p1
%patch614 -p1
%patch615 -p1
%patch616 -p1
tar -z -x -v -f %{SOURCE13}