Re: [RFC PATCH v2 06/11] pstore: Add decompression support to pstore

2013-08-27 Thread Aruna Balakrishnaiah

On Friday 23 August 2013 04:34 AM, Seiji Aguchi wrote:



-Original Message-
From: linux-kernel-ow...@vger.kernel.org 
[mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Aruna Balakrishnaiah
Sent: Friday, August 16, 2013 9:18 AM
To: linuxppc-...@ozlabs.org; tony.l...@intel.com; linux-kernel@vger.kernel.org; 
keesc...@chromium.org
Cc: jkeni...@linux.vnet.ibm.com; ana...@in.ibm.com; b...@kernel.crashing.org; 
cbouatmai...@gmail.com;
mah...@linux.vnet.ibm.com; ccr...@android.com
Subject: [RFC PATCH v2 06/11] pstore: Add decompression support to pstore

Based on the flag 'compressed' set or not, pstore will decompress the
data returning a plain text file. If decompression fails for a particular
record it will have the compressed data in the file which can be
decompressed with 'openssl' command line tool.

If the decompression fails and openssl doesn't work, the worst case is that 
users can't read the entry.
In that case, pstore is meaningless at all.


If decompression fails and openssl doesn't work. We have python module zlib to 
decompress

the zlib data. zlib.decompress() should do the trick.


Also, for users who want to get a single panic message, a compression is not 
needed.

So, I think we still have to support non-compression mode.
(IMO, pstore can take kdump as a model. Kdump supports both compression and 
non-compression mode.)

But, if you think my comment is outside this patchset, it's OK.
We can make it with a separate patch.

Seiji
___
Linuxppc-dev mailing list
linuxppc-...@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH v2 06/11] pstore: Add decompression support to pstore

2013-08-27 Thread Aruna Balakrishnaiah

On Friday 23 August 2013 04:34 AM, Seiji Aguchi wrote:



