Blob Blame History Raw
Return-Path: yishimat@redhat.com
Received: from zmta04.collab.prod.int.phx2.redhat.com (LHLO
 zmta04.collab.prod.int.phx2.redhat.com) (10.5.81.11) by
 zmail24.collab.prod.int.phx2.redhat.com with LMTP; Thu, 2 Jul 2015 01:09:57
 -0400 (EDT)
Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
	by zmta04.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 29864DA114;
	Thu,  2 Jul 2015 01:09:57 -0400 (EDT)
Received: from [10.3.112.13] ([10.3.112.13])
	by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6259s7J004916;
	Thu, 2 Jul 2015 01:09:55 -0400
Subject: [RHEL7.2 PATCH resend v3 4/5] Add module of calculating start_pfn and
 end_pfn in each dumpfile.
To: kexec-kdump-list@redhat.com
References: <55929D94.4020500@redhat.com> <5594C62C.3030407@redhat.com>
Cc: Minfei Huang <mhuang@redhat.com>, bhe@redhat.com, yishimat@redhat.com
From: Yasuaki Ishimatsu <yishimat@redhat.com>
Message-ID: <5594C7A1.6020609@redhat.com>
Date: Thu, 2 Jul 2015 01:09:53 -0400
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101
 Thunderbird/38.0.1
MIME-Version: 1.0
In-Reply-To: <5594C62C.3030407@redhat.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
Content-Length: 3398

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1182379

The patch is back ported directory from the following upstream commit:

commit 2b74c02081fa0777c8cfb336adb63d9ccb2b46dd
Author: Zhou Wenjian <zhouwj-fnst@cn.fujitsu.com>
Date:   Fri Nov 7 09:44:56 2014 +0900

    [PATCH v5 4/5] Add module of calculating start_pfn and end_pfn in each

    When --split is specified in cyclic mode, start_pfn and end_pfn of each
    will be calculated to make each dumpfile have the same size.

    Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
    Signed-off-by: Zhou Wenjian <zhouwj-fnst@cn.fujitsu.com>

Resolves: rhbz#1182379
Signed-off-by: Yasuaki Ishimatsu <yishimat@redhat.com>

---
 makedumpfile-1.5.7/makedumpfile.c |   73 ++++++++++++++++++++++++++++++++++---
 1 files changed, 68 insertions(+), 5 deletions(-)

diff --git a/makedumpfile-1.5.7/makedumpfile.c b/makedumpfile-1.5.7/makedumpfile.c
index 5ffe8e1..c4309af 100644
--- a/makedumpfile-1.5.7/makedumpfile.c
+++ b/makedumpfile-1.5.7/makedumpfile.c
@@ -8218,6 +8218,65 @@ out:
 		return ret;
 }

+/*
+ * calculate end_pfn of one dumpfile.
+ * try to make every output file have the same size.
+ * splitblock_table is used to reduce calculate time.
+ */
+
+#define CURRENT_SPLITBLOCK_PFN_NUM (*cur_splitblock_num * splitblock->page_per_splitblock)
+mdf_pfn_t
+calculate_end_pfn_by_splitblock(mdf_pfn_t start_pfn,
+				 int *cur_splitblock_num)
+{
+	if (start_pfn >= info->max_mapnr)
+		return info->max_mapnr;
+
+	mdf_pfn_t end_pfn;
+	long long pfn_needed, offset;
+	char *splitblock_value_offset;
+
+	pfn_needed = info->num_dumpable / info->num_dumpfile;
+	offset = *cur_splitblock_num * splitblock->entry_size;
+	splitblock_value_offset = splitblock->table + offset;
+	end_pfn = start_pfn;
+
+	while (*cur_splitblock_num < splitblock->num && pfn_needed > 0) {
+		pfn_needed -= read_from_splitblock_table(splitblock_value_offset);
+		splitblock_value_offset += splitblock->entry_size;
+		++*cur_splitblock_num;
+	}
+
+	end_pfn = CURRENT_SPLITBLOCK_PFN_NUM;
+	if (end_pfn > info->max_mapnr)
+		end_pfn = info->max_mapnr;
+
+	return end_pfn;
+}
+
+/*
+ * calculate start_pfn and end_pfn in each output file.
+ */
+static int setup_splitting_cyclic(void)
+{
+	int i;
+	mdf_pfn_t start_pfn, end_pfn;
+	int cur_splitblock_num = 0;
+	start_pfn = end_pfn = 0;
+
+	for (i = 0; i < info->num_dumpfile - 1; i++) {
+		start_pfn = end_pfn;
+		end_pfn = calculate_end_pfn_by_splitblock(start_pfn,
+							  &cur_splitblock_num);
+		SPLITTING_START_PFN(i) = start_pfn;
+		SPLITTING_END_PFN(i) = end_pfn;
+	}
+	SPLITTING_START_PFN(info->num_dumpfile - 1) = end_pfn;
+	SPLITTING_END_PFN(info->num_dumpfile - 1) = info->max_mapnr;
+
+	return TRUE;
+}
+
 int
 setup_splitting(void)
 {
@@ -8231,12 +8290,16 @@ setup_splitting(void)
 		return FALSE;

 	if (info->flag_cyclic) {
-		for (i = 0; i < info->num_dumpfile; i++) {
-			SPLITTING_START_PFN(i) = divideup(info->max_mapnr, info->num_dumpfile) * i;
-			SPLITTING_END_PFN(i)   = divideup(info->max_mapnr, info->num_dumpfile) * (i + 1);
+		int ret = FALSE;
+
+		if (!prepare_bitmap2_buffer_cyclic()) {
+			free_bitmap_buffer();
+			return ret;
 		}
-		if (SPLITTING_END_PFN(i-1) > info->max_mapnr)
-			SPLITTING_END_PFN(i-1) = info->max_mapnr;
+		ret = setup_splitting_cyclic();
+		free_bitmap2_buffer_cyclic();
+
+		return ret;
         } else {
 		initialize_2nd_bitmap(&bitmap2);

-- 
1.7.1