jffs2 & new linux zlib
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 <[email protected]>
To: [email protected]
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?
fs/jffs2/compr_zlib.c +2 -3
@@ -80,8 +80,7 @@ int zlib_compress(unsigned char *data_inreturn -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);
}
-------------------------------------------------------
David Woodhouse
maintainerQuoted 2 lines · [email protected] said:
What, no comments at all? Shall I just check this in then? - it works for me.
Sorry, I missed this one, possibly due to it mentioning 2.5, or the combination of https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=53659
and iso8859-15 mails. Neither of which are your fault.
The code against which your patch was made never existed in my CVS tree. It was fundamentally broken, as you observed. Whoever did the zlib changes in 2.5 evidently didn't verify that _either_ jffs2 or ppp_deflate were still working. Both are now fixed in Linus' tree, and I've also back-ported the (fixed) shared zlib code to 2.4, so that I can import the changes into CVS without breaking the 2.4 build. Now, we allocate the workspaces once at init time, rather than doing it each time we need to compress/decompress something.
2.4 zlib backport patch at ftp.kernel.org:/pub/linux/kernel/people/dwmw2 or in BK tree at http://linux-mtd.bkbits.net:8080/zlib-2.4 (note jffs2-2.4 tree sitting beside it).
That tree differs from the jffs2-2_4-branch only in the zlib changes, which will make their way onto the jffs2-2_4-branch when the zlib changes get into 2.4.x.
Quoted 4 lines
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?
The inflate workspace is OK - that's only about 40KiB. If we could reduce the deflate workspace from its current 400-odd, that would be useful.
--
dwmw2