public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Clive Davies <cdavies@altera.com>
To: linux-mtd@lists.infradead.org
Subject: Fwd: jffs2 & new linux zlib
Date: Wed, 6 Mar 2002 08:47:20 +0000	[thread overview]
Message-ID: <200203060847.g268lKv09419@localhost.localdomain> (raw)

What, no comments at all? Shall I just check this in then? - it works for me.

Clive

----------  Forwarded Message  ----------

Subject: jffs2 & new linux zlib
Date: Tue, 19 Feb 2002 14:24:30 +0000
From: Clive Davies <cdavies@altera.com>
To: linux-mtd@lists.infradead.org

In testing jffs2 in linux 2.5.4-rmk1 I've found that kmalloc cannot allocate
objects of the size returned by zlib_deflate_workspacesize() and
zlib_inflate_workspacesize(). The patch below uses vmalloc to sucessfully
allocate the memory, however I'm not sure that this is the best approach.,
maybe it would be better to try and reduce the size of the deflate_workspace
& inflate workspace in zlib? (This might be a ridiculous idea, I haven't a
clue how zlib works) Any suggestions?

--- linux_2.5.4-rmk1/fs/jffs2/compr_zlib.c	Mon Feb 11 01:50:06 2002
+++ linux/fs/jffs2/compr_zlib.c	Tue Feb 19 13:33:24 2002
@@ -80,8 +80,7 @@ int zlib_compress(unsigned char *data_in
 		return -1;

 #ifdef __KERNEL__
-	strm.workspace = kmalloc(zlib_deflate_workspacesize(),
-				 GFP_KERNEL);
+	strm.workspace = vmalloc(zlib_deflate_workspacesize());
 	if (strm.workspace == NULL) {
 		printk(KERN_WARNING "deflateInit alloc of workspace failed\n");
 		return -1;
@@ -123,7 +122,7 @@ int zlib_compress(unsigned char *data_in

 	}
 	zlib_deflateEnd(&strm);
-	kfree(strm.workspace);
+	vfree(strm.workspace);

 	D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld\n", strm.total_in,
strm.total_out));

@@ -137,7 +136,7 @@ int zlib_compress(unsigned char *data_in

  out_err:
 	zlib_deflateEnd(&strm);
-	kfree(strm.workspace);
+	vfree(strm.workspace);
 	return -1;
 }

@@ -148,8 +147,7 @@ void zlib_decompress(unsigned char *data
 	int ret;

 #ifdef __KERNEL__
-	strm.workspace = kmalloc(zlib_inflate_workspacesize(),
-				 GFP_KERNEL);
+	strm.workspace = vmalloc(zlib_inflate_workspacesize());
 	if (strm.workspace == NULL) {
 		printk(KERN_WARNING "inflateInit alloc of workspace failed\n");
 		return;
@@ -177,5 +175,5 @@ void zlib_decompress(unsigned char *data
 		printk(KERN_NOTICE "inflate returned %d\n", ret);
 	}
 	zlib_inflateEnd(&strm);
-	kfree(strm.workspace);
+	vfree(strm.workspace);
 }

-------------------------------------------------------

             reply	other threads:[~2002-03-06  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-06  8:47 Clive Davies [this message]
2002-03-06  9:29 ` Fwd: jffs2 & new linux zlib David Woodhouse

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=200203060847.g268lKv09419@localhost.localdomain \
    --to=cdavies@altera.com \
    --cc=linux-mtd@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox