Blame SOURCES/kexec-tools-2.0.8-makedumpfile-Implementation-of-dealing-with-kdump-co.patch

a6d77e
Return-Path: yishimat@redhat.com
a6d77e
Received: from zmta01.collab.prod.int.phx2.redhat.com (LHLO
a6d77e
 zmta01.collab.prod.int.phx2.redhat.com) (10.5.81.8) by
a6d77e
 zmail24.collab.prod.int.phx2.redhat.com with LMTP; Thu, 2 Jul 2015 01:15:32
a6d77e
 -0400 (EDT)
a6d77e
Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26])
a6d77e
	by zmta01.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id C144F1835B7;
a6d77e
	Thu,  2 Jul 2015 01:15:32 -0400 (EDT)
a6d77e
Received: from [10.3.112.13] ([10.3.112.13])
a6d77e
	by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t625FTop028995;
a6d77e
	Thu, 2 Jul 2015 01:15:30 -0400
a6d77e
Subject: [RHEL7.2 PATCH resend v3 3/4] Implementation of dealing with
a6d77e
 kdump-compressed dumpfile with ENOSPC error.
a6d77e
To: kexec-kdump-list@redhat.com
a6d77e
References: <55929BD5.7050709@redhat.com> <5594C856.6050503@redhat.com>
a6d77e
Cc: Minfei Huang <mhuang@redhat.com>, bhe@redhat.com, yishimat@redhat.com
a6d77e
From: Yasuaki Ishimatsu <yishimat@redhat.com>
a6d77e
Message-ID: <5594C8F1.3070006@redhat.com>
a6d77e
Date: Thu, 2 Jul 2015 01:15:29 -0400
a6d77e
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101
a6d77e
 Thunderbird/38.0.1
a6d77e
MIME-Version: 1.0
a6d77e
In-Reply-To: <5594C856.6050503@redhat.com>
a6d77e
Content-Type: text/plain; charset=utf-8
a6d77e
Content-Transfer-Encoding: 7bit
a6d77e
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26
a6d77e
Content-Length: 4314
a6d77e
a6d77e
https://bugzilla.redhat.com/show_bug.cgi?id=1182377
a6d77e
a6d77e
The patch is back ported directory from the following upstream commit:
a6d77e
a6d77e
commit 76025d3ca228affdd124b874b06d7a69573391e9
a6d77e
Author: Wang Xiao <wangx.fnst@cn.fujitsu.com>
a6d77e
Date:   Mon Oct 20 13:39:16 2014 +0900
a6d77e
a6d77e
    [PATCH v4 3/4] Implementation of dealing with kdump-compressed dumpfile with ENOSPC error.
a6d77e
a6d77e
    kdump-compressed:
a6d77e
    Dump the bitmap before any page header and page data. This format use
a6d77e
    "status" of "disk_dump_header" to indicate that it has been modified.
a6d77e
a6d77e
    Signed-of-by: Wang Xiao <wangx.fnst@cn.fujitsu.com>
a6d77e
a6d77e
Resolves: rhbz#1182377
a6d77e
Signed-off-by: Yasuaki Ishimatsu <yishimat@redhat.com>
a6d77e
Acked-by: Minfei Huang 
a6d77e
a6d77e
---
a6d77e
 makedumpfile-1.5.7/diskdump_mod.h |    2 +
a6d77e
 makedumpfile-1.5.7/makedumpfile.c |   80 ++++++++++++++++++++++++++++++++++--
a6d77e
 2 files changed, 77 insertions(+), 5 deletions(-)
