linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
To: linuxppc-dev@ozlabs.org, paulus@samba.org,
	linux-kernel@vger.kernel.org, benh@kernel.crashing.org
Cc: jkenisto@linux.vnet.ibm.com, tony.luck@intel.com,
	mahesh@linux.vnet.ibm.com, cbouatmailru@gmail.com,
	anton@samba.org, ccross@android.com, keescook@chromium.org
Subject: [PATCH 11/11] pstore/ram: Read and write to the 'compressed' flag of pstore
Date: Mon, 15 Jul 2013 22:27:00 +0530	[thread overview]
Message-ID: <20130715165700.1520.61365.stgit@aruna-ThinkPad-T420> (raw)
In-Reply-To: <20130715164844.1520.27771.stgit@aruna-ThinkPad-T420>

In pstore write, add character 'C'(compressed) or 'D'(decompressed)
in the header while writing to Ram persistent buffer. In pstore read,
read the header and update the 'compressed' flag accordingly.

Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
---
 fs/pstore/ram.c |   36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 2927223..4027c20 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -131,6 +131,27 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
 	return prz;
 }
 
+static void ramoops_read_kmsg_hdr(char *buffer, struct timespec *time,
+				  bool *compressed)
+{
+	char data_type;
+
+	if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lu.%lu-%c\n",
+			&time->tv_sec, &time->tv_nsec, &data_type) == 3) {
+		if (data_type == 'C')
+			*compressed = true;
+		else
+			*compressed = false;
+	} else if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lu.%lu\n",
+			&time->tv_sec, &time->tv_nsec) == 2) {
+			*compressed = false;
+	} else {
+		time->tv_sec = 0;
+		time->tv_nsec = 0;
+		*compressed = false;
+	}
+}
+
 static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
 				   int *count, struct timespec *time,
 				   char **buf, bool *compressed,
@@ -153,10 +174,6 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
 	if (!prz)
 		return 0;
 
-	/* TODO(kees): Bogus time for the moment. */
-	time->tv_sec = 0;
-	time->tv_nsec = 0;
-
 	size = persistent_ram_old_size(prz);
 
 	/* ECC correction notice */
@@ -167,12 +184,14 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
 		return -ENOMEM;
 
 	memcpy(*buf, persistent_ram_old(prz), size);
+	ramoops_read_kmsg_hdr(*buf, time, compressed);
 	persistent_ram_ecc_string(prz, *buf + size, ecc_notice_size + 1);
 
 	return size + ecc_notice_size;
 }
 
-static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
+static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
+				     bool compressed)
 {
 	char *hdr;
 	struct timespec timestamp;
@@ -183,8 +202,9 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
 		timestamp.tv_sec = 0;
 		timestamp.tv_nsec = 0;
 	}
-	hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu\n",
-		(long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000));
+	hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu-%c\n",
+		(long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000),
+		compressed ? 'C' : 'D');
 	WARN_ON_ONCE(!hdr);
 	len = hdr ? strlen(hdr) : 0;
 	persistent_ram_write(prz, hdr, len);
@@ -243,7 +263,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
 
 	prz = cxt->przs[cxt->dump_write_cnt];
 
-	hlen = ramoops_write_kmsg_hdr(prz);
+	hlen = ramoops_write_kmsg_hdr(prz, compressed);
 	if (size + hlen > prz->buffer_size)
 		size = prz->buffer_size - hlen;
 	persistent_ram_write(prz, buf, size);

  parent reply	other threads:[~2013-07-15 16:57 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15 16:55 [PATCH 00/11] Add compression support to pstore Aruna Balakrishnaiah
2013-07-15 16:55 ` [PATCH 01/11] powerpc/pseries: Remove (de)compression in nvram with pstore enabled Aruna Balakrishnaiah
2013-07-15 16:55 ` [PATCH 02/11] pstore: Add new argument 'compressed' in pstore write callback Aruna Balakrishnaiah
2013-07-15 16:55 ` [PATCH 03/11] pstore/Kconfig: Select ZLIB_DEFLATE and ZLIB_INFLATE when PSTORE is selected Aruna Balakrishnaiah
2013-07-15 16:55 ` [PATCH 04/11] pstore: Add compression support to pstore Aruna Balakrishnaiah
2013-07-15 16:55 ` [PATCH 05/11] pstore: Introduce new argument 'compressed' in the read callback Aruna Balakrishnaiah
2013-07-15 16:56 ` [PATCH 06/11] pstore: Provide decompression support to pstore Aruna Balakrishnaiah
2013-07-15 16:56 ` [PATCH 07/11] pstore: Add file extension to pstore file if compressed Aruna Balakrishnaiah
2013-07-15 16:56 ` [PATCH 08/11] powerpc/pseries: Read and write to the 'compressed' flag of pstore Aruna Balakrishnaiah
2013-07-15 16:56 ` [PATCH 09/11] erst: " Aruna Balakrishnaiah
2013-07-15 16:56 ` [PATCH 10/11] efi-pstore: " Aruna Balakrishnaiah
2013-07-15 16:57 ` Aruna Balakrishnaiah [this message]
2013-08-01 10:40 ` [PATCH 00/11] Add compression support to pstore Aruna Balakrishnaiah
2013-08-01 23:42   ` Luck, Tony
2013-08-02 21:39     ` Tony Luck
2013-08-02 22:12       ` Tony Luck
2013-08-05 16:41         ` Tony Luck
2013-08-05 17:10         ` Aruna Balakrishnaiah
2013-08-05 18:22           ` Tony Luck
2013-08-05 19:41             ` Aruna Balakrishnaiah
2013-08-05 21:20               ` Tony Luck
2013-08-06 23:36                 ` Tony Luck
2013-08-07  1:58                   ` Aruna Balakrishnaiah
2013-08-07  3:25                     ` Tony Luck
2013-08-07  5:13                       ` Aruna Balakrishnaiah
2013-08-07  5:35                         ` Tony Luck
2013-08-07 17:30                           ` Tony Luck
2013-08-08  4:29                             ` Aruna Balakrishnaiah
2013-08-08  5:05                               ` Tony Luck
2013-08-07 22:22                           ` Tony Luck
2013-08-08  4:08                             ` Aruna Balakrishnaiah
2013-08-09 10:13                               ` Aruna Balakrishnaiah

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=20130715165700.1520.61365.stgit@aruna-ThinkPad-T420 \
    --to=aruna@linux.vnet.ibm.com \
    --cc=anton@samba.org \
    --cc=benh@kernel.crashing.org \
    --cc=cbouatmailru@gmail.com \
    --cc=ccross@android.com \
    --cc=jkenisto@linux.vnet.ibm.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=tony.luck@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).