jffs2 whitespace
PATCH 1/1 jffs2 whitespace
I'm not sure if anyone else really cares about these kind of cleanup changes, but just in case someone does, here is a patch that fixes up several whitespace issues in the jffs2 code.
I believe all of these changes are consistent with what the mtd developers like to see in the code. There seems to be a lot of precedent for all of these changes.
There are no functional changes in this patch.
Here are the specific issues addressed:
* Remove all trailing whitespace
* Use tab-indentation consistently (there was some space indentation)
* Consistent placement of parenthesis for "if", "for", "while", and "switch" expressions (i.e. "if (a == b)" instead of "if( a == b )")
* Space follows all commas
* Space around binary operators (i.e. "a = b + c;" instead of "a=b+c;")
* Opening brace of function definition on its own line
* Put the "else" on the same line as the preceding and following braces
This is a rather large patch, but the changes are trivial. If this patch goes over well, I would be happy to create a similar patch for the rest of the mtd code.
Pete
[JFFS2] Whitespace cleanup
Remove all trailing whitespace.
Use tab-indentation consistently.
Changed "if( ... )" to "if (...)", same for "for" and "while". Always have a space after a comma ",..." to ", ...".
Use whitespace around binary operators "x+3" to "x + 3".
No space after function name "int foo (char bar)" to "int foo(char bar)". Opening brace for function on its own line.
"else" on same line as preceding and following braces.
[From: Peter Grayson <[email protected]>]
fs/jffs2/background.c +4 -5
@@ -17,14 +17,13 @@#include <linux/completion.h> #include "nodelist.h" -static int jffs2_garbage_collect_thread (void *);void jffs2_garbage_collect_trigger (struct jffs2_sb_info *c) {spin_lock (&c->erase_completion_lock); -if (c->gc_task &&jffs2_thread_should_wake (c)) -send_sig (SIGHUP , c->gc_task,1 ); +if (c->gc_task &&jffs2_thread_should_wake (c)) +send_sig (SIGHUP , c->gc_task,1 );spin_unlock (&c->erase_completion_lock); }
@@ -50,7 +49,7 @@D1 (printk (KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n" , pid));wait_for_completion (&c->gc_thread_start); } - +return ret; }
@@ -100,7 +99,7 @@cond_resched (); -/* Put_super will send a SIGKILL and then wait on the sem. +/* Put_super will send a SIGKILL and then wait on the sem. */ while (signal_pending (current)) {siginfo_t info;
fs/jffs2/build.c +19 -19
@@ -55,7 +55,7 @@dbg_fsbuild ("building directory inode #%u\n" , ic->ino);/* For each child, increase nlink */ -for (fd = ic->scan_dents; fd; fd = fd->next) { +for (fd = ic->scan_dents; fd; fd = fd->next) {struct jffs2_inode_cache *child_ic;if (!fd->ino)continue ;
@@ -129,10 +129,10 @@for_each_inode (i, c, ic) {if (ic->nlink)continue ; - +jffs2_build_remove_unlinked_inode (c, ic, &dead_fds);cond_resched (); - } + }dbg_fsbuild ("pass 2a starting\n" );
@@ -149,10 +149,10 @@dbg_fsbuild ("pass 2a complete\n" );dbg_fsbuild ("freeing temporary data structures\n" ); - +/* Finally, we can scan again and free the dirent structs */ for_each_inode (i, c, ic) { -while (ic->scan_dents) { +while (ic->scan_dents) { fd = ic->scan_dents; ic->scan_dents = fd->next;jffs2_free_full_dirent (fd);
@@ -161,7 +161,7 @@cond_resched (); } c->flags &= ~JFFS2_SB_FLAG_BUILDING ; - +dbg_fsbuild ("FS build complete\n" );/* Rotate the lists by some number to ensure wear levelling */
@@ -172,7 +172,7 @@ exit:if (ret) {for_each_inode (i, c, ic) { -while (ic->scan_dents) { +while (ic->scan_dents) { fd = ic->scan_dents; ic->scan_dents = fd->next;jffs2_free_full_dirent (fd);
@@ -191,7 +191,7 @@struct jffs2_full_dirent *fd;dbg_fsbuild ("removing ino #%u with nlink == zero.\n" , ic->ino); - + raw = ic->nodes;while (raw != (void *)ic) {struct jffs2_raw_node_ref *next = raw->next_in_ino;
@@ -204,7 +204,7 @@int whinged =0 ;dbg_fsbuild ("inode #%u was a directory which may have children...\n" , ic->ino); -while (ic->scan_dents) { +while (ic->scan_dents) {struct jffs2_inode_cache *child_ic; fd = ic->scan_dents;
@@ -220,7 +220,7 @@ whinged =1 ;dbg_fsbuild ("removing child \"%s\", ino #%u\n" , fd->name, fd->ino); - + child_ic =jffs2_get_ino_cache (c, fd->ino);if (!child_ic) { dbg_fsbuild("cannot remove child \"%s\", ino #%u, because it doesn't exist\n",
@@ -229,11 +229,11 @@continue ; } -/* Reduce nlink of the child. If it's now zero, stick it on the +/* Reduce nlink of the child. If it's now zero, stick it on the dead_fds list to be cleaned up later. Else just free the fd */ child_ic->nlink--; - +if (!child_ic->nlink) {dbg_fsbuild ("inode #%u (\"%s\") has now got zero nlink, adding to dead_fds list.\n" , fd->ino, fd->name);
@@ -248,7 +248,7 @@ }/* -We don't delete the inocache from the hash list and free it yet. +We don't delete the inocache from the hash list and free it yet. The erase code will do that, when all the nodes are completely gone. */ }
@@ -262,7 +262,7 @@because there's not enough free space... */ c->resv_blocks_deletion =2 ; -/* Be conservative about how much space we need before we allow writes. +/* Be conservative about how much space we need before we allow writes. On top of that which is required for deletia, require an extra 2% of the medium to be available, for overhead caused by nodes being split across blocks, etc. */
@@ -277,13 +277,13 @@ c->resv_blocks_gctrigger = c->resv_blocks_write +1 ; -/* When do we allow garbage collection to merge nodes to make +/* When do we allow garbage collection to merge nodes to make long-term progress at the expense of short-term space exhaustion? */ c->resv_blocks_gcmerge = c->resv_blocks_deletion +1 ;/* When do we allow garbage collection to eat from bad blocks rather than actually making progress? */ - c->resv_blocks_gcbad =0 ;//c->resv_blocks_deletion + 2; + c->resv_blocks_gcbad =0 ;//c->resv_blocks_deletion + 2; /* If there's less than this amount of dirty space, don't bother trying to GC to make more space. It'll be a fruitless task */
@@ -303,7 +303,7 @@ c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024);dbg_fsbuild ("Amount of dirty space required to GC: %d bytes\n" , c->nospc_dirty_size); -} +}int jffs2_do_mount_fs (struct jffs2_sb_info *c) {
@@ -320,7 +320,7 @@ c->blocks =kmalloc (sizeof (struct jffs2_eraseblock ) * c->nr_blocks,GFP_KERNEL );if (!c->blocks)return -ENOMEM ; -for (i=0 ; i<c->nr_blocks; i++) { +for (i =0 ; i < c->nr_blocks; i++) {INIT_LIST_HEAD (&c->blocks[i].list); c->blocks[i].offset = i * c->sector_size; c->blocks[i].free_size = c->sector_size;
@@ -358,7 +358,7 @@#ifndef __ECOSif (jffs2_blocks_use_vmalloc (c))vfree (c->blocks); - else + else#endif kfree (c->blocks);
fs/jffs2/compr.c +304 -306
725 lines not on this page · raw message
fs/jffs2/compr.h +21 -21
62 lines not on this page · raw message
fs/jffs2/compr_rtime.c +35 -36
134 lines not on this page · raw message
fs/jffs2/compr_rubin.c +54 -59
285 lines not on this page · raw message
fs/jffs2/compr_rubin.h +4 -4
@@ -6,13 +6,13 @@#include "pushpull.h" #define RUBIN_REG_SIZE 16 -#define UPPER_BIT_RUBIN (((long) 1)<<(RUBIN_REG_SIZE-1)) -#define LOWER_BITS_RUBIN ((((long) 1)<<(RUBIN_REG_SIZE-1))-1) +#define UPPER_BIT_RUBIN (((long) 1) << (RUBIN_REG_SIZE - 1)) +#define LOWER_BITS_RUBIN ((((long) 1) << (RUBIN_REG_SIZE - 1)) - 1)struct rubin_state { -unsigned long p; -unsigned long q; +unsigned long p; +unsigned long q;unsigned long rec_q;long bit_number;struct pushpull pp;
fs/jffs2/comprtest.c +16 -15
@@ -265,21 +265,22 @@static unsigned char comprbuf[TESTDATA_LEN ];static unsigned char decomprbuf[TESTDATA_LEN ]; -int jffs2_decompress (unsigned char comprtype,unsigned char *cdata_in, +int jffs2_decompress (unsigned char comprtype,unsigned char *cdata_in,unsigned char *data_out,uint32_t cdatalen,uint32_t datalen); -unsigned char jffs2_compress (unsigned char *data_in,unsigned char *cpage_out, + +unsigned char jffs2_compress (unsigned char *data_in,unsigned char *cpage_out,uint32_t *datalen,uint32_t *cdatalen); -int init_module (void ) { +int init_module (void ) {unsigned char comprtype;uint32_t c, d;int ret;printk ("Original data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n" , - testdata[0 ],testdata[1 ],testdata[2 ],testdata[3 ], - testdata[4 ],testdata[5 ],testdata[6 ],testdata[7 ], - testdata[8 ],testdata[9 ],testdata[10 ],testdata[11 ], - testdata[12 ],testdata[13 ],testdata[14 ],testdata[15 ]); + testdata[0 ], testdata[1 ], testdata[2 ], testdata[3 ], + testdata[4 ], testdata[5 ], testdata[6 ], testdata[7 ], + testdata[8 ], testdata[9 ], testdata[10 ], testdata[11 ], + testdata[12 ], testdata[13 ], testdata[14 ], testdata[15 ]); d =TESTDATA_LEN ; c =TESTDATA_LEN ; comprtype =jffs2_compress (testdata, comprbuf, &d, &c);
@@ -287,18 +288,18 @@printk ("jffs2_compress used compression type %d. Compressed size %d, uncompressed size %d\n" , comprtype, c, d);printk ("Compressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n" , - comprbuf[0 ],comprbuf[1 ],comprbuf[2 ],comprbuf[3 ], - comprbuf[4 ],comprbuf[5 ],comprbuf[6 ],comprbuf[7 ], - comprbuf[8 ],comprbuf[9 ],comprbuf[10 ],comprbuf[11 ], - comprbuf[12 ],comprbuf[13 ],comprbuf[14 ],comprbuf[15 ]); + comprbuf[0 ], comprbuf[1 ], comprbuf[2 ], comprbuf[3 ], + comprbuf[4 ], comprbuf[5 ], comprbuf[6 ], comprbuf[7 ], + comprbuf[8 ], comprbuf[9 ], comprbuf[10 ], comprbuf[11 ], + comprbuf[12 ], comprbuf[13 ], comprbuf[14 ], comprbuf[15 ]); ret =jffs2_decompress (comprtype, comprbuf, decomprbuf, c, d);printk ("jffs2_decompress returned %d\n" , ret);printk ("Decompressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n" , - decomprbuf[0 ],decomprbuf[1 ],decomprbuf[2 ],decomprbuf[3 ], - decomprbuf[4 ],decomprbuf[5 ],decomprbuf[6 ],decomprbuf[7 ], - decomprbuf[8 ],decomprbuf[9 ],decomprbuf[10 ],decomprbuf[11 ], - decomprbuf[12 ],decomprbuf[13 ],decomprbuf[14 ],decomprbuf[15 ]); + decomprbuf[0 ], decomprbuf[1 ], decomprbuf[2 ], decomprbuf[3 ], + decomprbuf[4 ], decomprbuf[5 ], decomprbuf[6 ], decomprbuf[7 ], + decomprbuf[8 ], decomprbuf[9 ], decomprbuf[10 ], decomprbuf[11 ], + decomprbuf[12 ], decomprbuf[13 ], decomprbuf[14 ], decomprbuf[15 ]);if (memcmp (decomprbuf, testdata, d))printk ("Compression and decompression corrupted data\n" );else
fs/jffs2/compr_zlib.c +29 -29
121 lines not on this page · raw message
fs/jffs2/crc32.h +4 -4
@@ -9,13 +9,13 @@/* Return a 32-bit CRC of the contents of the buffer. */ -static inline uint32_t +static inline uint32_t crc32 (uint32_t val,const void *ss,int len) {const unsigned char *s = ss; -while (--len >=0 ) - val = crc32_table[(val ^ *s++) &0xff ] ^ (val >>8 ); -return val; +while (--len >=0 ) + val = crc32_table[(val ^ *s++) &0xff ] ^ (val >>8 ); +return val; }#endif
fs/jffs2/debug.c +19 -19
@@ -67,7 +67,7 @@__jffs2_dbg_fragtree_paranoia_check_nolock (f);up (&f->sem); } - +void __jffs2_dbg_fragtree_paranoia_check_nolock (struct jffs2_inode_info *f) {
@@ -95,14 +95,14 @@if (frag->ofs & (PAGE_CACHE_SIZE -1 ) &&frag_prev (frag) &&frag_prev (frag)->size <PAGE_CACHE_SIZE &&frag_prev (frag)->node) {JFFS2_ERROR ("REF_PRISTINE node at 0x%08x had a previous non-hole frag in the same page. Tell dwmw2.\n" , -ref_offset (fn->raw)); +ref_offset (fn->raw)); bitched =1 ; }if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE -1 ) &&frag_next (frag) &&frag_next (frag)->size <PAGE_CACHE_SIZE &&frag_next (frag)->node) {JFFS2_ERROR ("REF_PRISTINE node at 0x%08x (%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2.\n" , -ref_offset (fn->raw), frag->ofs, frag->ofs+frag->size); +ref_offset (fn->raw), frag->ofs, frag->ofs+frag->size); bitched =1 ; } }
@@ -165,7 +165,7 @@__jffs2_dbg_acct_paranoia_check_nolock (c, jeb);spin_unlock (&c->erase_completion_lock); } - +void __jffs2_dbg_acct_paranoia_check_nolock (struct jffs2_sb_info *c,struct jffs2_eraseblock *jeb)
@@ -183,8 +183,8 @@JFFS2_ERROR ("node_ref %#08x shouldn't be in block at %#08x.\n" ,ref_offset (ref2), jeb->offset); goto error; - } +if (ref_flags (ref2) ==REF_UNCHECKED ) my_unchecked_size += totlen;else if (!ref_obsolete (ref2))
@@ -237,7 +237,7 @@__jffs2_dbg_dump_jeb_nolock (jeb);__jffs2_dbg_dump_block_lists_nolock (c); BUG(); - + }#endif /* JFFS2_DBG_PARANOIA_CHECKS */
@@ -321,7 +321,7 @@ __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c) {printk (JFFS2_DBG_MSG_PREFIX " dump JFFS2 blocks lists:\n" ); - +printk (JFFS2_DBG "flash_size: %#08x\n" , c->flash_size);printk (JFFS2_DBG "used_size: %#08x\n" , c->used_size);printk (JFFS2_DBG "dirty_size: %#08x\n" , c->dirty_size);
@@ -332,7 +332,7 @@printk (JFFS2_DBG "bad_size: %#08x\n" , c->bad_size);printk (JFFS2_DBG "sector_size: %#08x\n" , c->sector_size);printk (JFFS2_DBG "jffs2_reserved_blocks size: %#08x\n" , - c->sector_size * c->resv_blocks_write); + c->sector_size * c->resv_blocks_write);if (c->nextblock) printk(JFFS2_DBG "nextblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n",
@@ -546,7 +546,7 @@int buggy =0 ;printk (JFFS2_DBG_MSG_PREFIX " dump fragtree of ino #%u\n" , f->inocache->ino); -while (this) { +while (this) {if (this->node) printk(JFFS2_DBG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), right (%p), parent (%p)\n", this->ofs, this->ofs+this->size, ref_offset(this->node->raw),
@@ -577,15 +577,15 @@ {int skip;int i; - +printk (JFFS2_DBG_MSG_PREFIX " dump from offset %#08x to offset %#08x (%x bytes).\n" , offs, offs + len, len); i = skip = offs %JFFS2_BUFDUMP_BYTES_PER_LINE ; offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE -1 ); - +if (skip !=0 )printk (JFFS2_DBG "%#08x: " , offs); - +while (skip--)printk (" " );
@@ -598,7 +598,7 @@ }printk ("%02x " , buf[i]); - + i +=1 ; }
@@ -616,7 +616,7 @@size_t retlen;uint32_t crc;int ret; - +printk (JFFS2_DBG_MSG_PREFIX " dump node at offset %#08x.\n" , ofs); ret =jffs2_flash_read (c, ofs, len, &retlen, (unsigned char *)&node);
@@ -630,13 +630,13 @@printk (JFFS2_DBG "nodetype:\t%#04x\n" ,je16_to_cpu (node.u.nodetype));printk (JFFS2_DBG "totlen:\t%#08x\n" ,je32_to_cpu (node.u.totlen));printk (JFFS2_DBG "hdr_crc:\t%#08x\n" ,je32_to_cpu (node.u.hdr_crc)); - + crc =crc32 (0 , &node.u,sizeof (node.u) -4 );if (crc !=je32_to_cpu (node.u.hdr_crc)) {JFFS2_ERROR ("wrong common header CRC.\n" );return ; } - +if (je16_to_cpu (node.u.magic) !=JFFS2_MAGIC_BITMASK &&je16_to_cpu (node.u.magic) !=JFFS2_OLD_MAGIC_BITMASK ) {
@@ -668,7 +668,7 @@printk (JFFS2_DBG "data_crc:\t%#08x\n" ,je32_to_cpu (node.i.data_crc));printk (JFFS2_DBG "node_crc:\t%#08x\n" ,je32_to_cpu (node.i.node_crc)); - crc =crc32 (0 , &node.i,sizeof (node.i) -8 ); + crc =crc32 (0 , &node.i,sizeof (node.i) -8 );if (crc !=je32_to_cpu (node.i.node_crc)) {JFFS2_ERROR ("wrong node header CRC.\n" );return ;
@@ -686,11 +686,11 @@printk (JFFS2_DBG "type:\t%#02x\n" , node.d.type);printk (JFFS2_DBG "node_crc:\t%#08x\n" ,je32_to_cpu (node.d.node_crc));printk (JFFS2_DBG "name_crc:\t%#08x\n" ,je32_to_cpu (node.d.name_crc)); - + node.d.name[node.d.nsize] ='\0' ;printk (JFFS2_DBG "name:\t\"%s\"\n" , node.d.name); - crc =crc32 (0 , &node.d,sizeof (node.d) -8 ); + crc =crc32 (0 , &node.d,sizeof (node.d) -8 );if (crc !=je32_to_cpu (node.d.node_crc)) {JFFS2_ERROR ("wrong node header CRC.\n" );return ;
fs/jffs2/debug.h +12 -12
@@ -24,7 +24,7 @@#define JFFS2_DBG_PARANOIA_CHECKS #define JFFS2_DBG_DUMPS -/* +/* * By defining/undefining the below macros one may select debugging messages * fro specific JFFS2 subsystems. */
@@ -45,7 +45,7 @@/* Sanity checks are supposed to be light-weight and enabled by default */ #define JFFS2_DBG_SANITY_CHECKS -/* +/* * Dx() are mainly used for debugging messages, they must go away and be * superseded by nicer dbg_xxx() macros... */
@@ -83,30 +83,30 @@printk (JFFS2_ERR_MSG_PREFIX \" (%d) %s: " fmt, current->pid, \ __FUNCTION__, ##__VA_ARGS__); \ - } while(0) + } while (0)#define JFFS2_WARNING (fmt, ...) \ do { \ printk(JFFS2_WARN_MSG_PREFIX \ " (%d) %s: " fmt, current->pid, \ __FUNCTION__, ##__VA_ARGS__); \ - } while(0) - + } while (0) +#define JFFS2_NOTICE (fmt, ...) \ do { \ printk(JFFS2_NOTICE_MSG_PREFIX \ " (%d) %s: " fmt, current->pid, \ __FUNCTION__, ##__VA_ARGS__); \ - } while(0) + } while (0)#define JFFS2_DEBUG (fmt, ...) \ do { \ printk(JFFS2_DBG_MSG_PREFIX \ " (%d) %s: " fmt, current->pid, \ __FUNCTION__, ##__VA_ARGS__); \ - } while(0) + } while (0) -/* +/* * We split our debugging messages on several parts, depending on the JFFS2 * subsystem the message belongs to. */
@@ -187,7 +187,7 @@ __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);void __jffs2_dbg_acct_paranoia_check (struct jffs2_sb_info *c, -struct jffs2_eraseblock *jeb); +struct jffs2_eraseblock *jeb);void __jffs2_dbg_acct_paranoia_check_nolock (struct jffs2_sb_info *c,struct jffs2_eraseblock *jeb);
@@ -206,7 +206,7 @@ __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);void __jffs2_dbg_dump_node_refs (struct jffs2_sb_info *c, -struct jffs2_eraseblock *jeb); +struct jffs2_eraseblock *jeb);void __jffs2_dbg_dump_node_refs_nolock (struct jffs2_sb_info *c,struct jffs2_eraseblock *jeb);
@@ -225,9 +225,9 @@#define jffs2_dbg_fragtree_paranoia_check_nolock (f) \ __jffs2_dbg_fragtree_paranoia_check_nolock(f)#define jffs2_dbg_acct_paranoia_check (c, jeb) \ - __jffs2_dbg_acct_paranoia_check(c,jeb) + __jffs2_dbg_acct_paranoia_check(c, jeb)#define jffs2_dbg_acct_paranoia_check_nolock (c, jeb) \ - __jffs2_dbg_acct_paranoia_check_nolock(c,jeb) + __jffs2_dbg_acct_paranoia_check_nolock(c, jeb)#define jffs2_dbg_prewrite_paranoia_check (c, ofs, len) \ __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)#else
fs/jffs2/dir.c +50 -66
335 lines not on this page · raw message
fs/jffs2/ecos/cdl/jffs2.cdl +12 -12
@@ -70,7 +70,7 @@ requires CYGPKG_LINUX_COMPAT requires CYGPKG_CRC - implements CYGINT_IO_FILEIO_FS + implements CYGINT_IO_FILEIO_FS compile -library=libextras.a fs-ecos.c compile build.c scan.c malloc-ecos.c nodelist.c nodemgmt.c readinode.c dir-ecos.c read.c compr.c debug.c
@@ -84,11 +84,11 @@ compile gcthread.c requires CYGPKG_KERNEL description " - Enable background garbage collection thread, for making - free space ahead of time. Leave this off till it's been + Enable background garbage collection thread, for making + free space ahead of time. Leave this off till it's been implemented. And don't implement it till icache locking has been made thread-safe. - " + " cdl_option CYGNUM_JFFS2_GC_THREAD_PRIORITY {
@@ -108,7 +108,7 @@ This option sets the size of the stack used for jffs2 garbage collect thread" } - + cdl_option CYGNUM_JFFS2_GS_THREAD_TICKS { display "ticks between each garbage collect" flavor data
@@ -117,7 +117,7 @@ This option sets how many clock ticks there will be between each garbage collect operation triggered by the background thread" - } + } } cdl_option CYGOPT_FS_JFFS2_WRITE {
@@ -182,7 +182,7 @@ compile compr_rtime.c default_value 1 description " - Use the rtime algorithm for compression of data. This + Use the rtime algorithm for compression of data. This simple algorithm often manages to squeeze and extra few bytes from data already compressed with gzip." }
@@ -194,7 +194,7 @@ requires CYGOPT_FS_JFFS2_COMPRESS compile compr_rubin.c description " - Use the rubin algorithm for compression of data. This + Use the rubin algorithm for compression of data. This simple algorithm is faster than zlib but not quite as effective." }
@@ -205,10 +205,10 @@ legal_values { "NONE" "PRIORITY" "SIZE" } define CONFIG_JFFS2_CMODE description " - You can set here the default compression mode of JFFS2 from + You can set here the default compression mode of JFFS2 from the avaiable compression modes. NONE causes no compression to be performed. PRIORITY tries the compressors in a predefined - order and chooses the first successfull one. SIZE tries all + order and chooses the first successfull one. SIZE tries all compressors and chooses the one which has the smallest result" } }
@@ -262,10 +262,10 @@ no_define calculated { "tests/jffs2_1 tests/jffs2_2 tests/jffs2_3" } description " - This option specifies the set of tests for the JFFS2 + This option specifies the set of tests for the JFFS2 FS package." } - + } # End of jffs2.cdl
fs/jffs2/ecos/ChangeLog +75 -75
322 lines not on this page · raw message
fs/jffs2/ecos/doc/readme.txt +3 -3
@@ -1,15 +1,15 @@ This package is a port of the JFFS2 flash filing system to eCos. It has been developed on the Compaq Ipaq, and has not been tested on any other device. -This code is subject to the original licensing terms, and additionally it -should be noted that this code is still in an early stage of development. +This code is subject to the original licensing terms, and additionally it +should be noted that this code is still in an early stage of development. As this code will write to flash directly, caution should be exercised in its use. It may cause areas of the flash chips essential to the operation of the device to become corrupted. -Minor modifications are necessary to the the eCos flash drivers +Minor modifications are necessary to the the eCos flash drivers io/flash/current/src/flash.c
fs/jffs2/ecos/src/dir-ecos.c +24 -24
142 lines not on this page · raw message
fs/jffs2/ecos/src/fs-ecos.c +53 -53
295 lines not on this page · raw message
fs/jffs2/ecos/src/gcthread.c +22 -22
44 lines not on this page · raw message
fs/jffs2/ecos/tests/jffs2_1.c +80 -80
160 lines not on this page · raw message
fs/jffs2/ecos/tests/jffs2_2.c +36 -36
72 lines not on this page · raw message
fs/jffs2/erase.c +29 -29
58 lines not on this page · raw message
fs/jffs2/file.c +20 -21
41 lines not on this page · raw message
fs/jffs2/fs.c +39 -39
78 lines not on this page · raw message
fs/jffs2/gc.c +76 -73
149 lines not on this page · raw message
fs/jffs2/nodelist.c +96 -96
192 lines not on this page · raw message
fs/jffs2/nodemgmt.c +71 -74
145 lines not on this page · raw message
fs/jffs2/rbtree.c +15 -26
41 lines not on this page · raw message
fs/jffs2/readinode.c +54 -53
107 lines not on this page · raw message
fs/jffs2/scan.c +55 -52
107 lines not on this page · raw message
fs/jffs2/wbuf.c +116 -112
228 lines not on this page · raw message
fs/jffs2/write.c +53 -56
109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 11 lines · Peter Grayson
I'm not sure if anyone else really cares about these kind of cleanup changes, but just in case someone does, here is a patch that fixes up several whitespace issues in the jffs2 code.
I believe all of these changes are consistent with what the mtd developers like to see in the code. There seems to be a lot of precedent for all of these changes.
There are no functional changes in this patch.
Quoted 8 lines
Here are the specific issues addressed:
* Remove all trailing whitespace
* Use tab-indentation consistently (there was some space indentation)
* Consistent placement of parenthesis for "if", "for", "while", and "switch" expressions (i.e. "if (a == b)" instead of "if( a == b )")
* Space follows all commas
* Space around binary operators (i.e. "a = b + c;" instead of "a=b+c;")
This one may be controversial. Ime, there are cases when spaces should not be used based on some strict rule, but rather to logically group expressions.
Quoted 6 lines
* Opening brace of function definition on its own line
* Put the "else" on the same line as the preceding and following bracesThis is a rather large patch, but the changes are trivial. If this patch goes over well, I would be happy to create a similar patch for the rest of the mtd code.
I'm not sure about this. Apart from the binary operator cases, your changes are definitely a slight improvement. But the patch is also peeing on every lantern pole in the county:
61 files changed, 1677 insertions(+), 1713 deletions(-)
How can I trust you that you didn't introduce a security problem on line 6789 of your 9485 line patch, by intention or not. I'd have to read it all, which is quite boring.
And if all goes well, pretty much every single patch maintained outside of cvs would break after merging this. There must be a collision _somewhere_, after all.
So I guess the short answer is "no".
My usual approach to whitespace cleanup, btw., is as a first step before I change some code anyway. Even whitespace patches should get tested and since I need some testing anyway and they help me read and change the code, the cleanup is gaining me more than it costs.
Jörn
Signature · 2 lines
A victorious army first wins and then seeks battle. -- Sun Tzu
Quoted 13 lines · Jörn Engel
I'm not sure about this. Apart from the binary operator cases, your changes are definitely a slight improvement. But the patch is also peeing on every lantern pole in the county:
61 files changed, 1677 insertions(+), 1713 deletions(-)How can I trust you that you didn't introduce a security problem on line 6789 of your 9485 line patch, by intention or not. I'd have to read it all, which is quite boring.
And if all goes well, pretty much every single patch maintained outside of cvs would break after merging this. There must be a collision _somewhere_, after all.
Quoted 6 lines
So I guess the short answer is "no".
My usual approach to whitespace cleanup, btw., is as a first step before I change some code anyway. Even whitespace patches should get tested and since I need some testing anyway and they help me read and change the code, the cleanup is gaining me more than it costs.
Well, I looked through the patch and have not found anything really bad. Some changes are neutral, but as for me the patch is OK. And why should we care about external patches? Let people work them out and regenerate. :-)
Signature · 3 lines
Best Regards, Artem B. Bityuckiy, St.-Petersburg, Russia.
Quoted 4 lines · Artem B. Bityutskiy
Well, I looked through the patch and have not found anything really bad. Some changes are neutral, but as for me the patch is OK. And why should we care about external patches? Let people work them out and regenerate. :-)
Because we want things like ebh, summary, xattr, etc.? If we accept this patch, it makes life a bit worse for people who write the stuff we want. It may be the straw that makes them go away and never come back.
Jörn
Signature · 4 lines
My second remark is that our intellectual powers are rather geared to master static relations and that our powers to visualize processes evolving in time are relatively poorly developed. -- Edsger W. Dijkstra
Quoted 4 lines · Jörn Engel
Because we want things like ebh, summary, xattr, etc.? If we accept this patch, it makes life a bit worse for people who write the stuff we want. It may be the straw that makes them go away and never come back.
Ok, but the patch also does the right thing, isn't it? Then let's get determined with (1) will it be accepted at all and (2) when?
Signature · 3 lines
Best Regards, Artem B. Bityuckiy, St.-Petersburg, Russia.
Quoted 8 lines · Artem B. Bityutskiy
Quoted 4 lines · Jörn Engel
Because we want things like ebh, summary, xattr, etc.? If we accept this patch, it makes life a bit worse for people who write the stuff we want. It may be the straw that makes them go away and never come back.
Ok, but the patch also does the right thing, isn't it? Then let's get determined with (1) will it be accepted at all and (2) when?
(1) no.
Imo, the costs outweigh the benefit. [ Which doesn't mean that I question the benefit. It's just not big enough. ]
Jörn
Signature · 4 lines
To recognize individual spam features you have to try to get into the mind of the spammer, and frankly I want to spend as little time inside the minds of spammers as possible. -- Paul Graham
Quoted 6 lines · Jörn Engel
Quoted 5 lines · Artem B. Bityutskiy
Quoted 4 lines · Jörn Engel
Because we want things like ebh, summary, xattr, etc.? If we accept this patch, it makes life a bit worse for people who write the stuff we want. It may be the straw that makes them go away and never come back.
I agree that other patches are more important than code formatting. However, we may also enable more people to contribute to jffs2 if the code is as readable/understandable as possible. I want to help make a small, but tangible step in that direction.
Quoted 2 lines
Imo, the costs outweigh the benefit. [ Which doesn't mean that I question the benefit. It's just not big enough. ]
Since there appears to be at least some benefit, maybe we can do this in easy to digest pieces. I have made another patch just against the files concerning compression in jffs2. These files had a lot of problems and I do not believe they conflict with any of the main outstanding patches (ebh, xattr, centsum).
Thanks to Jörn and Artem for their feedback; it is much appreciated.
Pete
fs/jffs2/compr.c +304 -306
@@ -24,151 +24,150 @@static int jffs2_compression_mode =JFFS2_COMPR_MODE_PRIORITY ;/* Statistics for blocks stored without compression */ -static uint32_t none_stat_compr_blocks=0 ,none_stat_decompr_blocks=0 ,none_stat_compr_size=0 ; +static uint32_t none_stat_compr_blocks =0 , none_stat_decompr_blocks =0 , none_stat_compr_size =0 ;/* jffs2_compress: * @data: Pointer to uncompressed data * @cdata: Pointer to returned pointer to buffer for compressed data * @datalen: On entry, holds the amount of data available for compression. -* On exit, expected to hold the amount of data actually compressed. +* On exit, expected to hold the amount of data actually compressed. * @cdatalen: On entry, holds the amount of space available for compressed -* data. On exit, expected to hold the actual size of the compressed -* data. +* data. On exit, expected to hold the actual size of the compressed +* data. * * Returns: Lower byte to be stored with data indicating compression type used. -* Zero is used to show that the data could not be compressed - the +* Zero is used to show that the data could not be compressed - the * compressed version was actually larger than the original. * Upper byte will be used later. (soon) * * If the cdata buffer isn't large enough to hold all the uncompressed data, -* jffs2_compress should compress as much as will fit, and should set +* jffs2_compress should compress as much as will fit, and should set * *datalen accordingly to show the amount of data which were compressed. */ uint16_t jffs2_compress (struct jffs2_sb_info *c,struct jffs2_inode_info *f, -unsigned char *data_in,unsigned char **cpage_out, -uint32_t *datalen,uint32_t *cdatalen) +unsigned char *data_in,unsigned char **cpage_out, +uint32_t *datalen,uint32_t *cdatalen) {int ret =JFFS2_COMPR_NONE ; -int compr_ret; -struct jffs2_compressor *this, *best=NULL ; -unsigned char *output_buf =NULL , *tmp_buf; -uint32_t orig_slen, orig_dlen; -uint32_t best_slen=0 , best_dlen=0 ; - -switch (jffs2_compression_mode) { -case JFFS2_COMPR_MODE_NONE : -break ; -case JFFS2_COMPR_MODE_PRIORITY : - output_buf =kmalloc (*cdatalen,GFP_KERNEL ); -if (!output_buf) { -printk (KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n" ); - goto out; - } - orig_slen = *datalen; - orig_dlen = *cdatalen; -spin_lock (&jffs2_compressor_list_lock); -list_for_each_entry (this, &jffs2_compressor_list, list) { -/* Skip decompress-only backwards-compatibility and disabled modules */ -if ((!this->compress)||(this->disabled)) -continue ; - - this->usecount++; -spin_unlock (&jffs2_compressor_list_lock); - *datalen = orig_slen; - *cdatalen = orig_dlen; - compr_ret = this->compress (data_in, output_buf, datalen, cdatalen,NULL ); -spin_lock (&jffs2_compressor_list_lock); - this->usecount--; -if (!compr_ret) { - ret = this->compr; - this->stat_compr_blocks++; - this->stat_compr_orig_size += *datalen; - this->stat_compr_new_size += *cdatalen; -break ; - } - } -spin_unlock (&jffs2_compressor_list_lock); -if (ret ==JFFS2_COMPR_NONE )kfree (output_buf); -break ; -case JFFS2_COMPR_MODE_SIZE : - orig_slen = *datalen; - orig_dlen = *cdatalen; -spin_lock (&jffs2_compressor_list_lock); -list_for_each_entry (this, &jffs2_compressor_list, list) { -/* Skip decompress-only backwards-compatibility and disabled modules */ -if ((!this->compress)||(this->disabled)) -continue ; -/* Allocating memory for output buffer if necessary */ -if ((this->compr_buf_size<orig_dlen)&&(this->compr_buf)) { -spin_unlock (&jffs2_compressor_list_lock); -kfree (this->compr_buf); -spin_lock (&jffs2_compressor_list_lock); - this->compr_buf_size=0 ; - this->compr_buf=NULL ; - } -if (!this->compr_buf) { -spin_unlock (&jffs2_compressor_list_lock); - tmp_buf =kmalloc (orig_dlen,GFP_KERNEL ); -spin_lock (&jffs2_compressor_list_lock); -if (!tmp_buf) { -printk (KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n" ,orig_dlen); -continue ; - } -else { - this->compr_buf = tmp_buf; - this->compr_buf_size = orig_dlen; - } - } - this->usecount++; -spin_unlock (&jffs2_compressor_list_lock); - *datalen = orig_slen; - *cdatalen = orig_dlen; - compr_ret = this->compress (data_in, this->compr_buf, datalen, cdatalen,NULL ); -spin_lock (&jffs2_compressor_list_lock); - this->usecount--; -if (!compr_ret) { -if ((!best_dlen)||(best_dlen>*cdatalen)) { - best_dlen = *cdatalen; - best_slen = *datalen; - best = this; - } - } - } -if (best_dlen) { - *cdatalen = best_dlen; - *datalen = best_slen; - output_buf = best->compr_buf; - best->compr_buf =NULL ; - best->compr_buf_size =0 ; - best->stat_compr_blocks++; - best->stat_compr_orig_size += best_slen; - best->stat_compr_new_size += best_dlen; - ret = best->compr; - } -spin_unlock (&jffs2_compressor_list_lock); -break ; -default : -printk (KERN_ERR "JFFS2: unknow compression mode.\n" ); - } +int compr_ret; +struct jffs2_compressor *this, *best =NULL ; +unsigned char *output_buf =NULL , *tmp_buf; +uint32_t orig_slen, orig_dlen; +uint32_t best_slen =0 , best_dlen =0 ; + +switch (jffs2_compression_mode) { +case JFFS2_COMPR_MODE_NONE : +break ; +case JFFS2_COMPR_MODE_PRIORITY : + output_buf =kmalloc (*cdatalen,GFP_KERNEL ); +if (!output_buf) { +printk (KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n" ); + goto out; + } + orig_slen = *datalen; + orig_dlen = *cdatalen; +spin_lock (&jffs2_compressor_list_lock); +list_for_each_entry (this, &jffs2_compressor_list, list) { +/* Skip decompress-only backwards-compatibility and disabled modules */ +if ((!this->compress)||(this->disabled)) +continue ; + + this->usecount++; +spin_unlock (&jffs2_compressor_list_lock); + *datalen = orig_slen; + *cdatalen = orig_dlen; + compr_ret = this->compress (data_in, output_buf, datalen, cdatalen,NULL ); +spin_lock (&jffs2_compressor_list_lock); + this->usecount--; +if (!compr_ret) { + ret = this->compr; + this->stat_compr_blocks++; + this->stat_compr_orig_size += *datalen; + this->stat_compr_new_size += *cdatalen; +break ; + } + } +spin_unlock (&jffs2_compressor_list_lock); +if (ret ==JFFS2_COMPR_NONE ) +kfree (output_buf); +break ; +case JFFS2_COMPR_MODE_SIZE : + orig_slen = *datalen; + orig_dlen = *cdatalen; +spin_lock (&jffs2_compressor_list_lock); +list_for_each_entry (this, &jffs2_compressor_list, list) { +/* Skip decompress-only backwards-compatibility and disabled modules */ +if ((!this->compress)||(this->disabled)) +continue ; +/* Allocating memory for output buffer if necessary */ +if ((this->compr_buf_size < orig_dlen)&&(this->compr_buf)) { +spin_unlock (&jffs2_compressor_list_lock); +kfree (this->compr_buf); +spin_lock (&jffs2_compressor_list_lock); + this->compr_buf_size =0 ; + this->compr_buf =NULL ; + } +if (!this->compr_buf) { +spin_unlock (&jffs2_compressor_list_lock); + tmp_buf =kmalloc (orig_dlen,GFP_KERNEL ); +spin_lock (&jffs2_compressor_list_lock); +if (!tmp_buf) { +printk (KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n" , orig_dlen); +continue ; + }else { + this->compr_buf = tmp_buf; + this->compr_buf_size = orig_dlen; + } + } + this->usecount++; +spin_unlock (&jffs2_compressor_list_lock); + *datalen = orig_slen; + *cdatalen = orig_dlen; + compr_ret = this->compress (data_in, this->compr_buf, datalen, cdatalen,NULL ); +spin_lock (&jffs2_compressor_list_lock); + this->usecount--; +if (!compr_ret) { +if ((!best_dlen) || (best_dlen > *cdatalen)) { + best_dlen = *cdatalen; + best_slen = *datalen; + best = this; + } + } + } +if (best_dlen) { + *cdatalen = best_dlen; + *datalen = best_slen; + output_buf = best->compr_buf; + best->compr_buf =NULL ; + best->compr_buf_size =0 ; + best->stat_compr_blocks++; + best->stat_compr_orig_size += best_slen; + best->stat_compr_new_size += best_dlen; + ret = best->compr; + } +spin_unlock (&jffs2_compressor_list_lock); +break ; +default : +printk (KERN_ERR "JFFS2: unknow compression mode.\n" ); + } out: -if (ret ==JFFS2_COMPR_NONE ) { - *cpage_out = data_in; - *datalen = *cdatalen; - none_stat_compr_blocks++; - none_stat_compr_size += *datalen; - } -else { - *cpage_out = output_buf; - } +if (ret ==JFFS2_COMPR_NONE ) { + *cpage_out = data_in; + *datalen = *cdatalen; + none_stat_compr_blocks++; + none_stat_compr_size += *datalen; + }else { + *cpage_out = output_buf; + }return ret; }int jffs2_decompress (struct jffs2_sb_info *c,struct jffs2_inode_info *f, -uint16_t comprtype,unsigned char *cdata_in, +uint16_t comprtype,unsigned char *cdata_in,unsigned char *data_out,uint32_t cdatalen,uint32_t datalen) { -struct jffs2_compressor *this; -int ret; +struct jffs2_compressor *this; +int ret;/* Older code had a bug where it would write non-zero 'usercompr' fields. Deal with it. */
@@ -185,26 +184,25 @@memset (data_out,0 , datalen);break ;default : -spin_lock (&jffs2_compressor_list_lock); -list_for_each_entry (this, &jffs2_compressor_list, list) { -if (comprtype == this->compr) { - this->usecount++; -spin_unlock (&jffs2_compressor_list_lock); - ret = this->decompress (cdata_in, data_out, cdatalen, datalen,NULL ); -spin_lock (&jffs2_compressor_list_lock); -if (ret) { -printk (KERN_WARNING "Decompressor \"%s\" returned %d\n" , this->name, ret); - } -else { - this->stat_decompr_blocks++; - } - this->usecount--; -spin_unlock (&jffs2_compressor_list_lock); -return ret; - } - } +spin_lock (&jffs2_compressor_list_lock); +list_for_each_entry (this, &jffs2_compressor_list, list) { +if (comprtype == this->compr) { + this->usecount++; +spin_unlock (&jffs2_compressor_list_lock); + ret = this->decompress (cdata_in, data_out, cdatalen, datalen,NULL ); +spin_lock (&jffs2_compressor_list_lock); +if (ret) { +printk (KERN_WARNING "Decompressor \"%s\" returned %d\n" , this->name, ret); + }else { + this->stat_decompr_blocks++; + } + this->usecount--; +spin_unlock (&jffs2_compressor_list_lock); +return ret; + } + }printk (KERN_WARNING "JFFS2 compression type 0x%02x not available.\n" , comprtype); -spin_unlock (&jffs2_compressor_list_lock); +spin_unlock (&jffs2_compressor_list_lock);return -EIO ; }return 0 ;
@@ -212,60 +210,60 @@int jffs2_register_compressor (struct jffs2_compressor *comp) { -struct jffs2_compressor *this; +struct jffs2_compressor *this; -if (!comp->name) { -printk (KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n" ); -return -1 ; - } - comp->compr_buf_size=0 ; - comp->compr_buf=NULL ; - comp->usecount=0 ; - comp->stat_compr_orig_size=0 ; - comp->stat_compr_new_size=0 ; - comp->stat_compr_blocks=0 ; - comp->stat_decompr_blocks=0 ; -D1 (printk (KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n" , comp->name)); - -spin_lock (&jffs2_compressor_list_lock); - -list_for_each_entry (this, &jffs2_compressor_list, list) { -if (this->priority < comp->priority) { -list_add (&comp->list, this->list.prev); - goto out; - } - } -list_add_tail (&comp->list, &jffs2_compressor_list); +if (!comp->name) { +printk (KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n" ); +return -1 ; + } + comp->compr_buf_size =0 ; + comp->compr_buf =NULL ; + comp->usecount =0 ; + comp->stat_compr_orig_size =0 ; + comp->stat_compr_new_size =0 ; + comp->stat_compr_blocks =0 ; + comp->stat_decompr_blocks =0 ; +D1 (printk (KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n" , comp->name)); + +spin_lock (&jffs2_compressor_list_lock); + +list_for_each_entry (this, &jffs2_compressor_list, list) { +if (this->priority < comp->priority) { +list_add (&comp->list, this->list.prev); + goto out; + } + } +list_add_tail (&comp->list, &jffs2_compressor_list); out: - D2(list_for_each_entry(this, &jffs2_compressor_list, list) { -printk (KERN_DEBUG "Compressor \"%s\", prio %d\n" , this->name, this->priority); - }) + D2(list_for_each_entry(this, &jffs2_compressor_list, list) { +printk (KERN_DEBUG "Compressor \"%s\", prio %d\n" , this->name, this->priority); + }) -spin_unlock (&jffs2_compressor_list_lock); +spin_unlock (&jffs2_compressor_list_lock); -return 0 ; +return 0 ; }int jffs2_unregister_compressor (struct jffs2_compressor *comp) { - D2(struct jffs2_compressor *this;) + D2(struct jffs2_compressor *this;) -D1 (printk (KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n" , comp->name)); +D1 (printk (KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n" , comp->name)); -spin_lock (&jffs2_compressor_list_lock); +spin_lock (&jffs2_compressor_list_lock); + +if (comp->usecount) { +spin_unlock (&jffs2_compressor_list_lock); +printk (KERN_WARNING "JFFS2: Compressor modul is in use. Unregister failed.\n" ); +return -1 ; + } +list_del (&comp->list); -if (comp->usecount) { -spin_unlock (&jffs2_compressor_list_lock); -printk (KERN_WARNING "JFFS2: Compressor modul is in use. Unregister failed.\n" ); -return -1 ; - } -list_del (&comp->list); - - D2(list_for_each_entry(this, &jffs2_compressor_list, list) { -printk (KERN_DEBUG "Compressor \"%s\", prio %d\n" , this->name, this->priority); - }) -spin_unlock (&jffs2_compressor_list_lock); -return 0 ; + D2(list_for_each_entry(this, &jffs2_compressor_list, list) { +printk (KERN_DEBUG "Compressor \"%s\", prio %d\n" , this->name, this->priority); + }) +spin_unlock (&jffs2_compressor_list_lock); +return 0 ; }#ifdef CONFIG_JFFS2_PROC
@@ -274,184 +272,184 @@char *jffs2_list_compressors (void ) { -struct jffs2_compressor *this; -char *buf, *act_buf; +struct jffs2_compressor *this; +char *buf, *act_buf; - act_buf = buf =kmalloc (JFFS2_STAT_BUF_SIZE ,GFP_KERNEL ); -list_for_each_entry (this, &jffs2_compressor_list, list) { - act_buf +=sprintf (act_buf,"%10s priority:%d " , this->name, this->priority); -if ((this->disabled)||(!this->compress)) - act_buf +=sprintf (act_buf,"disabled" ); -else - act_buf +=sprintf (act_buf,"enabled" ); - act_buf +=sprintf (act_buf,"\n" ); - } -return buf; + act_buf = buf =kmalloc (JFFS2_STAT_BUF_SIZE ,GFP_KERNEL ); +list_for_each_entry (this, &jffs2_compressor_list, list) { + act_buf +=sprintf (act_buf,"%10s priority:%d " , this->name, this->priority); +if ((this->disabled)||(!this->compress)) + act_buf +=sprintf (act_buf,"disabled" ); +else + act_buf +=sprintf (act_buf,"enabled" ); + act_buf +=sprintf (act_buf,"\n" ); + } +return buf; }char *jffs2_stats (void ) { -struct jffs2_compressor *this; -char *buf, *act_buf; +struct jffs2_compressor *this; +char *buf, *act_buf; + + act_buf = buf =kmalloc (JFFS2_STAT_BUF_SIZE ,GFP_KERNEL ); + + act_buf +=sprintf (act_buf,"JFFS2 compressor statistics:\n" ); + act_buf +=sprintf (act_buf,"%10s " ,"none" ); + act_buf +=sprintf (act_buf,"compr: %d blocks (%d) decompr: %d blocks\n" , none_stat_compr_blocks, + none_stat_compr_size, none_stat_decompr_blocks); +spin_lock (&jffs2_compressor_list_lock); +list_for_each_entry (this, &jffs2_compressor_list, list) { + act_buf +=sprintf (act_buf,"%10s " , this->name); +if ((this->disabled)||(!this->compress)) + act_buf +=sprintf (act_buf,"- " ); +else + act_buf +=sprintf (act_buf,"+ " ); + act_buf +=sprintf (act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks " , this->stat_compr_blocks, + this->stat_compr_new_size, this->stat_compr_orig_size, + this->stat_decompr_blocks); + act_buf +=sprintf (act_buf,"\n" ); + } +spin_unlock (&jffs2_compressor_list_lock); + +return buf; +} - act_buf = buf =kmalloc (JFFS2_STAT_BUF_SIZE ,GFP_KERNEL ); +char *jffs2_get_compression_mode_name (void ) +{ +switch (jffs2_compression_mode) { +case JFFS2_COMPR_MODE_NONE : +return "none" ; +case JFFS2_COMPR_MODE_PRIORITY : +return "priority" ; +case JFFS2_COMPR_MODE_SIZE : +return "size" ; + } +return "unkown" ; +} - act_buf +=sprintf (act_buf,"JFFS2 compressor statistics:\n" ); - act_buf +=sprintf (act_buf,"%10s " ,"none" ); - act_buf +=sprintf (act_buf,"compr: %d blocks (%d) decompr: %d blocks\n" , none_stat_compr_blocks, - none_stat_compr_size, none_stat_decompr_blocks); -spin_lock (&jffs2_compressor_list_lock); -list_for_each_entry (this, &jffs2_compressor_list, list) { - act_buf +=sprintf (act_buf,"%10s " ,this->name); -if ((this->disabled)||(!this->compress)) - act_buf +=sprintf (act_buf,"- " ); -else - act_buf +=sprintf (act_buf,"+ " ); - act_buf +=sprintf (act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks " , this->stat_compr_blocks, - this->stat_compr_new_size, this->stat_compr_orig_size, - this->stat_decompr_blocks); - act_buf +=sprintf (act_buf,"\n" ); - } -spin_unlock (&jffs2_compressor_list_lock); - -return buf; -} - -char *jffs2_get_compression_mode_name (void ) -{ -switch (jffs2_compression_mode) { -case JFFS2_COMPR_MODE_NONE : -return "none" ; -case JFFS2_COMPR_MODE_PRIORITY : -return "priority" ; -case JFFS2_COMPR_MODE_SIZE : -return "size" ; - } -return "unkown" ; -} - -int jffs2_set_compression_mode_name (const char *name) -{ -if (!strcmp ("none" ,name)) { - jffs2_compression_mode =JFFS2_COMPR_MODE_NONE ; -return 0 ; - } -if (!strcmp ("priority" ,name)) { - jffs2_compression_mode =JFFS2_COMPR_MODE_PRIORITY ; -return 0 ; - } -if (!strcmp ("size" ,name)) { - jffs2_compression_mode =JFFS2_COMPR_MODE_SIZE ; -return 0 ; - } -return 1 ; +int jffs2_set_compression_mode_name (const char *name) +{ +if (!strcmp ("none" , name)) { + jffs2_compression_mode =JFFS2_COMPR_MODE_NONE ; +return 0 ; + } +if (!strcmp ("priority" , name)) { + jffs2_compression_mode =JFFS2_COMPR_MODE_PRIORITY ; +return 0 ; + } +if (!strcmp ("size" , name)) { + jffs2_compression_mode =JFFS2_COMPR_MODE_SIZE ; +return 0 ; + } +return 1 ; }static int jffs2_compressor_Xable (const char *name,int disabled) { -struct jffs2_compressor *this; -spin_lock (&jffs2_compressor_list_lock); -list_for_each_entry (this, &jffs2_compressor_list, list) { -if (!strcmp (this->name, name)) { - this->disabled = disabled; -spin_unlock (&jffs2_compressor_list_lock); -return 0 ; - } - } -spin_unlock (&jffs2_compressor_list_lock); -printk (KERN_WARNING "JFFS2: compressor %s not found.\n" ,name); -return 1 ; +struct jffs2_compressor *this; +spin_lock (&jffs2_compressor_list_lock); +list_for_each_entry (this, &jffs2_compressor_list, list) { +if (!strcmp (this->name, name)) { + this->disabled = disabled; +spin_unlock (&jffs2_compressor_list_lock); +return 0 ; + } + } +spin_unlock (&jffs2_compressor_list_lock); +printk (KERN_WARNING "JFFS2: compressor %s not found.\n" , name); +return 1 ; }int jffs2_enable_compressor_name (const char *name) { -return jffs2_compressor_Xable (name,0 ); +return jffs2_compressor_Xable (name,0 ); }int jffs2_disable_compressor_name (const char *name) { -return jffs2_compressor_Xable (name,1 ); +return jffs2_compressor_Xable (name,1 ); }int jffs2_set_compressor_priority (const char *name,int priority) { -struct jffs2_compressor *this,*comp; -spin_lock (&jffs2_compressor_list_lock); -list_for_each_entry (this, &jffs2_compressor_list, list) { -if (!strcmp (this->name, name)) { - this->priority = priority; - comp = this; - goto reinsert; - } - } -spin_unlock (&jffs2_compressor_list_lock); -printk (KERN_WARNING "JFFS2: compressor %s not found.\n" ,name); -return 1 ; +struct jffs2_compressor *this, *comp; +spin_lock (&jffs2_compressor_list_lock); +list_for_each_entry (this, &jffs2_compressor_list, list) { +if (!strcmp (this->name, name)) { + this->priority = priority; + comp = this; + goto reinsert; + } + } +spin_unlock (&jffs2_compressor_list_lock); +printk (KERN_WARNING "JFFS2: compressor %s not found.\n" , name); +return 1 ; reinsert: -/* list is sorted in the order of priority, so if -we change it we have to reinsert it into the -good place */ -list_del (&comp->list); -list_for_each_entry (this, &jffs2_compressor_list, list) { -if (this->priority < comp->priority) { -list_add (&comp->list, this->list.prev); -spin_unlock (&jffs2_compressor_list_lock); -return 0 ; - } - } -list_add_tail (&comp->list, &jffs2_compressor_list); -spin_unlock (&jffs2_compressor_list_lock); -return 0 ; +/* list is sorted in the order of priority, so if +we change it we have to reinsert it into the +good place */ +list_del (&comp->list); +list_for_each_entry (this, &jffs2_compressor_list, list) { +if (this->priority < comp->priority) { +list_add (&comp->list, this->list.prev); +spin_unlock (&jffs2_compressor_list_lock); +return 0 ; + } + } +list_add_tail (&comp->list, &jffs2_compressor_list); +spin_unlock (&jffs2_compressor_list_lock); +return 0 ; }#endif void jffs2_free_comprbuf (unsigned char *comprbuf,unsigned char *orig) { -if (orig != comprbuf) -kfree (comprbuf); +if (orig != comprbuf) +kfree (comprbuf); } -int jffs2_compressors_init (void ) +int jffs2_compressors_init (void ) {/* Registering compressors */ #ifdef CONFIG_JFFS2_ZLIB -jffs2_zlib_init (); +jffs2_zlib_init ();#endif #ifdef CONFIG_JFFS2_RTIME -jffs2_rtime_init (); +jffs2_rtime_init ();#endif #ifdef CONFIG_JFFS2_RUBIN -jffs2_rubinmips_init (); -jffs2_dynrubin_init (); +jffs2_rubinmips_init (); +jffs2_dynrubin_init ();#endif /* Setting default compression mode */ #ifdef CONFIG_JFFS2_CMODE_NONE - jffs2_compression_mode =JFFS2_COMPR_MODE_NONE ; - D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");) + jffs2_compression_mode =JFFS2_COMPR_MODE_NONE ; + D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");)#else #ifdef CONFIG_JFFS2_CMODE_SIZE - jffs2_compression_mode =JFFS2_COMPR_MODE_SIZE ; - D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");) + jffs2_compression_mode =JFFS2_COMPR_MODE_SIZE ; + D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");)#else - D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");) + D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");)#endif #endif -return 0 ; +return 0 ; } -int jffs2_compressors_exit (void ) +int jffs2_compressors_exit (void ) {/* Unregistering compressors */ #ifdef CONFIG_JFFS2_RUBIN -jffs2_dynrubin_exit (); -jffs2_rubinmips_exit (); +jffs2_dynrubin_exit (); +jffs2_rubinmips_exit ();#endif #ifdef CONFIG_JFFS2_RTIME -jffs2_rtime_exit (); +jffs2_rtime_exit ();#endif #ifdef CONFIG_JFFS2_ZLIB -jffs2_zlib_exit (); +jffs2_zlib_exit ();#endif -return 0 ; +return 0 ; }
fs/jffs2/compr.h +21 -21
62 lines not on this page · raw message
fs/jffs2/compr_rtime.c +35 -36
134 lines not on this page · raw message
fs/jffs2/compr_rubin.c +54 -59
285 lines not on this page · raw message
fs/jffs2/compr_rubin.h +4 -4
@@ -6,13 +6,13 @@#include "pushpull.h" #define RUBIN_REG_SIZE 16 -#define UPPER_BIT_RUBIN (((long) 1)<<(RUBIN_REG_SIZE-1)) -#define LOWER_BITS_RUBIN ((((long) 1)<<(RUBIN_REG_SIZE-1))-1) +#define UPPER_BIT_RUBIN (((long) 1) << (RUBIN_REG_SIZE - 1)) +#define LOWER_BITS_RUBIN ((((long) 1) << (RUBIN_REG_SIZE - 1)) - 1)struct rubin_state { -unsigned long p; -unsigned long q; +unsigned long p; +unsigned long q;unsigned long rec_q;long bit_number;struct pushpull pp;
fs/jffs2/comprtest.c +16 -15
@@ -265,21 +265,22 @@static unsigned char comprbuf[TESTDATA_LEN ];static unsigned char decomprbuf[TESTDATA_LEN ]; -int jffs2_decompress (unsigned char comprtype,unsigned char *cdata_in, +int jffs2_decompress (unsigned char comprtype,unsigned char *cdata_in,unsigned char *data_out,uint32_t cdatalen,uint32_t datalen); -unsigned char jffs2_compress (unsigned char *data_in,unsigned char *cpage_out, + +unsigned char jffs2_compress (unsigned char *data_in,unsigned char *cpage_out,uint32_t *datalen,uint32_t *cdatalen); -int init_module (void ) { +int init_module (void ) {unsigned char comprtype;uint32_t c, d;int ret;printk ("Original data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n" , - testdata[0 ],testdata[1 ],testdata[2 ],testdata[3 ], - testdata[4 ],testdata[5 ],testdata[6 ],testdata[7 ], - testdata[8 ],testdata[9 ],testdata[10 ],testdata[11 ], - testdata[12 ],testdata[13 ],testdata[14 ],testdata[15 ]); + testdata[0 ], testdata[1 ], testdata[2 ], testdata[3 ], + testdata[4 ], testdata[5 ], testdata[6 ], testdata[7 ], + testdata[8 ], testdata[9 ], testdata[10 ], testdata[11 ], + testdata[12 ], testdata[13 ], testdata[14 ], testdata[15 ]); d =TESTDATA_LEN ; c =TESTDATA_LEN ; comprtype =jffs2_compress (testdata, comprbuf, &d, &c);
@@ -287,18 +288,18 @@printk ("jffs2_compress used compression type %d. Compressed size %d, uncompressed size %d\n" , comprtype, c, d);printk ("Compressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n" , - comprbuf[0 ],comprbuf[1 ],comprbuf[2 ],comprbuf[3 ], - comprbuf[4 ],comprbuf[5 ],comprbuf[6 ],comprbuf[7 ], - comprbuf[8 ],comprbuf[9 ],comprbuf[10 ],comprbuf[11 ], - comprbuf[12 ],comprbuf[13 ],comprbuf[14 ],comprbuf[15 ]); + comprbuf[0 ], comprbuf[1 ], comprbuf[2 ], comprbuf[3 ], + comprbuf[4 ], comprbuf[5 ], comprbuf[6 ], comprbuf[7 ], + comprbuf[8 ], comprbuf[9 ], comprbuf[10 ], comprbuf[11 ], + comprbuf[12 ], comprbuf[13 ], comprbuf[14 ], comprbuf[15 ]); ret =jffs2_decompress (comprtype, comprbuf, decomprbuf, c, d);printk ("jffs2_decompress returned %d\n" , ret);printk ("Decompressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n" , - decomprbuf[0 ],decomprbuf[1 ],decomprbuf[2 ],decomprbuf[3 ], - decomprbuf[4 ],decomprbuf[5 ],decomprbuf[6 ],decomprbuf[7 ], - decomprbuf[8 ],decomprbuf[9 ],decomprbuf[10 ],decomprbuf[11 ], - decomprbuf[12 ],decomprbuf[13 ],decomprbuf[14 ],decomprbuf[15 ]); + decomprbuf[0 ], decomprbuf[1 ], decomprbuf[2 ], decomprbuf[3 ], + decomprbuf[4 ], decomprbuf[5 ], decomprbuf[6 ], decomprbuf[7 ], + decomprbuf[8 ], decomprbuf[9 ], decomprbuf[10 ], decomprbuf[11 ], + decomprbuf[12 ], decomprbuf[13 ], decomprbuf[14 ], decomprbuf[15 ]);if (memcmp (decomprbuf, testdata, d))printk ("Compression and decompression corrupted data\n" );else
fs/jffs2/compr_zlib.c +29 -29
121 lines not on this page · raw message
Quoted 7 lines · Peter Grayson
On Mon, 2005-09-26 at 13:01 +0200, Jörn Engel wrote:
I agree that other patches are more important than code formatting. However, we may also enable more people to contribute to jffs2 if the code is as readable/understandable as possible. I want to help make a small, but tangible step in that direction.
Quoted 6 lines
Since there appears to be at least some benefit, maybe we can do this in easy to digest pieces. I have made another patch just against the files concerning compression in jffs2. These files had a lot of problems and I do not believe they conflict with any of the main outstanding patches (ebh, xattr, centsum).
Wait a bit, I gonna just try those patches and check if there are actually any big problem if they are applied above your patch.
Signature · 3 lines
Best Regards, Artem B. Bityuckiy, St.-Petersburg, Russia.
Quoted 8 lines · Peter Grayson
Quoted 6 lines · Jörn Engel
Quoted 5 lines · Artem B. Bityutskiy
Quoted 4 lines · Jörn Engel
Because we want things like ebh, summary, xattr, etc.? If we accept this patch, it makes life a bit worse for people who write the stuff we want. It may be the straw that makes them go away and never come back.
Quoted 4 lines
I agree that other patches are more important than code formatting. However, we may also enable more people to contribute to jffs2 if the code is as readable/understandable as possible. I want to help make a small, but tangible step in that direction.
Thank you for that effort.
Quoted 8 lines
Quoted 2 lines
Imo, the costs outweigh the benefit. [ Which doesn't mean that I question the benefit. It's just not big enough. ]
Since there appears to be at least some benefit, maybe we can do this in easy to digest pieces. I have made another patch just against the files concerning compression in jffs2. These files had a lot of problems and I do not believe they conflict with any of the main outstanding patches (ebh, xattr, centsum).
That patch I would gladly take. Someone should quickly review it for correctness (not me, sorry :-P).
The easiest way for review, I guess, would be to compile before and after your patch. If the binaries are identical (module timestamps, so take objdump -D output or such), nothing dangerous slipped in.
And yes, for compression the benefits greatly outweigh the costs. Quite an improvement.
Jörn
Signature · 4 lines
The story so far: In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move. -- Douglas Adams
Well, Joern is right, there are some problems with patches...
And people are asking to postpone your fix and do it after JFFS2 will be synched with Linus's tree. Could you come up with it later please?
Signature · 3 lines
Best Regards, Artem B. Bityuckiy, St.-Petersburg, Russia.
Quoted 5 lines · Artem B. Bityutskiy
Well, Joern is right, there are some problems with patches...
And people are asking to postpone your fix and do it after JFFS2 will be synched with Linus's tree. Could you come up with it later please?
I guess we can merge an unchanged patch then - after all, we want to quiet down for a while. ;)
Jörn
Signature · 4 lines
More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. -- W. A. Wulf
Quoted 1 line · Artem B. Bityutskiy
Well, Joern is right, there are some problems with patches...
That's too bad.
Quoted 2 lines
And people are asking to postpone your fix and do it after JFFS2 will be synched with Linus's tree. Could you come up with it later please?
Yes. I will wait until it looks like things have settled down, or until someone asks me to do it; whichever comes first.
Pete