a6d77e
a6d77e
diff --git a/makedumpfile-1.5.7/diskdump_mod.h b/makedumpfile-1.5.7/diskdump_mod.h
a6d77e
index dd24eb2..275ed83 100644
a6d77e
--- a/makedumpfile-1.5.7/diskdump_mod.h
a6d77e
+++ b/makedumpfile-1.5.7/diskdump_mod.h
a6d77e
@@ -95,6 +95,8 @@ struct kdump_sub_header {
a6d77e
 #define DUMP_DH_COMPRESSED_LZO	0x2	/* paged is compressed with lzo */
a6d77e
 #define DUMP_DH_COMPRESSED_SNAPPY	0x4
a6d77e
 					/* paged is compressed with snappy */
a6d77e
+#define DUMP_DH_COMPRESSED_INCOMPLETE	0x8
a6d77e
+					/* indicate an incomplete dumpfile */
a6d77e
a6d77e
 /* descriptor of each page for vmcore */
a6d77e
 typedef struct page_desc {
a6d77e
diff --git a/makedumpfile-1.5.7/makedumpfile.c b/makedumpfile-1.5.7/makedumpfile.c
a6d77e
index 141d290..4dba83e 100644
a6d77e
--- a/makedumpfile-1.5.7/makedumpfile.c
a6d77e
+++ b/makedumpfile-1.5.7/makedumpfile.c
a6d77e
@@ -3847,10 +3847,80 @@ out_close_file:
a6d77e
 }
a6d77e
a6d77e
 int
a6d77e
+check_and_modify_kdump_headers(char *filename) {
a6d77e
+	int fd, ret = FALSE;
a6d77e
+	struct disk_dump_header dh;
a6d77e
+
a6d77e
+	if (!read_disk_dump_header(&dh, filename))
a6d77e
+		return FALSE;
a6d77e
+
a6d77e
+	if ((fd = open(filename, O_RDWR)) < 0) {
a6d77e
+		ERRMSG("Can't open the dump file(%s). %s\n",
a6d77e
+		       filename, strerror(errno));
a6d77e
+		return FALSE;
a6d77e
+	}
a6d77e
+
a6d77e
+	/*
a6d77e
+	 * Set the incomplete flag to the status of disk_dump_header.
a6d77e
+	 */
a6d77e
+	dh.status |= DUMP_DH_COMPRESSED_INCOMPLETE;
a6d77e
+
a6d77e
+	/*
a6d77e
+	 * It's safe to overwrite the disk_dump_header.
a6d77e
+	 */
a6d77e
+	if (!write_buffer(fd, 0, &dh, sizeof(struct disk_dump_header), filename))
a6d77e
+		goto out_close_file;
a6d77e
+
a6d77e
+	ret = TRUE;
a6d77e
+out_close_file:
a6d77e
+	if (close(fd) < 0) {
a6d77e
+		ERRMSG("Can't close the dump file(%s). %s\n",
a6d77e
+		       filename, strerror(errno));
a6d77e
+	}
a6d77e
+
a6d77e
+	return ret;
a6d77e
+}
a6d77e
+
a6d77e
+int
a6d77e
+check_and_modify_multiple_kdump_headers() {
a6d77e
+	int i, status, ret = TRUE;
a6d77e
+	pid_t pid;
a6d77e
+	pid_t array_pid[info->num_dumpfile];
a6d77e
+
a6d77e
+	for (i = 0; i < info->num_dumpfile; i++) {
a6d77e
+		if ((pid = fork()) < 0) {
a6d77e
+			return FALSE;
a6d77e
+
a6d77e
+		} else if (pid == 0) { /* Child */
a6d77e
+			if (!check_and_modify_kdump_headers(SPLITTING_DUMPFILE(i)))
a6d77e
+				exit(1);
a6d77e
+			exit(0);
a6d77e
+		}
a6d77e
+		array_pid[i] = pid;
a6d77e
+	}
a6d77e
+
a6d77e
+	for (i = 0; i < info->num_dumpfile; i++) {
a6d77e
+		waitpid(array_pid[i], &status, WUNTRACED);
a6d77e
+		if (!WIFEXITED(status) || WEXITSTATUS(status) == 1) {
a6d77e
+			ERRMSG("Check and modify the incomplete dumpfile(%s) failed.\n",
a6d77e
+			       SPLITTING_DUMPFILE(i));
a6d77e
+			ret = FALSE;
a6d77e
+		}
a6d77e
+	}
a6d77e
+
a6d77e
+	return ret;
a6d77e
+}
a6d77e
+
a6d77e
+int
a6d77e
 check_and_modify_headers()
a6d77e
 {
a6d77e
 	if (info->flag_elf_dumpfile)
a6d77e
 		return check_and_modify_elf_headers(info->name_dumpfile);
a6d77e
+	else
a6d77e
+		if(info->flag_split)
a6d77e
+			return check_and_modify_multiple_kdump_headers();
a6d77e
+		else
a6d77e
+			return check_and_modify_kdump_headers(info->name_dumpfile);
a6d77e
 	return FALSE;
a6d77e
 }
a6d77e
a6d77e
@@ -7123,11 +7193,11 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d
a6d77e
 		if (!exclude_unnecessary_pages_cyclic(&cycle))
a6d77e
 			return FALSE;
a6d77e
a6d77e
-		if (!write_kdump_pages_cyclic(cd_header, cd_page, &pd_zero,
a6d77e
-					&offset_data, &cycle))
a6d77e
+		if (!write_kdump_bitmap2_cyclic(&cycle))
a6d77e
 			return FALSE;
a6d77e
a6d77e
-		if (!write_kdump_bitmap2_cyclic(&cycle))
a6d77e
+		if (!write_kdump_pages_cyclic(cd_header, cd_page, &pd_zero,
a6d77e
+					&offset_data, &cycle))
a6d77e
 			return FALSE;
a6d77e
 	}
a6d77e
a6d77e
@@ -8127,12 +8197,12 @@ writeout_dumpfile(void)
a6d77e
 	} else {
a6d77e
 		if (!write_kdump_header())
a6d77e
 			goto out;
a6d77e
+		if (!write_kdump_bitmap())
a6d77e
+			goto out;
a6d77e
 		if (!write_kdump_pages(&cd_header, &cd_page))
a6d77e
 			goto out;
a6d77e
 		if (!write_kdump_eraseinfo(&cd_page))
a6d77e
 			goto out;
a6d77e
-		if (!write_kdump_bitmap())
a6d77e
-			goto out;
a6d77e
 	}
a6d77e
 	if (info->flag_flatten) {
a6d77e
 		if (!write_end_flat_header())
a6d77e
-- 
a6d77e
1.7.1
a6d77e