All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Zhou Wenjian <zhouwj-fnst@cn.fujitsu.com>
To: kexec@lists.infradead.org
Subject: [PATCH v1 3/4] Add write_kdump_page
Date: Fri, 10 Jul 2015 10:28:52 +0800	[thread overview]
Message-ID: <1436495333-22892-4-git-send-email-zhouwj-fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1436495333-22892-1-git-send-email-zhouwj-fnst@cn.fujitsu.com>

write_kdump_page is used to write page when generating kdump core.
It mainly optimizes the way of generating incomplete core.

Signed-off-by: Zhou Wenjian <zhouwj-fnst@cn.fujitsu.com>
---
 makedumpfile.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/makedumpfile.c b/makedumpfile.c
index e8b52f4..74bf83e 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -6324,6 +6324,59 @@ get_pfn_offset(void *buf, struct cache_data *cd_page){
 }
 
 int
+write_kdump_page(struct cache_data *cd_header, struct cache_data *cd_page,
+		struct page_desc *pd, void *page_data)
+{
+	int written_pfns_size;
+
+	/*
+	 * if either cd_header or cd_page is nearly full,
+	 * write the buffer cd_header into dumpfile and then write the cd_page.
+	 */
+	if ( cd_header->buf_size + sizeof(pd) > cd_header->cache_size
+		|| cd_page->buf_size + pd->size > cd_page->cache_size ){
+
+		if(!write_cd_buf(cd_header)) {
+			/*
+			 * if enospc occurs in writing cd_header,
+			 * fill the cd_header with zero and re-write it
+			 * into the dumpfile.
+			 */
+			memset(cd_header->buf, 0, cd_header->cache_size);
+			write_cd_buf(cd_header);
+
+			return FALSE;
+		}
+
+		if(!write_cd_buf(cd_page)) {
+			/*
+			 * if enospc occurs in writing cd_page,
+			 * get how many pages having been written.
+			 * and fill part of cd_header with zero according to it.
+			 */
+			written_pfns_size = sizeof(page_desc_t) *
+					get_pfn_offset(cd_header->buf, cd_page);
+
+			memset(cd_header->buf, 0, cd_header->cache_size);
+			cd_header->offset += written_pfns_size;
+			cd_header->buf_size -= written_pfns_size;
+			write_cd_buf(cd_header);
+
+			return FALSE;
+		}
+		cd_header->offset += cd_header->buf_size;
+		cd_page->offset += cd_page->buf_size;
+		cd_header->buf_size = 0;
+		cd_page->buf_size = 0;
+	}
+
+	write_cache(cd_header, pd, sizeof(page_desc_t));
+	write_cache(cd_page, page_data, pd->size);
+
+	return TRUE;
+}
+
+int
 write_kdump_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page,
 			 struct page_desc *pd_zero, off_t *offset_data, struct cycle *cycle)
 {
-- 
1.8.3.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2015-07-10  2:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10  2:28 [PATCH v1 0/4] makedumpfile: optimize the way of generating incomplete kdump core Zhou Wenjian
2015-07-10  2:28 ` [PATCH v1 1/4] Add write_cd_buf Zhou Wenjian
2015-07-15  2:35   ` HATAYAMA Daisuke
2015-07-10  2:28 ` [PATCH v1 2/4] Add get_pfn_offset Zhou Wenjian
2015-07-15  2:56   ` HATAYAMA Daisuke
2015-07-10  2:28 ` Zhou Wenjian [this message]
2015-07-15  3:09   ` [PATCH v1 3/4] Add write_kdump_page HATAYAMA Daisuke
2015-07-10  2:28 ` [PATCH v1 4/4] Use write_kdump_page instead of write_cache in write_kdump_pages_cyclic Zhou Wenjian
2015-07-15  2:32   ` HATAYAMA Daisuke
2015-07-15  2:36   ` HATAYAMA Daisuke
2015-07-15  2:31 ` [PATCH v1 0/4] makedumpfile: optimize the way of generating incomplete kdump core HATAYAMA Daisuke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436495333-22892-4-git-send-email-zhouwj-fnst@cn.fujitsu.com \
    --to=zhouwj-fnst@cn.fujitsu.com \
    --cc=kexec@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.