Skip to contentSkip to conversation

JFFS2 uncompressed?

DISCUSSION Steven Scholz 4 participants 14 messages Apr 8, 2003 – Apr 11, 2003 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hi there,

IIRC files are stored compressed on a JFFS2 partition.

Is there any chance that I could use JFFS2 without any compression?

I guess this might me faster for our embedded system!

Thanks,

Steven

#1 lore raw
Quoted 6 lines · Steven Scholz

IIRC files are stored compressed on a JFFS2 partition.

Is there any chance that I could use JFFS2 without any compression?

I guess this might me faster for our embedded system!

Piece of cake.
Look at fs/jffs2/compr.c, first function. Add a couple of #if 0 and you're done.

Do the same with the second function and the kernel image should shrink a little.

Jörn

Signature · 3 lines
Beware of bugs in the above code; I have only proved it correct, but
not tried it.
-- Donald Knuth
#2 lore raw
Quoted 4 lines · Jörn Engel
Quoted 2 lines · Steven Scholz

IIRC files are stored compressed on a JFFS2 partition.

Quoted 8 lines
Quoted 3 lines

Is there any chance that I could use JFFS2 without any compression?

I guess this might me faster for our embedded system!

Piece of cake.
Look at fs/jffs2/compr.c, first function. Add a couple of #if 0 and you're done.

Thanks!

How about mkfs.jff2? Do I have to change something there as well?

Quoted 2 lines

Do the same with the second function and the kernel image should shrink a little.

:o)

Steven

#3 lore raw
Quoted 2 lines · Steven Scholz

How about mkfs.jff2? Do I have to change something there as well?

Yes, you do. Shouldn't be much more complicated, but I didn't do it myself yet.

Could you post a patch for mkfs.jffs2, when done? Just for the curious.

Jörn

Signature · 2 lines
Anything that can go wrong, will.
-- Finagle's Law
#4 lore raw
Quoted 10 lines · Jörn Engel
Quoted 1 line · Steven Scholz

How about mkfs.jff2? Do I have to change something there as well?

Yes, you do. Shouldn't be much more complicated, but I didn't do it myself yet.

Could you post a patch for mkfs.jffs2, when done? Just for the curious.

It's working! :o)

Would you like a define like

#define USE_COMPRESSION

or rather

#define DONT_USE_COMP
or something like that!?

BTW: Where could I put it so mkfs.jffs2 will find it? Or should we add a command line option to mkfs.jffs2?

Steven

#5 lore raw
Quoted 2 lines · Steven Scholz

It's working! :o)

The good thing about clean code is that it's so easy to add ugly code on top of it. :)

Quoted 8 lines

Would you like a define like

#define USE_COMPRESSION

or rather

#define DONT_USE_COMP
or something like that!?

The change is simple enough already, no neef for more #ifdefs.

There is currently ongoing discussion about implementing conditional compression in several places. Either per compile, as you did it, per mount point or per inode.

Per inode is the most flexible, was already prepared a long time ago and is imo the way. If/when this is done, the only reason to use your simpler approach is to shrink the kernel image.

In short: don't bother.

Quoted 2 lines

BTW: Where could I put it so mkfs.jffs2 will find it? Or should we add a command line option to mkfs.jffs2?

I'd prefer a command line option.

Jörn

Signature · 3 lines
The grand essentials of happiness are: something to do, something to
love, and something to hope for.
-- Allan K. Chalmers
#6 lore raw
In reply to Jörn Engel
Quoted 10 lines · Jörn Engel
Quoted 1 line · Steven Scholz

How about mkfs.jff2? Do I have to change something there as well?

Yes, you do. Shouldn't be much more complicated, but I didn't do it myself yet.

Could you post a patch for mkfs.jffs2, when done? Just for the curious.

Here you are!

Just a quick hack! :o) Enjoy!

Steven

Index: util/mkfs.jffs2.c
===================================================================
RCS file: /home/cvs/mtd/util/mkfs.jffs2.c,v
retrieving revision 1.36

mkfs.jffs2.c +11 -1
diff -p -u -r1.36 mkfs.jffs2.c
@@ -98,6 +98,7 @@ static int squash_uids = 0;
 static int squash_perms = 0;
 static int fake_times = 0;
 static int target_endian = __BYTE_ORDER;