-Original Message-
From: linux-kernel-ow...@vger.kernel.org 
[mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Aruna Balakrishnaiah
Sent: Friday, August 16, 2013 9:18 AM
To: linuxppc-...@ozlabs.org; tony.l...@intel.com; linux-kernel@vger.kernel.org; 
keesc...@chromium.org
Cc: jkeni...@linux.vnet.ibm.com; ana...@in.ibm.com; b...@kernel.crashing.org; 
cbouatmai...@gmail.com;
mah...@linux.vnet.ibm.com; ccr...@android.com
Subject: [RFC PATCH v2 06/11] pstore: Add decompression support to pstore

Based on the flag 'compressed' set or not, pstore will decompress the
data returning a plain text file. If decompression fails for a particular
record it will have the compressed data in the file which can be
decompressed with 'openssl' command line tool.

If the decompression fails and openssl doesn't work, the worst case is that 
users can't read the entry.
In that case, pstore is meaningless at all.


If decompression fails and openssl doesn't work. We have python module zlib to 
decompress

the zlib data. zlib.decompress() should do the trick.


Also, for users who want to get a single panic message, a compression is not 
needed.

So, I think we still have to support non-compression mode.
(IMO, pstore can take kdump as a model. Kdump supports both compression and 
non-compression mode.)

But, if you think my comment is outside this patchset, it's OK.
We can make it with a separate patch.

Seiji
___
Linuxppc-dev mailing list
linuxppc-...@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [RFC PATCH v2 06/11] pstore: Add decompression support to pstore

2013-08-22 Thread Seiji Aguchi


> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org 
> [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Aruna Balakrishnaiah
> Sent: Friday, August 16, 2013 9:18 AM
> To: linuxppc-...@ozlabs.org; tony.l...@intel.com; 
> linux-kernel@vger.kernel.org; keesc...@chromium.org
> Cc: jkeni...@linux.vnet.ibm.com; ana...@in.ibm.com; b...@kernel.crashing.org; 
> cbouatmai...@gmail.com;
> mah...@linux.vnet.ibm.com; ccr...@android.com
> Subject: [RFC PATCH v2 06/11] pstore: Add decompression support to pstore
> 
> Based on the flag 'compressed' set or not, pstore will decompress the
> data returning a plain text file. If decompression fails for a particular
> record it will have the compressed data in the file which can be
> decompressed with 'openssl' command line tool.

If the decompression fails and openssl doesn't work, the worst case is that 
users can't read the entry.
In that case, pstore is meaningless at all.

Also, for users who want to get a single panic message, a compression is not 
needed.

So, I think we still have to support non-compression mode.
(IMO, pstore can take kdump as a model. Kdump supports both compression and 
non-compression mode.)

But, if you think my comment is outside this patchset, it's OK.
We can make it with a separate patch.

Seiji


RE: [RFC PATCH v2 06/11] pstore: Add decompression support to pstore

2013-08-22 Thread Seiji Aguchi


 -Original Message-
 From: linux-kernel-ow...@vger.kernel.org 
 [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Aruna Balakrishnaiah
 Sent: Friday, August 16, 2013 9:18 AM
 To: linuxppc-...@ozlabs.org; tony.l...@intel.com; 
 linux-kernel@vger.kernel.org; keesc...@chromium.org
 Cc: jkeni...@linux.vnet.ibm.com; ana...@in.ibm.com; b...@kernel.crashing.org; 
 cbouatmai...@gmail.com;
 mah...@linux.vnet.ibm.com; ccr...@android.com
 Subject: [RFC PATCH v2 06/11] pstore: Add decompression support to pstore
 
 Based on the flag 'compressed' set or not, pstore will decompress the
 data returning a plain text file. If decompression fails for a particular
 record it will have the compressed data in the file which can be
 decompressed with 'openssl' command line tool.

If the decompression fails and openssl doesn't work, the worst case is that 
users can't read the entry.
In that case, pstore is meaningless at all.

Also, for users who want to get a single panic message, a compression is not 
needed.

So, I think we still have to support non-compression mode.
(IMO, pstore can take kdump as a model. Kdump supports both compression and 
non-compression mode.)

But, if you think my comment is outside this patchset, it's OK.
We can make it with a separate patch.

Seiji


[RFC PATCH v2 06/11] pstore: Add decompression support to pstore

2013-08-16 Thread Aruna Balakrishnaiah
Based on the flag 'compressed' set or not, pstore will decompress the
data returning a plain text file. If decompression fails for a particular
record it will have the compressed data in the file which can be
decompressed with 'openssl' command line tool.

Signed-off-by: Aruna Balakrishnaiah 
---
 fs/pstore/platform.c |   53 --
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 6418eb7..0195cca0 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -162,6 +162,36 @@ error:
return ret;
 }
 
+/* Derived from logfs_uncompress */
+int pstore_decompress(void *in, void *out, size_t inlen, size_t outlen)
+{
+   int err, ret;
+
+   ret = -EIO;
+   err = zlib_inflateInit();
+   if (err != Z_OK)
+   goto error;
+
+   stream.next_in = in;
+   stream.avail_in = inlen;
+   stream.total_in = 0;
+   stream.next_out = out;
+   stream.avail_out = outlen;
+   stream.total_out = 0;
+
+   err = zlib_inflate(, Z_FINISH);
+   if (err != Z_STREAM_END)
+   goto error;
+
+   err = zlib_inflateEnd();
+   if (err != Z_OK)
+   goto error;
+
+   ret = stream.total_out;
+error:
+   return ret;
+}
+
 static void allocate_buf_for_compression(void)
 {
size_t size;
@@ -429,6 +459,7 @@ void pstore_get_records(int quiet)
struct timespec time;
int failed = 0, rc;
boolcompressed;
+   int unzipped_len = -1;
 
if (!psi)
return;
@@ -439,10 +470,28 @@ void pstore_get_records(int quiet)
 
while ((size = psi->read(, , , , , ,
psi)) > 0) {
+   if (compressed && (type == PSTORE_TYPE_DMESG)) {
+   if (big_oops_buf)
+   unzipped_len = pstore_decompress(buf,
+   big_oops_buf, size,
+   big_oops_buf_sz);
+
+   if (unzipped_len > 0) {
+   buf = big_oops_buf;
+   size = unzipped_len;
+   } else {
+   pr_err("pstore: decompression failed;"
+   "returned %d\n", unzipped_len);
+   }
+   }
rc = pstore_mkfile(type, psi->name, id, count, buf,
  (size_t)size, time, psi);
-   kfree(buf);
-   buf = NULL;
+   if (unzipped_len < 0) {
+   /* Free buffer other than big oops */
+   kfree(buf);
+   buf = NULL;
+   } else
+   unzipped_len = -1;
if (rc && (rc != -EEXIST || !quiet))
failed++;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2 06/11] pstore: Add decompression support to pstore

2013-08-16 Thread Aruna Balakrishnaiah
Based on the flag 'compressed' set or not, pstore will decompress the
data returning a plain text file. If decompression fails for a particular
record it will have the compressed data in the file which can be
decompressed with 'openssl' command line tool.

Signed-off-by: Aruna Balakrishnaiah ar...@linux.vnet.ibm.com
---
 fs/pstore/platform.c |   53 --
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 6418eb7..0195cca0 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -162,6 +162,36 @@ error:
return ret;
 }
 
+/* Derived from logfs_uncompress */
+int pstore_decompress(void *in, void *out, size_t inlen, size_t outlen)
+{
+   int err, ret;
+
+   ret = -EIO;
+   err = zlib_inflateInit(stream);
+   if (err != Z_OK)
+   goto error;
+
+   stream.next_in = in;
+   stream.avail_in = inlen;
+   stream.total_in = 0;
+   stream.next_out = out;
+   stream.avail_out = outlen;
+   stream.total_out = 0;
+
+   err = zlib_inflate(stream, Z_FINISH);
+   if (err != Z_STREAM_END)
+   goto error;
+
+   err = zlib_inflateEnd(stream);
+   if (err != Z_OK)
+   goto error;
+
+   ret = stream.total_out;
+error:
+   return ret;
+}
+
 static void allocate_buf_for_compression(void)
 {
size_t size;
@@ -429,6 +459,7 @@ void pstore_get_records(int quiet)
struct timespec time;
int failed = 0, rc;
boolcompressed;
+   int unzipped_len = -1;
 
if (!psi)
return;
@@ -439,10 +470,28 @@ void pstore_get_records(int quiet)
 
while ((size = psi-read(id, type, count, time, buf, compressed,
psi))  0) {
+   if (compressed  (type == PSTORE_TYPE_DMESG)) {
+   if (big_oops_buf)
+   unzipped_len = pstore_decompress(buf,
+   big_oops_buf, size,
+   big_oops_buf_sz);
+
+   if (unzipped_len  0) {
+   buf = big_oops_buf;
+   size = unzipped_len;
+   } else {
+   pr_err(pstore: decompression failed;
+   returned %d\n, unzipped_len);
+   }
+   }
rc = pstore_mkfile(type, psi-name, id, count, buf,
  (size_t)size, time, psi);
-   kfree(buf);
-   buf = NULL;
+   if (unzipped_len  0) {
+   /* Free buffer other than big oops */
+   kfree(buf);
+   buf = NULL;
+   } else
+   unzipped_len = -1;
if (rc  (rc != -EEXIST || !quiet))
failed++;
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/