+static int do_compress = 1;
 static const char *const app_name = "mkfs.jffs2";
 static const char *const memory_exhausted = "memory exhausted";
 
@@ -691,6 +692,9 @@ unsigned char jffs2_compress(unsigned ch
 {
 	int ret;
 
+	if (! do_compress)
+		return JFFS2_COMPR_NONE; /* We don't want to compress */
+
 	ret = jffs2_zlib_compress(data_in, cpage_out, datalen, cdatalen);
 	if (!ret) {
 		return JFFS2_COMPR_ZLIB;
@@ -1177,6 +1181,7 @@ static struct option long_options[] = {
 	{"no-cleanmarkers", 0, NULL, 'n'},
 	{"cleanmarker", 1, NULL, 'c'},
 	{"squash", 0, NULL, 'q'},
+	{"no-compression", 0, NULL, 'u'},
 	{"squash-uids", 0, NULL, 'U'},
 	{"squash-perms", 0, NULL, 'P'},
 	{"faketime", 0, NULL, 'f'},
@@ -1202,6 +1207,7 @@ static char *helptext =
 	"  -D, --devtable=FILE    Use the named FILE as a device table file\n"
 	"  -f, --faketime         Change all file times to '0' for regression testing\n"
 	"  -q, --squash           Squash permissions and owners making all files be owned by root\n"
+	"  -u, --no-compression   Don't use any compression\n"
 	"  -U, --squash-uids      Squash owners making all files be owned by root\n"
 	"  -P, --squash-perms     Squash permissions on all files\n"
 	"  -h, --help             Display this help text\n"
@@ -1220,7 +1226,7 @@ int main(int argc, char **argv)
 	struct filesystem_entry *root;
 
 	while ((opt = getopt_long(argc, argv, 
-					"D:d:r:s:o:qUPfh?vVe:lbp::nc:", long_options, &c)) >= 0) 
+					"D:d:r:s:o:quUPfh?vVe:lbp::nc:", long_options, &c)) >= 0) 
 	{
 		switch (opt) {
 			case 'D':
@@ -1256,6 +1262,10 @@ int main(int argc, char **argv)
 			case 'q':
 				squash_uids = 1;
 				squash_perms = 1;
+				break;
+
+			case 'u':
+				do_compress = 0;
 				break;
 
 			case 'U':
#7 lore raw
Quoted 7 lines · Steven Scholz
Quoted 3 lines

Could you post a patch for mkfs.jffs2, when done? Just for the curious.

Here you are!

Just a quick hack! :o) Enjoy!

If you call this a quick hack, I'd like to see your clean code. Thanks!

Quoted 51 lines

Index: util/mkfs.jffs2.c
===================================================================
RCS file: /home/cvs/mtd/util/mkfs.jffs2.c,v
retrieving revision 1.36
diff -p -u -r1.36 mkfs.jffs2.c

mkfs.jffs2.c +7 -1
@@ -98,6 +98,7 @@ static int squash_uids = 0;
 static int squash_perms = 0;
 static int fake_times = 0;
 static int target_endian = __BYTE_ORDER;
+static int do_compress = 1;
 static const char *const app_name = "mkfs.jffs2";
 static const char *const memory_exhausted = "memory exhausted";
 
@@ -691,6 +692,9 @@ unsigned char jffs2_compress(unsigned ch
 {
 	int ret;
 
+	if (! do_compress)
+		return JFFS2_COMPR_NONE; /* We don't want to compress */
+
 	ret = jffs2_zlib_compress(data_in, cpage_out, datalen, cdatalen);
 	if (!ret) {
 		return JFFS2_COMPR_ZLIB;
@@ -1177,6 +1181,7 @@ static struct option long_options[] = {
 	{"no-cleanmarkers", 0, NULL, 'n'},
 	{"cleanmarker", 1, NULL, 'c'},
 	{"squash", 0, NULL, 'q'},
+	{"no-compression", 0, NULL, 'u'},
 	{"squash-uids", 0, NULL, 'U'},
 	{"squash-perms", 0, NULL, 'P'},
 	{"faketime", 0, NULL, 'f'},
@@ -1202,6 +1207,7 @@ static char *helptext =
 	"  -D, --devtable=FILE    Use the named FILE as a device table file\n"
 	"  -f, --faketime         Change all file times to '0' for regression testing\n"
 	"  -q, --squash           Squash permissions and owners making all files be owned by root\n"
+	"  -u, --no-compression   Don't use any compression\n"
 	"  -U, --squash-uids      Squash owners making all files be owned by root\n"
 	"  -P, --squash-perms     Squash permissions on all files\n"
 	"  -h, --help             Display this help text\n"
@@ -1220,7 +1226,7 @@ int main(int argc, char **argv)
 	struct filesystem_entry *root;
 
 	while ((opt = getopt_long(argc, argv, 
-					"D:d:r:s:o:qUPfh?vVe:lbp::nc:", long_options, &c)) >= 0) 
+					"D:d:r:s:o:quUPfh?vVe:lbp::nc:", long_options, &c)) >= 0) 
 	{
 		switch (opt) {
 			case 'D':

mkfs.jffs2.c int main(int argc, char **argv) · line 1271

Quoted 10 lines
mkfs.jffs2.c +4 -0
@@ -1256,6 +1262,10 @@ int main(int argc, char **argv)
 			case 'q':
 				squash_uids = 1;
 				squash_perms = 1;
+				break;
+
+			case 'u':
+				do_compress = 0;
 				break;
 
 			case 'U':

David, I don't see any obvious mistakes. Is it ok to apply?

Jörn

Signature · 3 lines
With a PC, I always felt limited by the software available. On Unix, 
I am limited only by my knowledge.
-- Peter J. Schoenster
#8 lore raw
Quoted 5 lines · Jörn Engel
Quoted 3 lines · Steven Scholz
Quoted 2 lines

Could you post a patch for mkfs.jffs2, when done? Just for the curious.

Quoted 7 lines
Quoted 3 lines

Here you are!

Just a quick hack! :o) Enjoy!

If you call this a quick hack, I'd like to see your clean code. Thanks!

;-) I am flattered! Thanks!

Quick meant I did not try to use "--no-compress" only "-u" ...

But I'd love to see my name in the MTD Hall of Fame though! ;-)

Cheers,

Steven

#9 lore raw
Quoted 1 line · Steven Scholz

But I'd love to see my name in the MTD Hall of Fame though! ;-)

Send me a SSH key and you can commit your patch and at least get your name in the $Id$ tag and the changelog... :)

Signature · 1 line
dwmw2
#10 lore raw
Quoted 2 lines · David Woodhouse
Quoted 1 line · Steven Scholz

But I'd love to see my name in the MTD Hall of Fame though! ;-)

For us, it's the cheap thrill of having our name in the MTD Hall of Fame . . .

Quoted 3 lines

Send me a SSH key and you can commit your patch and at least get your name in the $Id$ tag and the changelog... :)

For Dave, it's that he's just too lazy to commit the patches we send him . . .

;^)

Signature · 2 lines
Thayne Harbaugh
Linux Networx
#11 lore raw
Quoted 1 line · Thayne Harbaugh

For Dave, it's that he's just too lazy to commit the patches we send him

So true. And if you commit it yourself I know who to blame when three weeks later it turns out to be broken. :)

Signature · 1 line
dwmw2
#12 lore raw
In reply to David Woodhouse
Quoted 7 lines · David Woodhouse
Quoted 1 line · Steven Scholz

But I'd love to see my name in the MTD Hall of Fame though! ;-)

Send me a SSH key and you can commit your patch and at least get your name in the $Id$ tag and the changelog... :)

Do you need an entry for the man page as well?

Steven

#13 lore raw
In reply to Jörn Engel

Hallo Jörn,

hab grad den Patch gesendet. Bekam aber ein

--------------
Your mail to 'linux-mtd' with the subject

Re: JFFS2 uncompressed?

Is being held until the list moderator can review it for approval.

The reason it is being held:

Message has a suspicious header

Either the message will get posted to the list, or you will receive notification of the moderator's decision. If you would like to cancel this posting, please visit the following URL:
------------------

Hast Du den Patch bekommen?

Steven