Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[JFFS2] Clean up trailing white spaces

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Thomas Gleixner and committed by
Thomas Gleixner
182ec4ee 97894cda

+604 -605
+5 -5
fs/Kconfig
··· 1084 1084 default y 1085 1085 help 1086 1086 Zlib is designed to be a free, general-purpose, legally unencumbered, 1087 - lossless data-compression library for use on virtually any computer 1087 + lossless data-compression library for use on virtually any computer 1088 1088 hardware and operating system. See <http://www.gzip.org/zlib/> for 1089 1089 further information. 1090 - 1090 + 1091 1091 Say 'Y' if unsure. 1092 1092 1093 1093 config JFFS2_RTIME ··· 1109 1109 default JFFS2_CMODE_PRIORITY 1110 1110 depends on JFFS2_FS 1111 1111 help 1112 - You can set here the default compression mode of JFFS2 from 1112 + You can set here the default compression mode of JFFS2 from 1113 1113 the available compression modes. Don't touch if unsure. 1114 1114 1115 1115 config JFFS2_CMODE_NONE ··· 1120 1120 config JFFS2_CMODE_PRIORITY 1121 1121 bool "priority" 1122 1122 help 1123 - Tries the compressors in a predefinied order and chooses the first 1123 + Tries the compressors in a predefinied order and chooses the first 1124 1124 successful one. 1125 1125 1126 1126 config JFFS2_CMODE_SIZE 1127 1127 bool "size (EXPERIMENTAL)" 1128 1128 help 1129 - Tries all compressors and chooses the one which has the smallest 1129 + Tries all compressors and chooses the one which has the smallest 1130 1130 result. 1131 1131 1132 1132 endchoice
+2 -2
fs/jffs2/background.c
··· 51 51 D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", pid)); 52 52 wait_for_completion(&c->gc_thread_start); 53 53 } 54 - 54 + 55 55 return ret; 56 56 } 57 57 ··· 101 101 102 102 cond_resched(); 103 103 104 - /* Put_super will send a SIGKILL and then wait on the sem. 104 + /* Put_super will send a SIGKILL and then wait on the sem. 105 105 */ 106 106 while (signal_pending(current)) { 107 107 siginfo_t info;
+14 -14
fs/jffs2/build.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: build.c,v 1.84 2005/09/27 13:40:49 dedekind Exp $ 10 + * $Id: build.c,v 1.85 2005/11/07 11:14:38 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 129 129 for_each_inode(i, c, ic) { 130 130 if (ic->nlink) 131 131 continue; 132 - 132 + 133 133 jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); 134 134 cond_resched(); 135 - } 135 + } 136 136 137 137 dbg_fsbuild("pass 2a starting\n"); 138 138 ··· 149 149 150 150 dbg_fsbuild("pass 2a complete\n"); 151 151 dbg_fsbuild("freeing temporary data structures\n"); 152 - 152 + 153 153 /* Finally, we can scan again and free the dirent structs */ 154 154 for_each_inode(i, c, ic) { 155 155 while(ic->scan_dents) { ··· 161 161 cond_resched(); 162 162 } 163 163 c->flags &= ~JFFS2_SB_FLAG_BUILDING; 164 - 164 + 165 165 dbg_fsbuild("FS build complete\n"); 166 166 167 167 /* Rotate the lists by some number to ensure wear levelling */ ··· 191 191 struct jffs2_full_dirent *fd; 192 192 193 193 dbg_fsbuild("removing ino #%u with nlink == zero.\n", ic->ino); 194 - 194 + 195 195 raw = ic->nodes; 196 196 while (raw != (void *)ic) { 197 197 struct jffs2_raw_node_ref *next = raw->next_in_ino; ··· 220 220 whinged = 1; 221 221 222 222 dbg_fsbuild("removing child \"%s\", ino #%u\n", fd->name, fd->ino); 223 - 223 + 224 224 child_ic = jffs2_get_ino_cache(c, fd->ino); 225 225 if (!child_ic) { 226 226 dbg_fsbuild("cannot remove child \"%s\", ino #%u, because it doesn't exist\n", ··· 229 229 continue; 230 230 } 231 231 232 - /* Reduce nlink of the child. If it's now zero, stick it on the 232 + /* Reduce nlink of the child. If it's now zero, stick it on the 233 233 dead_fds list to be cleaned up later. Else just free the fd */ 234 234 235 235 child_ic->nlink--; 236 - 236 + 237 237 if (!child_ic->nlink) { 238 238 dbg_fsbuild("inode #%u (\"%s\") has now got zero nlink, adding to dead_fds list.\n", 239 239 fd->ino, fd->name); ··· 248 248 } 249 249 250 250 /* 251 - We don't delete the inocache from the hash list and free it yet. 251 + We don't delete the inocache from the hash list and free it yet. 252 252 The erase code will do that, when all the nodes are completely gone. 253 253 */ 254 254 } ··· 262 262 because there's not enough free space... */ 263 263 c->resv_blocks_deletion = 2; 264 264 265 - /* Be conservative about how much space we need before we allow writes. 265 + /* Be conservative about how much space we need before we allow writes. 266 266 On top of that which is required for deletia, require an extra 2% 267 267 of the medium to be available, for overhead caused by nodes being 268 268 split across blocks, etc. */ ··· 277 277 278 278 c->resv_blocks_gctrigger = c->resv_blocks_write + 1; 279 279 280 - /* When do we allow garbage collection to merge nodes to make 280 + /* When do we allow garbage collection to merge nodes to make 281 281 long-term progress at the expense of short-term space exhaustion? */ 282 282 c->resv_blocks_gcmerge = c->resv_blocks_deletion + 1; 283 283 ··· 303 303 c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024); 304 304 dbg_fsbuild("Amount of dirty space required to GC: %d bytes\n", 305 305 c->nospc_dirty_size); 306 - } 306 + } 307 307 308 308 int jffs2_do_mount_fs(struct jffs2_sb_info *c) 309 309 { ··· 355 355 #ifndef __ECOS 356 356 if (jffs2_blocks_use_vmalloc(c)) 357 357 vfree(c->blocks); 358 - else 358 + else 359 359 #endif 360 360 kfree(c->blocks); 361 361
+14 -14
fs/jffs2/compr.c
··· 9 9 * 10 10 * For licensing information, see the file 'LICENCE' in this directory. 11 11 * 12 - * $Id: compr.c,v 1.45 2005/07/26 13:24:40 havasi Exp $ 12 + * $Id: compr.c,v 1.46 2005/11/07 11:14:38 gleixner Exp $ 13 13 * 14 14 */ 15 15 ··· 36 36 * data. 37 37 * 38 38 * Returns: Lower byte to be stored with data indicating compression type used. 39 - * Zero is used to show that the data could not be compressed - the 39 + * Zero is used to show that the data could not be compressed - the 40 40 * compressed version was actually larger than the original. 41 41 * Upper byte will be used later. (soon) 42 42 * 43 43 * If the cdata buffer isn't large enough to hold all the uncompressed data, 44 - * jffs2_compress should compress as much as will fit, and should set 44 + * jffs2_compress should compress as much as will fit, and should set 45 45 * *datalen accordingly to show the amount of data which were compressed. 46 46 */ 47 47 uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 48 - unsigned char *data_in, unsigned char **cpage_out, 48 + unsigned char *data_in, unsigned char **cpage_out, 49 49 uint32_t *datalen, uint32_t *cdatalen) 50 50 { 51 51 int ret = JFFS2_COMPR_NONE; ··· 164 164 } 165 165 166 166 int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 167 - uint16_t comprtype, unsigned char *cdata_in, 167 + uint16_t comprtype, unsigned char *cdata_in, 168 168 unsigned char *data_out, uint32_t cdatalen, uint32_t datalen) 169 169 { 170 170 struct jffs2_compressor *this; ··· 298 298 299 299 act_buf += sprintf(act_buf,"JFFS2 compressor statistics:\n"); 300 300 act_buf += sprintf(act_buf,"%10s ","none"); 301 - act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks, 301 + act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks, 302 302 none_stat_compr_size, none_stat_decompr_blocks); 303 303 spin_lock(&jffs2_compressor_list_lock); 304 304 list_for_each_entry(this, &jffs2_compressor_list, list) { ··· 307 307 act_buf += sprintf(act_buf,"- "); 308 308 else 309 309 act_buf += sprintf(act_buf,"+ "); 310 - act_buf += sprintf(act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks ", this->stat_compr_blocks, 311 - this->stat_compr_new_size, this->stat_compr_orig_size, 310 + act_buf += sprintf(act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks ", this->stat_compr_blocks, 311 + this->stat_compr_new_size, this->stat_compr_orig_size, 312 312 this->stat_decompr_blocks); 313 313 act_buf += sprintf(act_buf,"\n"); 314 314 } ··· 317 317 return buf; 318 318 } 319 319 320 - char *jffs2_get_compression_mode_name(void) 320 + char *jffs2_get_compression_mode_name(void) 321 321 { 322 322 switch (jffs2_compression_mode) { 323 323 case JFFS2_COMPR_MODE_NONE: ··· 330 330 return "unkown"; 331 331 } 332 332 333 - int jffs2_set_compression_mode_name(const char *name) 333 + int jffs2_set_compression_mode_name(const char *name) 334 334 { 335 335 if (!strcmp("none",name)) { 336 336 jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; ··· 355 355 if (!strcmp(this->name, name)) { 356 356 this->disabled = disabled; 357 357 spin_unlock(&jffs2_compressor_list_lock); 358 - return 0; 358 + return 0; 359 359 } 360 360 } 361 361 spin_unlock(&jffs2_compressor_list_lock); ··· 385 385 } 386 386 } 387 387 spin_unlock(&jffs2_compressor_list_lock); 388 - printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name); 388 + printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name); 389 389 return 1; 390 390 reinsert: 391 391 /* list is sorted in the order of priority, so if ··· 412 412 kfree(comprbuf); 413 413 } 414 414 415 - int jffs2_compressors_init(void) 415 + int jffs2_compressors_init(void) 416 416 { 417 417 /* Registering compressors */ 418 418 #ifdef CONFIG_JFFS2_ZLIB ··· 440 440 return 0; 441 441 } 442 442 443 - int jffs2_compressors_exit(void) 443 + int jffs2_compressors_exit(void) 444 444 { 445 445 /* Unregistering compressors */ 446 446 #ifdef CONFIG_JFFS2_RUBIN
+2 -2
fs/jffs2/compr.h
··· 4 4 * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, 5 5 * University of Szeged, Hungary 6 6 * 7 - * For licensing information, see the file 'LICENCE' in the 7 + * For licensing information, see the file 'LICENCE' in the 8 8 * jffs2 directory. 9 9 * 10 - * $Id: compr.h,v 1.8 2005/07/26 13:24:40 havasi Exp $ 10 + * $Id: compr.h,v 1.9 2005/11/07 11:14:38 gleixner Exp $ 11 11 * 12 12 */ 13 13
+16 -16
fs/jffs2/compr_rtime.c
··· 24 24 #include <linux/kernel.h> 25 25 #include <linux/types.h> 26 26 #include <linux/errno.h> 27 - #include <linux/string.h> 28 - #include <linux/jffs2.h> 27 + #include <linux/string.h> 28 + #include <linux/jffs2.h> 29 29 #include "compr.h" 30 30 31 31 /* _compress returns the compressed size, -1 if bigger */ ··· 38 38 int outpos = 0; 39 39 int pos=0; 40 40 41 - memset(positions,0,sizeof(positions)); 42 - 41 + memset(positions,0,sizeof(positions)); 42 + 43 43 while (pos < (*sourcelen) && outpos <= (*dstlen)-2) { 44 44 int backpos, runlen=0; 45 45 unsigned char value; 46 - 46 + 47 47 value = data_in[pos]; 48 48 49 49 cpage_out[outpos++] = data_in[pos++]; 50 - 50 + 51 51 backpos = positions[value]; 52 52 positions[value]=pos; 53 - 53 + 54 54 while ((backpos < pos) && (pos < (*sourcelen)) && 55 55 (data_in[pos]==data_in[backpos++]) && (runlen<255)) { 56 56 pos++; ··· 63 63 /* We failed */ 64 64 return -1; 65 65 } 66 - 66 + 67 67 /* Tell the caller how much we managed to compress, and how much space it took */ 68 68 *sourcelen = pos; 69 69 *dstlen = outpos; 70 70 return 0; 71 - } 71 + } 72 72 73 73 74 74 static int jffs2_rtime_decompress(unsigned char *data_in, ··· 79 79 short positions[256]; 80 80 int outpos = 0; 81 81 int pos=0; 82 - 83 - memset(positions,0,sizeof(positions)); 84 - 82 + 83 + memset(positions,0,sizeof(positions)); 84 + 85 85 while (outpos<destlen) { 86 86 unsigned char value; 87 87 int backoffs; 88 88 int repeat; 89 - 89 + 90 90 value = data_in[pos++]; 91 91 cpage_out[outpos++] = value; /* first the verbatim copied byte */ 92 92 repeat = data_in[pos++]; 93 93 backoffs = positions[value]; 94 - 94 + 95 95 positions[value]=outpos; 96 96 if (repeat) { 97 97 if (backoffs + repeat >= outpos) { ··· 101 101 } 102 102 } else { 103 103 memcpy(&cpage_out[outpos],&cpage_out[backoffs],repeat); 104 - outpos+=repeat; 104 + outpos+=repeat; 105 105 } 106 106 } 107 107 } 108 108 return 0; 109 - } 109 + } 110 110 111 111 static struct jffs2_compressor jffs2_rtime_comp = { 112 112 .priority = JFFS2_RTIME_PRIORITY,
+18 -19
fs/jffs2/compr_rubin.c
··· 11 11 * 12 12 */ 13 13 14 - 15 14 #include <linux/string.h> 16 15 #include <linux/types.h> 17 16 #include <linux/jffs2.h> ··· 19 20 #include "compr.h" 20 21 21 22 static void init_rubin(struct rubin_state *rs, int div, int *bits) 22 - { 23 + { 23 24 int c; 24 25 25 26 rs->q = 0; ··· 39 40 40 41 while ((rs->q >= UPPER_BIT_RUBIN) || ((rs->p + rs->q) <= UPPER_BIT_RUBIN)) { 41 42 rs->bit_number++; 42 - 43 + 43 44 ret = pushbit(&rs->pp, (rs->q & UPPER_BIT_RUBIN) ? 1 : 0, 0); 44 45 if (ret) 45 46 return ret; ··· 67 68 68 69 69 70 static void end_rubin(struct rubin_state *rs) 70 - { 71 + { 71 72 72 73 int i; 73 74 ··· 81 82 82 83 static void init_decode(struct rubin_state *rs, int div, int *bits) 83 84 { 84 - init_rubin(rs, div, bits); 85 + init_rubin(rs, div, bits); 85 86 86 87 /* behalve lower */ 87 88 rs->rec_q = 0; ··· 187 188 188 189 189 190 190 - static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in, 191 + static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in, 191 192 unsigned char *cpage_out, uint32_t *sourcelen, uint32_t *dstlen) 192 193 { 193 194 int outpos = 0; ··· 197 198 init_pushpull(&rs.pp, cpage_out, *dstlen * 8, 0, 32); 198 199 199 200 init_rubin(&rs, bit_divider, bits); 200 - 201 + 201 202 while (pos < (*sourcelen) && !out_byte(&rs, data_in[pos])) 202 203 pos++; 203 - 204 + 204 205 end_rubin(&rs); 205 206 206 207 if (outpos > pos) { 207 208 /* We failed */ 208 209 return -1; 209 210 } 210 - 211 - /* Tell the caller how much we managed to compress, 211 + 212 + /* Tell the caller how much we managed to compress, 212 213 * and how much space it took */ 213 - 214 + 214 215 outpos = (pushedbits(&rs.pp)+7)/8; 215 - 216 + 216 217 if (outpos >= pos) 217 218 return -1; /* We didn't actually compress */ 218 219 *sourcelen = pos; 219 220 *dstlen = outpos; 220 221 return 0; 221 - } 222 + } 222 223 #if 0 223 224 /* _compress returns the compressed size, -1 if bigger */ 224 - int jffs2_rubinmips_compress(unsigned char *data_in, unsigned char *cpage_out, 225 + int jffs2_rubinmips_compress(unsigned char *data_in, unsigned char *cpage_out, 225 226 uint32_t *sourcelen, uint32_t *dstlen, void *model) 226 227 { 227 228 return rubin_do_compress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen); ··· 276 277 } 277 278 278 279 ret = rubin_do_compress(256, bits, data_in, cpage_out+8, &mysrclen, &mydstlen); 279 - if (ret) 280 + if (ret) 280 281 return ret; 281 282 282 283 /* Add back the 8 bytes we took for the probabilities */ ··· 292 293 return 0; 293 294 } 294 295 295 - static void rubin_do_decompress(int bit_divider, int *bits, unsigned char *cdata_in, 296 + static void rubin_do_decompress(int bit_divider, int *bits, unsigned char *cdata_in, 296 297 unsigned char *page_out, uint32_t srclen, uint32_t destlen) 297 298 { 298 299 int outpos = 0; 299 300 struct rubin_state rs; 300 - 301 + 301 302 init_pushpull(&rs.pp, cdata_in, srclen, 0, 0); 302 303 init_decode(&rs, bit_divider, bits); 303 - 304 + 304 305 while (outpos < destlen) { 305 306 page_out[outpos++] = in_byte(&rs); 306 307 } 307 - } 308 + } 308 309 309 310 310 311 static int jffs2_rubinmips_decompress(unsigned char *data_in,
+3 -3
fs/jffs2/compr_rubin.h
··· 1 1 /* Rubin encoder/decoder header */ 2 2 /* work started at : aug 3, 1994 */ 3 3 /* last modification : aug 15, 1994 */ 4 - /* $Id: compr_rubin.h,v 1.6 2002/01/25 01:49:26 dwmw2 Exp $ */ 4 + /* $Id: compr_rubin.h,v 1.7 2005/11/07 11:14:38 gleixner Exp $ */ 5 5 6 6 #include "pushpull.h" 7 7 ··· 11 11 12 12 13 13 struct rubin_state { 14 - unsigned long p; 15 - unsigned long q; 14 + unsigned long p; 15 + unsigned long q; 16 16 unsigned long rec_q; 17 17 long bit_number; 18 18 struct pushpull pp;
+7 -7
fs/jffs2/compr_zlib.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: compr_zlib.c,v 1.31 2005/05/20 19:30:06 gleixner Exp $ 10 + * $Id: compr_zlib.c,v 1.32 2005/11/07 11:14:38 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 24 24 #include "nodelist.h" 25 25 #include "compr.h" 26 26 27 - /* Plan: call deflate() with avail_in == *sourcelen, 28 - avail_out = *dstlen - 12 and flush == Z_FINISH. 27 + /* Plan: call deflate() with avail_in == *sourcelen, 28 + avail_out = *dstlen - 12 and flush == Z_FINISH. 29 29 If it doesn't manage to finish, call it again with 30 30 avail_in == 0 and avail_out set to the remaining 12 31 - bytes for it to clean up. 31 + bytes for it to clean up. 32 32 Q: Is 12 bytes sufficient? 33 33 */ 34 34 #define STREAM_END_SPACE 12 ··· 89 89 90 90 def_strm.next_in = data_in; 91 91 def_strm.total_in = 0; 92 - 92 + 93 93 def_strm.next_out = cpage_out; 94 94 def_strm.total_out = 0; 95 95 ··· 99 99 D1(printk(KERN_DEBUG "calling deflate with avail_in %d, avail_out %d\n", 100 100 def_strm.avail_in, def_strm.avail_out)); 101 101 ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); 102 - D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", 102 + D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", 103 103 def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out)); 104 104 if (ret != Z_OK) { 105 105 D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret)); ··· 150 150 inf_strm.next_in = data_in; 151 151 inf_strm.avail_in = srclen; 152 152 inf_strm.total_in = 0; 153 - 153 + 154 154 inf_strm.next_out = cpage_out; 155 155 inf_strm.avail_out = destlen; 156 156 inf_strm.total_out = 0;
+15 -15
fs/jffs2/comprtest.c
··· 1 - /* $Id: comprtest.c,v 1.5 2002/01/03 15:20:44 dwmw2 Exp $ */ 1 + /* $Id: comprtest.c,v 1.6 2005/11/07 11:14:38 gleixner Exp $ */ 2 2 3 3 #include <linux/kernel.h> 4 4 #include <linux/string.h> ··· 265 265 static unsigned char comprbuf[TESTDATA_LEN]; 266 266 static unsigned char decomprbuf[TESTDATA_LEN]; 267 267 268 - int jffs2_decompress(unsigned char comprtype, unsigned char *cdata_in, 268 + int jffs2_decompress(unsigned char comprtype, unsigned char *cdata_in, 269 269 unsigned char *data_out, uint32_t cdatalen, uint32_t datalen); 270 - unsigned char jffs2_compress(unsigned char *data_in, unsigned char *cpage_out, 270 + unsigned char jffs2_compress(unsigned char *data_in, unsigned char *cpage_out, 271 271 uint32_t *datalen, uint32_t *cdatalen); 272 272 273 273 int init_module(void ) { ··· 276 276 int ret; 277 277 278 278 printk("Original data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 279 - testdata[0],testdata[1],testdata[2],testdata[3], 280 - testdata[4],testdata[5],testdata[6],testdata[7], 281 - testdata[8],testdata[9],testdata[10],testdata[11], 282 - testdata[12],testdata[13],testdata[14],testdata[15]); 279 + testdata[0],testdata[1],testdata[2],testdata[3], 280 + testdata[4],testdata[5],testdata[6],testdata[7], 281 + testdata[8],testdata[9],testdata[10],testdata[11], 282 + testdata[12],testdata[13],testdata[14],testdata[15]); 283 283 d = TESTDATA_LEN; 284 284 c = TESTDATA_LEN; 285 285 comprtype = jffs2_compress(testdata, comprbuf, &d, &c); ··· 287 287 printk("jffs2_compress used compression type %d. Compressed size %d, uncompressed size %d\n", 288 288 comprtype, c, d); 289 289 printk("Compressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 290 - comprbuf[0],comprbuf[1],comprbuf[2],comprbuf[3], 291 - comprbuf[4],comprbuf[5],comprbuf[6],comprbuf[7], 292 - comprbuf[8],comprbuf[9],comprbuf[10],comprbuf[11], 293 - comprbuf[12],comprbuf[13],comprbuf[14],comprbuf[15]); 290 + comprbuf[0],comprbuf[1],comprbuf[2],comprbuf[3], 291 + comprbuf[4],comprbuf[5],comprbuf[6],comprbuf[7], 292 + comprbuf[8],comprbuf[9],comprbuf[10],comprbuf[11], 293 + comprbuf[12],comprbuf[13],comprbuf[14],comprbuf[15]); 294 294 295 295 ret = jffs2_decompress(comprtype, comprbuf, decomprbuf, c, d); 296 296 printk("jffs2_decompress returned %d\n", ret); 297 297 printk("Decompressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 298 - decomprbuf[0],decomprbuf[1],decomprbuf[2],decomprbuf[3], 299 - decomprbuf[4],decomprbuf[5],decomprbuf[6],decomprbuf[7], 300 - decomprbuf[8],decomprbuf[9],decomprbuf[10],decomprbuf[11], 301 - decomprbuf[12],decomprbuf[13],decomprbuf[14],decomprbuf[15]); 298 + decomprbuf[0],decomprbuf[1],decomprbuf[2],decomprbuf[3], 299 + decomprbuf[4],decomprbuf[5],decomprbuf[6],decomprbuf[7], 300 + decomprbuf[8],decomprbuf[9],decomprbuf[10],decomprbuf[11], 301 + decomprbuf[12],decomprbuf[13],decomprbuf[14],decomprbuf[15]); 302 302 if (memcmp(decomprbuf, testdata, d)) 303 303 printk("Compression and decompression corrupted data\n"); 304 304 else
+15 -15
fs/jffs2/debug.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: debug.c,v 1.11 2005/09/21 13:28:35 dedekind Exp $ 10 + * $Id: debug.c,v 1.12 2005/11/07 11:14:39 gleixner Exp $ 11 11 * 12 12 */ 13 13 #include <linux/kernel.h> ··· 67 67 __jffs2_dbg_fragtree_paranoia_check_nolock(f); 68 68 up(&f->sem); 69 69 } 70 - 70 + 71 71 void 72 72 __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f) 73 73 { ··· 165 165 __jffs2_dbg_acct_paranoia_check_nolock(c, jeb); 166 166 spin_unlock(&c->erase_completion_lock); 167 167 } 168 - 168 + 169 169 void 170 170 __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, 171 171 struct jffs2_eraseblock *jeb) ··· 237 237 __jffs2_dbg_dump_jeb_nolock(jeb); 238 238 __jffs2_dbg_dump_block_lists_nolock(c); 239 239 BUG(); 240 - 240 + 241 241 } 242 242 #endif /* JFFS2_DBG_PARANOIA_CHECKS */ 243 243 ··· 321 321 __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c) 322 322 { 323 323 printk(JFFS2_DBG_MSG_PREFIX " dump JFFS2 blocks lists:\n"); 324 - 324 + 325 325 printk(JFFS2_DBG "flash_size: %#08x\n", c->flash_size); 326 326 printk(JFFS2_DBG "used_size: %#08x\n", c->used_size); 327 327 printk(JFFS2_DBG "dirty_size: %#08x\n", c->dirty_size); ··· 577 577 { 578 578 int skip; 579 579 int i; 580 - 580 + 581 581 printk(JFFS2_DBG_MSG_PREFIX " dump from offset %#08x to offset %#08x (%x bytes).\n", 582 582 offs, offs + len, len); 583 583 i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE; 584 584 offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1); 585 - 585 + 586 586 if (skip != 0) 587 587 printk(JFFS2_DBG "%#08x: ", offs); 588 - 588 + 589 589 while (skip--) 590 590 printk(" "); 591 591 ··· 598 598 } 599 599 600 600 printk("%02x ", buf[i]); 601 - 601 + 602 602 i += 1; 603 603 } 604 604 ··· 616 616 size_t retlen; 617 617 uint32_t crc; 618 618 int ret; 619 - 619 + 620 620 printk(JFFS2_DBG_MSG_PREFIX " dump node at offset %#08x.\n", ofs); 621 621 622 622 ret = jffs2_flash_read(c, ofs, len, &retlen, (unsigned char *)&node); ··· 630 630 printk(JFFS2_DBG "nodetype:\t%#04x\n", je16_to_cpu(node.u.nodetype)); 631 631 printk(JFFS2_DBG "totlen:\t%#08x\n", je32_to_cpu(node.u.totlen)); 632 632 printk(JFFS2_DBG "hdr_crc:\t%#08x\n", je32_to_cpu(node.u.hdr_crc)); 633 - 633 + 634 634 crc = crc32(0, &node.u, sizeof(node.u) - 4); 635 635 if (crc != je32_to_cpu(node.u.hdr_crc)) { 636 636 JFFS2_ERROR("wrong common header CRC.\n"); 637 637 return; 638 638 } 639 - 639 + 640 640 if (je16_to_cpu(node.u.magic) != JFFS2_MAGIC_BITMASK && 641 641 je16_to_cpu(node.u.magic) != JFFS2_OLD_MAGIC_BITMASK) 642 642 { ··· 668 668 printk(JFFS2_DBG "data_crc:\t%#08x\n", je32_to_cpu(node.i.data_crc)); 669 669 printk(JFFS2_DBG "node_crc:\t%#08x\n", je32_to_cpu(node.i.node_crc)); 670 670 671 - crc = crc32(0, &node.i, sizeof(node.i) - 8); 671 + crc = crc32(0, &node.i, sizeof(node.i) - 8); 672 672 if (crc != je32_to_cpu(node.i.node_crc)) { 673 673 JFFS2_ERROR("wrong node header CRC.\n"); 674 674 return; ··· 686 686 printk(JFFS2_DBG "type:\t%#02x\n", node.d.type); 687 687 printk(JFFS2_DBG "node_crc:\t%#08x\n", je32_to_cpu(node.d.node_crc)); 688 688 printk(JFFS2_DBG "name_crc:\t%#08x\n", je32_to_cpu(node.d.name_crc)); 689 - 689 + 690 690 node.d.name[node.d.nsize] = '\0'; 691 691 printk(JFFS2_DBG "name:\t\"%s\"\n", node.d.name); 692 692 693 - crc = crc32(0, &node.d, sizeof(node.d) - 8); 693 + crc = crc32(0, &node.d, sizeof(node.d) - 8); 694 694 if (crc != je32_to_cpu(node.d.node_crc)) { 695 695 JFFS2_ERROR("wrong node header CRC.\n"); 696 696 return;
+5 -5
fs/jffs2/debug.h
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: debug.h,v 1.20 2005/10/24 16:22:34 dedekind Exp $ 10 + * $Id: debug.h,v 1.21 2005/11/07 11:14:39 gleixner Exp $ 11 11 * 12 12 */ 13 13 #ifndef _JFFS2_DEBUG_H_ ··· 24 24 #define JFFS2_DBG_PARANOIA_CHECKS 25 25 #define JFFS2_DBG_DUMPS 26 26 27 - /* 27 + /* 28 28 * By defining/undefining the below macros one may select debugging messages 29 29 * fro specific JFFS2 subsystems. 30 30 */ ··· 45 45 /* Sanity checks are supposed to be light-weight and enabled by default */ 46 46 #define JFFS2_DBG_SANITY_CHECKS 47 47 48 - /* 48 + /* 49 49 * Dx() are mainly used for debugging messages, they must go away and be 50 50 * superseded by nicer dbg_xxx() macros... 51 51 */ ··· 91 91 " (%d) %s: " fmt, current->pid, \ 92 92 __FUNCTION__, ##__VA_ARGS__); \ 93 93 } while(0) 94 - 94 + 95 95 #define JFFS2_NOTICE(fmt, ...) \ 96 96 do { \ 97 97 printk(JFFS2_NOTICE_MSG_PREFIX \ ··· 106 106 __FUNCTION__, ##__VA_ARGS__); \ 107 107 } while(0) 108 108 109 - /* 109 + /* 110 110 * We split our debugging messages on several parts, depending on the JFFS2 111 111 * subsystem the message belongs to. 112 112 */
+37 -37
fs/jffs2/dir.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: dir.c,v 1.89 2005/09/07 08:34:54 havasi Exp $ 10 + * $Id: dir.c,v 1.90 2005/11/07 11:14:39 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 64 64 65 65 66 66 /* We keep the dirent list sorted in increasing order of name hash, 67 - and we use the same hash function as the dentries. Makes this 67 + and we use the same hash function as the dentries. Makes this 68 68 nice and simple 69 69 */ 70 70 static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, ··· 85 85 86 86 /* NB: The 2.2 backport will need to explicitly check for '.' and '..' here */ 87 87 for (fd_list = dir_f->dents; fd_list && fd_list->nhash <= target->d_name.hash; fd_list = fd_list->next) { 88 - if (fd_list->nhash == target->d_name.hash && 88 + if (fd_list->nhash == target->d_name.hash && 89 89 (!fd || fd_list->version > fd->version) && 90 90 strlen(fd_list->name) == target->d_name.len && 91 91 !strncmp(fd_list->name, target->d_name.name, target->d_name.len)) { ··· 147 147 curofs++; 148 148 /* First loop: curofs = 2; offset = 2 */ 149 149 if (curofs < offset) { 150 - D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", 150 + D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", 151 151 fd->name, fd->ino, fd->type, curofs, offset)); 152 152 continue; 153 153 } ··· 182 182 ri = jffs2_alloc_raw_inode(); 183 183 if (!ri) 184 184 return -ENOMEM; 185 - 185 + 186 186 c = JFFS2_SB_INFO(dir_i->i_sb); 187 187 188 188 D1(printk(KERN_DEBUG "jffs2_create()\n")); ··· 203 203 f = JFFS2_INODE_INFO(inode); 204 204 dir_f = JFFS2_INODE_INFO(dir_i); 205 205 206 - ret = jffs2_do_create(c, dir_f, f, ri, 206 + ret = jffs2_do_create(c, dir_f, f, ri, 207 207 dentry->d_name.name, dentry->d_name.len); 208 208 209 209 if (ret) { ··· 234 234 int ret; 235 235 uint32_t now = get_seconds(); 236 236 237 - ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, 237 + ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, 238 238 dentry->d_name.len, dead_f, now); 239 239 if (dead_f->inocache) 240 240 dentry->d_inode->i_nlink = dead_f->inocache->nlink; ··· 303 303 304 304 if (!ri) 305 305 return -ENOMEM; 306 - 306 + 307 307 c = JFFS2_SB_INFO(dir_i->i_sb); 308 - 309 - /* Try to reserve enough space for both node and dirent. 310 - * Just the node will do for now, though 308 + 309 + /* Try to reserve enough space for both node and dirent. 310 + * Just the node will do for now, though 311 311 */ 312 312 namelen = dentry->d_name.len; 313 313 ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &phys_ofs, &alloclen, ··· 338 338 ri->compr = JFFS2_COMPR_NONE; 339 339 ri->data_crc = cpu_to_je32(crc32(0, target, targetlen)); 340 340 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 341 - 341 + 342 342 fn = jffs2_write_dnode(c, f, ri, target, targetlen, phys_ofs, ALLOC_NORMAL); 343 343 344 344 jffs2_free_raw_inode(ri); ··· 364 364 memcpy(f->target, target, targetlen + 1); 365 365 D1(printk(KERN_DEBUG "jffs2_symlink: symlink's target '%s' cached\n", (char *)f->target)); 366 366 367 - /* No data here. Only a metadata node, which will be 367 + /* No data here. Only a metadata node, which will be 368 368 obsoleted by the first data write 369 369 */ 370 370 f->metadata = fn; ··· 407 407 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); 408 408 409 409 if (IS_ERR(fd)) { 410 - /* dirent failed to write. Delete the inode normally 410 + /* dirent failed to write. Delete the inode normally 411 411 as if it were the final unlink() */ 412 412 jffs2_complete_reservation(c); 413 413 jffs2_free_raw_dirent(rd); ··· 450 450 ri = jffs2_alloc_raw_inode(); 451 451 if (!ri) 452 452 return -ENOMEM; 453 - 453 + 454 454 c = JFFS2_SB_INFO(dir_i->i_sb); 455 455 456 - /* Try to reserve enough space for both node and dirent. 457 - * Just the node will do for now, though 456 + /* Try to reserve enough space for both node and dirent. 457 + * Just the node will do for now, though 458 458 */ 459 459 namelen = dentry->d_name.len; 460 460 ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL, ··· 482 482 483 483 ri->data_crc = cpu_to_je32(0); 484 484 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 485 - 485 + 486 486 fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, ALLOC_NORMAL); 487 487 488 488 jffs2_free_raw_inode(ri); ··· 494 494 jffs2_clear_inode(inode); 495 495 return PTR_ERR(fn); 496 496 } 497 - /* No data here. Only a metadata node, which will be 497 + /* No data here. Only a metadata node, which will be 498 498 obsoleted by the first data write 499 499 */ 500 500 f->metadata = fn; ··· 508 508 jffs2_clear_inode(inode); 509 509 return ret; 510 510 } 511 - 511 + 512 512 rd = jffs2_alloc_raw_dirent(); 513 513 if (!rd) { 514 514 /* Argh. Now we treat it like a normal delete */ ··· 535 535 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); 536 536 537 537 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); 538 - 538 + 539 539 if (IS_ERR(fd)) { 540 - /* dirent failed to write. Delete the inode normally 540 + /* dirent failed to write. Delete the inode normally 541 541 as if it were the final unlink() */ 542 542 jffs2_complete_reservation(c); 543 543 jffs2_free_raw_dirent(rd); ··· 599 599 ri = jffs2_alloc_raw_inode(); 600 600 if (!ri) 601 601 return -ENOMEM; 602 - 602 + 603 603 c = JFFS2_SB_INFO(dir_i->i_sb); 604 - 604 + 605 605 if (S_ISBLK(mode) || S_ISCHR(mode)) { 606 606 dev = cpu_to_je16(old_encode_dev(rdev)); 607 607 devlen = sizeof(dev); 608 608 } 609 - 610 - /* Try to reserve enough space for both node and dirent. 611 - * Just the node will do for now, though 609 + 610 + /* Try to reserve enough space for both node and dirent. 611 + * Just the node will do for now, though 612 612 */ 613 613 namelen = dentry->d_name.len; 614 614 ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &phys_ofs, &alloclen, ··· 638 638 ri->compr = JFFS2_COMPR_NONE; 639 639 ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen)); 640 640 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 641 - 641 + 642 642 fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, phys_ofs, ALLOC_NORMAL); 643 643 644 644 jffs2_free_raw_inode(ri); ··· 650 650 jffs2_clear_inode(inode); 651 651 return PTR_ERR(fn); 652 652 } 653 - /* No data here. Only a metadata node, which will be 653 + /* No data here. Only a metadata node, which will be 654 654 obsoleted by the first data write 655 655 */ 656 656 f->metadata = fn; ··· 694 694 rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); 695 695 696 696 fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); 697 - 697 + 698 698 if (IS_ERR(fd)) { 699 - /* dirent failed to write. Delete the inode normally 699 + /* dirent failed to write. Delete the inode normally 700 700 as if it were the final unlink() */ 701 701 jffs2_complete_reservation(c); 702 702 jffs2_free_raw_dirent(rd); ··· 730 730 uint8_t type; 731 731 uint32_t now; 732 732 733 - /* The VFS will check for us and prevent trying to rename a 733 + /* The VFS will check for us and prevent trying to rename a 734 734 * file over a directory and vice versa, but if it's a directory, 735 735 * the VFS can't check whether the victim is empty. The filesystem 736 736 * needs to do that for itself. ··· 752 752 } 753 753 754 754 /* XXX: We probably ought to alloc enough space for 755 - both nodes at the same time. Writing the new link, 755 + both nodes at the same time. Writing the new link, 756 756 then getting -ENOSPC, is quite bad :) 757 757 */ 758 758 759 759 /* Make a hard link */ 760 - 760 + 761 761 /* XXX: This is ugly */ 762 762 type = (old_dentry->d_inode->i_mode & S_IFMT) >> 12; 763 763 if (!type) type = DT_REG; 764 764 765 765 now = get_seconds(); 766 - ret = jffs2_do_link(c, JFFS2_INODE_INFO(new_dir_i), 766 + ret = jffs2_do_link(c, JFFS2_INODE_INFO(new_dir_i), 767 767 old_dentry->d_inode->i_ino, type, 768 768 new_dentry->d_name.name, new_dentry->d_name.len, now); 769 769 ··· 782 782 } 783 783 } 784 784 785 - /* If it was a directory we moved, and there was no victim, 785 + /* If it was a directory we moved, and there was no victim, 786 786 increase i_nlink on its new parent */ 787 787 if (S_ISDIR(old_dentry->d_inode->i_mode) && !victim_f) 788 788 new_dir_i->i_nlink++; 789 789 790 790 /* Unlink the original */ 791 - ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), 791 + ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), 792 792 old_dentry->d_name.name, old_dentry->d_name.len, NULL, now); 793 793 794 794 /* We don't touch inode->i_nlink */
+14 -14
fs/jffs2/erase.c
··· 24 24 struct jffs2_eraseblock *jeb; 25 25 struct jffs2_sb_info *c; 26 26 }; 27 - 27 + 28 28 #ifndef __ECOS 29 29 static void jffs2_erase_callback(struct erase_info *); 30 30 #endif ··· 71 71 instr->callback = jffs2_erase_callback; 72 72 instr->priv = (unsigned long)(&instr[1]); 73 73 instr->fail_addr = 0xffffffff; 74 - 74 + 75 75 ((struct erase_priv_struct *)instr->priv)->jeb = jeb; 76 76 ((struct erase_priv_struct *)instr->priv)->c = c; 77 77 ··· 96 96 return; 97 97 } 98 98 99 - if (ret == -EROFS) 99 + if (ret == -EROFS) 100 100 printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset); 101 101 else 102 102 printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret); ··· 197 197 c->nr_erasing_blocks--; 198 198 spin_unlock(&c->erase_completion_lock); 199 199 wake_up(&c->erase_wait); 200 - } 200 + } 201 201 202 202 #ifndef __ECOS 203 203 static void jffs2_erase_callback(struct erase_info *instr) ··· 209 209 jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr); 210 210 } else { 211 211 jffs2_erase_succeeded(priv->c, priv->jeb); 212 - } 212 + } 213 213 kfree(instr); 214 214 } 215 215 #endif /* !__ECOS */ ··· 227 227 /* Walk the inode's list once, removing any nodes from this eraseblock */ 228 228 while (1) { 229 229 if (!(*prev)->next_in_ino) { 230 - /* We're looking at the jffs2_inode_cache, which is 230 + /* We're looking at the jffs2_inode_cache, which is 231 231 at the end of the linked list. Stash it and continue 232 232 from the beginning of the list */ 233 233 ic = (struct jffs2_inode_cache *)(*prev); 234 234 prev = &ic->nodes; 235 235 continue; 236 - } 236 + } 237 237 238 238 if (SECTOR_ADDR((*prev)->flash_offset) == jeb->offset) { 239 239 /* It's in the block we're erasing */ ··· 267 267 printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n" KERN_DEBUG); 268 268 269 269 this = ic->nodes; 270 - 270 + 271 271 while(this) { 272 272 printk( "0x%08x(%d)->", ref_offset(this), ref_flags(this)); 273 273 if (++i == 5) { ··· 290 290 while(jeb->first_node) { 291 291 ref = jeb->first_node; 292 292 jeb->first_node = ref->next_phys; 293 - 293 + 294 294 /* Remove from the inode-list */ 295 295 if (ref->next_in_ino) 296 296 jffs2_remove_node_refs_from_ino_list(c, ref, jeb); ··· 307 307 uint32_t ofs; 308 308 size_t retlen; 309 309 int ret = -EIO; 310 - 310 + 311 311 ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); 312 312 if (!ebuf) { 313 313 printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset); ··· 361 361 case -EIO: goto filebad; 362 362 } 363 363 364 - /* Write the erase complete marker */ 364 + /* Write the erase complete marker */ 365 365 D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset)); 366 366 bad_offset = jeb->offset; 367 367 ··· 399 399 vecs[0].iov_base = (unsigned char *) &marker; 400 400 vecs[0].iov_len = sizeof(marker); 401 401 ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen); 402 - 402 + 403 403 if (ret || retlen != sizeof(marker)) { 404 404 if (ret) 405 405 printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n", ··· 416 416 marker_ref->next_phys = NULL; 417 417 marker_ref->flash_offset = jeb->offset | REF_NORMAL; 418 418 marker_ref->__totlen = c->cleanmarker_size; 419 - 419 + 420 420 jeb->first_node = jeb->last_node = marker_ref; 421 - 421 + 422 422 jeb->free_size = c->sector_size - c->cleanmarker_size; 423 423 jeb->used_size = c->cleanmarker_size; 424 424 jeb->dirty_size = 0;
+10 -10
fs/jffs2/file.c
··· 34 34 35 35 /* Trigger GC to flush any pending writes for this inode */ 36 36 jffs2_flush_wbuf_gc(c, inode->i_ino); 37 - 38 - return 0; 37 + 38 + return 0; 39 39 } 40 40 41 41 struct file_operations jffs2_file_operations = ··· 107 107 { 108 108 struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host); 109 109 int ret; 110 - 110 + 111 111 down(&f->sem); 112 112 ret = jffs2_do_readpage_unlock(pg->mapping->host, pg); 113 113 up(&f->sem); ··· 130 130 struct jffs2_raw_inode ri; 131 131 struct jffs2_full_dnode *fn; 132 132 uint32_t phys_ofs, alloc_len; 133 - 133 + 134 134 D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", 135 135 (unsigned int)inode->i_size, pageofs)); 136 136 ··· 160 160 ri.compr = JFFS2_COMPR_ZERO; 161 161 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); 162 162 ri.data_crc = cpu_to_je32(0); 163 - 163 + 164 164 fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_NORMAL); 165 165 166 166 if (IS_ERR(fn)) { ··· 187 187 inode->i_size = pageofs; 188 188 up(&f->sem); 189 189 } 190 - 190 + 191 191 /* Read in the page if it wasn't already present, unless it's a whole page */ 192 192 if (!PageUptodate(pg) && (start || end < PAGE_CACHE_SIZE)) { 193 193 down(&f->sem); ··· 218 218 if (!start && end == PAGE_CACHE_SIZE) { 219 219 /* We need to avoid deadlock with page_cache_read() in 220 220 jffs2_garbage_collect_pass(). So we have to mark the 221 - page up to date, to prevent page_cache_read() from 221 + page up to date, to prevent page_cache_read() from 222 222 trying to re-lock it. */ 223 223 SetPageUptodate(pg); 224 224 } ··· 252 252 /* There was an error writing. */ 253 253 SetPageError(pg); 254 254 } 255 - 255 + 256 256 /* Adjust writtenlen for the padding we did, so we don't confuse our caller */ 257 257 if (writtenlen < (start&3)) 258 258 writtenlen = 0; ··· 263 263 if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) { 264 264 inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen; 265 265 inode->i_blocks = (inode->i_size + 511) >> 9; 266 - 266 + 267 267 inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime)); 268 268 } 269 269 } ··· 272 272 273 273 if (start+writtenlen < end) { 274 274 /* generic_file_write has written more to the page cache than we've 275 - actually written to the medium. Mark the page !Uptodate so that 275 + actually written to the medium. Mark the page !Uptodate so that 276 276 it gets reread */ 277 277 D1(printk(KERN_DEBUG "jffs2_commit_write(): Not all bytes written. Marking page !uptodate\n")); 278 278 SetPageError(pg);
+28 -28
fs/jffs2/fs.c
··· 40 40 int ret; 41 41 D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); 42 42 ret = inode_change_ok(inode, iattr); 43 - if (ret) 43 + if (ret) 44 44 return ret; 45 45 46 46 /* Special cases - we don't want more than one data node ··· 73 73 kfree(mdata); 74 74 return -ENOMEM; 75 75 } 76 - 76 + 77 77 ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &phys_ofs, &alloclen, 78 78 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); 79 79 if (ret) { ··· 84 84 } 85 85 down(&f->sem); 86 86 ivalid = iattr->ia_valid; 87 - 87 + 88 88 ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 89 89 ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE); 90 90 ri->totlen = cpu_to_je32(sizeof(*ri) + mdatalen); ··· 100 100 if (iattr->ia_mode & S_ISGID && 101 101 !in_group_p(je16_to_cpu(ri->gid)) && !capable(CAP_FSETID)) 102 102 ri->mode = cpu_to_jemode(iattr->ia_mode & ~S_ISGID); 103 - else 103 + else 104 104 ri->mode = cpu_to_jemode(iattr->ia_mode); 105 105 else 106 106 ri->mode = cpu_to_jemode(inode->i_mode); ··· 129 129 new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, ALLOC_NORMAL); 130 130 if (S_ISLNK(inode->i_mode)) 131 131 kfree(mdata); 132 - 132 + 133 133 if (IS_ERR(new_metadata)) { 134 134 jffs2_complete_reservation(c); 135 135 jffs2_free_raw_inode(ri); ··· 167 167 jffs2_complete_reservation(c); 168 168 169 169 /* We have to do the vmtruncate() without f->sem held, since 170 - some pages may be locked and waiting for it in readpage(). 170 + some pages may be locked and waiting for it in readpage(). 171 171 We are protected from a simultaneous write() extending i_size 172 172 back past iattr->ia_size, because do_truncate() holds the 173 173 generic inode semaphore. */ ··· 210 210 211 211 void jffs2_clear_inode (struct inode *inode) 212 212 { 213 - /* We can forget about this inode for now - drop all 213 + /* We can forget about this inode for now - drop all 214 214 * the nodelists associated with it, etc. 215 215 */ 216 216 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); 217 217 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 218 - 218 + 219 219 D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode)); 220 220 221 221 jffs2_do_clear_inode(c, f); ··· 234 234 c = JFFS2_SB_INFO(inode->i_sb); 235 235 236 236 jffs2_init_inode_info(f); 237 - 237 + 238 238 ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); 239 239 240 240 if (ret) { ··· 254 254 255 255 inode->i_blksize = PAGE_SIZE; 256 256 inode->i_blocks = (inode->i_size + 511) >> 9; 257 - 257 + 258 258 switch (inode->i_mode & S_IFMT) { 259 259 jint16_t rdev; 260 260 261 261 case S_IFLNK: 262 262 inode->i_op = &jffs2_symlink_inode_operations; 263 263 break; 264 - 264 + 265 265 case S_IFDIR: 266 266 { 267 267 struct jffs2_full_dirent *fd; ··· 298 298 jffs2_do_clear_inode(c, f); 299 299 make_bad_inode(inode); 300 300 return; 301 - } 301 + } 302 302 303 303 case S_IFSOCK: 304 304 case S_IFIFO: ··· 354 354 down(&c->alloc_sem); 355 355 jffs2_flush_wbuf_pad(c); 356 356 up(&c->alloc_sem); 357 - } 357 + } 358 358 359 359 if (!(*flags & MS_RDONLY)) 360 360 jffs2_start_garbage_collect_thread(c); 361 - 361 + 362 362 *flags |= MS_NOATIME; 363 363 364 364 return 0; ··· 392 392 D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode)); 393 393 394 394 c = JFFS2_SB_INFO(sb); 395 - 395 + 396 396 inode = new_inode(sb); 397 - 397 + 398 398 if (!inode) 399 399 return ERR_PTR(-ENOMEM); 400 400 ··· 458 458 #endif 459 459 460 460 c->flash_size = c->mtd->size; 461 - c->sector_size = c->mtd->erasesize; 461 + c->sector_size = c->mtd->erasesize; 462 462 blocks = c->flash_size / c->sector_size; 463 463 464 464 /* 465 465 * Size alignment check 466 466 */ 467 467 if ((c->sector_size * blocks) != c->flash_size) { 468 - c->flash_size = c->sector_size * blocks; 468 + c->flash_size = c->sector_size * blocks; 469 469 printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n", 470 470 c->flash_size / 1024); 471 471 } ··· 543 543 struct jffs2_inode_cache *ic; 544 544 if (!nlink) { 545 545 /* The inode has zero nlink but its nodes weren't yet marked 546 - obsolete. This has to be because we're still waiting for 546 + obsolete. This has to be because we're still waiting for 547 547 the final (close() and) iput() to happen. 548 548 549 - There's a possibility that the final iput() could have 549 + There's a possibility that the final iput() could have 550 550 happened while we were contemplating. In order to ensure 551 551 that we don't cause a new read_inode() (which would fail) 552 552 for the inode in question, we use ilookup() in this case 553 553 instead of iget(). 554 554 555 - The nlink can't _become_ zero at this point because we're 555 + The nlink can't _become_ zero at this point because we're 556 556 holding the alloc_sem, and jffs2_do_unlink() would also 557 557 need that while decrementing nlink on any inode. 558 558 */ ··· 599 599 return JFFS2_INODE_INFO(inode); 600 600 } 601 601 602 - unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, 603 - struct jffs2_inode_info *f, 602 + unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, 603 + struct jffs2_inode_info *f, 604 604 unsigned long offset, 605 605 unsigned long *priv) 606 606 { 607 607 struct inode *inode = OFNI_EDONI_2SFFJ(f); 608 608 struct page *pg; 609 609 610 - pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT, 610 + pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT, 611 611 (void *)jffs2_do_readpage_unlock, inode); 612 612 if (IS_ERR(pg)) 613 613 return (void *)pg; 614 - 614 + 615 615 *priv = (unsigned long)pg; 616 616 return kmap(pg); 617 617 } ··· 628 628 629 629 static int jffs2_flash_setup(struct jffs2_sb_info *c) { 630 630 int ret = 0; 631 - 631 + 632 632 if (jffs2_cleanmarker_oob(c)) { 633 633 /* NAND flash... do setup accordingly */ 634 634 ret = jffs2_nand_flash_setup(c); ··· 642 642 if (ret) 643 643 return ret; 644 644 } 645 - 645 + 646 646 /* and Dataflash */ 647 647 if (jffs2_dataflash(c)) { 648 648 ret = jffs2_dataflash_setup(c); ··· 670 670 if (jffs2_nor_ecc(c)) { 671 671 jffs2_nor_ecc_flash_cleanup(c); 672 672 } 673 - 673 + 674 674 /* and DataFlash */ 675 675 if (jffs2_dataflash(c)) { 676 676 jffs2_dataflash_cleanup(c);
+56 -56
fs/jffs2/gc.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: gc.c,v 1.154 2005/09/07 08:34:54 havasi Exp $ 10 + * $Id: gc.c,v 1.155 2005/11/07 11:14:39 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 21 21 #include "nodelist.h" 22 22 #include "compr.h" 23 23 24 - static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, 24 + static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, 25 25 struct jffs2_inode_cache *ic, 26 26 struct jffs2_raw_node_ref *raw); 27 - static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 27 + static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 28 28 struct jffs2_inode_info *f, struct jffs2_full_dnode *fd); 29 - static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 29 + static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 30 30 struct jffs2_inode_info *f, struct jffs2_full_dirent *fd); 31 - static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 31 + static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 32 32 struct jffs2_inode_info *f, struct jffs2_full_dirent *fd); 33 33 static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 34 34 struct jffs2_inode_info *f, struct jffs2_full_dnode *fn, ··· 55 55 D1(printk(KERN_DEBUG "Picking block from bad_used_list to GC next\n")); 56 56 nextlist = &c->bad_used_list; 57 57 } else if (n < 50 && !list_empty(&c->erasable_list)) { 58 - /* Note that most of them will have gone directly to be erased. 58 + /* Note that most of them will have gone directly to be erased. 59 59 So don't favour the erasable_list _too_ much. */ 60 60 D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n")); 61 61 nextlist = &c->erasable_list; ··· 101 101 printk(KERN_WARNING "Eep. ret->gc_node for block at 0x%08x is NULL\n", ret->offset); 102 102 BUG(); 103 103 } 104 - 104 + 105 105 /* Have we accidentally picked a clean block with wasted space ? */ 106 106 if (ret->wasted_size) { 107 107 D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size)); ··· 136 136 137 137 /* We can't start doing GC yet. We haven't finished checking 138 138 the node CRCs etc. Do it now. */ 139 - 139 + 140 140 /* checked_ino is protected by the alloc_sem */ 141 141 if (c->checked_ino > c->highest_ino) { 142 142 printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n", ··· 178 178 179 179 case INO_STATE_READING: 180 180 /* We need to wait for it to finish, lest we move on 181 - and trigger the BUG() above while we haven't yet 181 + and trigger the BUG() above while we haven't yet 182 182 finished checking all its nodes */ 183 183 D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); 184 184 up(&c->alloc_sem); ··· 228 228 } 229 229 230 230 raw = jeb->gc_node; 231 - 231 + 232 232 while(ref_obsolete(raw)) { 233 233 D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); 234 234 raw = raw->next_phys; 235 235 if (unlikely(!raw)) { 236 236 printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); 237 - printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", 237 + printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", 238 238 jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); 239 239 jeb->gc_node = raw; 240 240 spin_unlock(&c->erase_completion_lock); ··· 259 259 ic = jffs2_raw_ref_to_ic(raw); 260 260 261 261 /* We need to hold the inocache. Either the erase_completion_lock or 262 - the inocache_lock are sufficient; we trade down since the inocache_lock 262 + the inocache_lock are sufficient; we trade down since the inocache_lock 263 263 causes less contention. */ 264 264 spin_lock(&c->inocache_lock); 265 265 ··· 278 278 279 279 switch(ic->state) { 280 280 case INO_STATE_CHECKEDABSENT: 281 - /* It's been checked, but it's not currently in-core. 281 + /* It's been checked, but it's not currently in-core. 282 282 We can just copy any pristine nodes, but have 283 283 to prevent anyone else from doing read_inode() while 284 284 we're at it, so we set the state accordingly */ 285 285 if (ref_flags(raw) == REF_PRISTINE) 286 286 ic->state = INO_STATE_GC; 287 287 else { 288 - D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", 288 + D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", 289 289 ic->ino)); 290 290 } 291 291 break; ··· 298 298 case INO_STATE_CHECKING: 299 299 case INO_STATE_GC: 300 300 /* Should never happen. We should have finished checking 301 - by the time we actually start doing any GC, and since 302 - we're holding the alloc_sem, no other garbage collection 301 + by the time we actually start doing any GC, and since 302 + we're holding the alloc_sem, no other garbage collection 303 303 can happen. 304 304 */ 305 305 printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", ··· 319 319 D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", 320 320 ic->ino, ic->state)); 321 321 sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); 322 - /* And because we dropped the alloc_sem we must start again from the 322 + /* And because we dropped the alloc_sem we must start again from the 323 323 beginning. Ponder chance of livelock here -- we're returning success 324 324 without actually making any progress. 325 325 326 - Q: What are the chances that the inode is back in INO_STATE_READING 326 + Q: What are the chances that the inode is back in INO_STATE_READING 327 327 again by the time we next enter this function? And that this happens 328 328 enough times to cause a real delay? 329 329 330 - A: Small enough that I don't care :) 330 + A: Small enough that I don't care :) 331 331 */ 332 332 return 0; 333 333 } 334 334 335 335 /* OK. Now if the inode is in state INO_STATE_GC, we are going to copy the 336 - node intact, and we don't have to muck about with the fragtree etc. 336 + node intact, and we don't have to muck about with the fragtree etc. 337 337 because we know it's not in-core. If it _was_ in-core, we go through 338 338 all the iget() crap anyway */ 339 339 ··· 453 453 if (!ret) { 454 454 /* Urgh. Return it sensibly. */ 455 455 frag->node->raw = f->inocache->nodes; 456 - } 456 + } 457 457 if (ret != -EBADFD) 458 458 goto upnout; 459 459 } ··· 467 467 } 468 468 goto upnout; 469 469 } 470 - 470 + 471 471 /* Wasn't a dnode. Try dirent */ 472 472 for (fd = f->dents; fd; fd=fd->next) { 473 473 if (fd->raw == raw) ··· 494 494 return ret; 495 495 } 496 496 497 - static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, 497 + static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, 498 498 struct jffs2_inode_cache *ic, 499 499 struct jffs2_raw_node_ref *raw) 500 500 { ··· 580 580 } 581 581 break; 582 582 default: 583 - printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", 583 + printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", 584 584 ref_offset(raw), je16_to_cpu(node->u.nodetype)); 585 585 goto bail; 586 586 } ··· 621 621 retried = 1; 622 622 623 623 D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n")); 624 - 624 + 625 625 jffs2_dbg_acct_sanity_check(c,jeb); 626 626 jffs2_dbg_acct_paranoia_check(c, jeb); 627 627 ··· 669 669 goto out_node; 670 670 } 671 671 672 - static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 672 + static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 673 673 struct jffs2_inode_info *f, struct jffs2_full_dnode *fn) 674 674 { 675 675 struct jffs2_full_dnode *new_fn; ··· 684 684 S_ISCHR(JFFS2_F_I_MODE(f)) ) { 685 685 /* For these, we don't actually need to read the old node */ 686 686 /* FIXME: for minor or major > 255. */ 687 - dev = cpu_to_je16(((JFFS2_F_I_RDEV_MAJ(f) << 8) | 687 + dev = cpu_to_je16(((JFFS2_F_I_RDEV_MAJ(f) << 8) | 688 688 JFFS2_F_I_RDEV_MIN(f))); 689 689 mdata = (char *)&dev; 690 690 mdatalen = sizeof(dev); ··· 705 705 D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen)); 706 706 707 707 } 708 - 708 + 709 709 ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &phys_ofs, &alloclen, 710 710 JFFS2_SUMMARY_INODE_SIZE); 711 711 if (ret) { ··· 713 713 sizeof(ri)+ mdatalen, ret); 714 714 goto out; 715 715 } 716 - 716 + 717 717 last_frag = frag_last(&f->fragtree); 718 718 if (last_frag) 719 719 /* Fetch the inode length from the fragtree rather then ··· 721 721 ilen = last_frag->ofs + last_frag->size; 722 722 else 723 723 ilen = JFFS2_F_I_SIZE(f); 724 - 724 + 725 725 memset(&ri, 0, sizeof(ri)); 726 726 ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 727 727 ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE); ··· 760 760 return ret; 761 761 } 762 762 763 - static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 763 + static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 764 764 struct jffs2_inode_info *f, struct jffs2_full_dirent *fd) 765 765 { 766 766 struct jffs2_full_dirent *new_fd; ··· 781 781 so refrain from splatting them. */ 782 782 if (JFFS2_F_I_MTIME(f) == JFFS2_F_I_CTIME(f)) 783 783 rd.mctime = cpu_to_je32(JFFS2_F_I_MTIME(f)); 784 - else 784 + else 785 785 rd.mctime = cpu_to_je32(0); 786 786 rd.type = fd->type; 787 787 rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8)); 788 788 rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize)); 789 - 789 + 790 790 ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &phys_ofs, &alloclen, 791 791 JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); 792 792 if (ret) { ··· 804 804 return 0; 805 805 } 806 806 807 - static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 807 + static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 808 808 struct jffs2_inode_info *f, struct jffs2_full_dirent *fd) 809 809 { 810 810 struct jffs2_full_dirent **fdp = &f->dents; ··· 843 843 if (ref_totlen(c, NULL, raw) != rawlen) 844 844 continue; 845 845 846 - /* Doesn't matter if there's one in the same erase block. We're going to 846 + /* Doesn't matter if there's one in the same erase block. We're going to 847 847 delete it too at the same time. */ 848 848 if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) 849 849 continue; ··· 895 895 kfree(rd); 896 896 } 897 897 898 - /* FIXME: If we're deleting a dirent which contains the current mtime and ctime, 898 + /* FIXME: If we're deleting a dirent which contains the current mtime and ctime, 899 899 we should update the metadata node with those times accordingly */ 900 900 901 901 /* No need for it any more. Just mark it obsolete and remove it from the list */ ··· 927 927 928 928 D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", 929 929 f->inocache->ino, start, end)); 930 - 930 + 931 931 memset(&ri, 0, sizeof(ri)); 932 932 933 933 if(fn->frags > 1) { 934 934 size_t readlen; 935 935 uint32_t crc; 936 - /* It's partially obsoleted by a later write. So we have to 936 + /* It's partially obsoleted by a later write. So we have to 937 937 write it out again with the _same_ version as before */ 938 938 ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); 939 939 if (readlen != sizeof(ri) || ret) { ··· 955 955 crc = crc32(0, &ri, sizeof(ri)-8); 956 956 if (crc != je32_to_cpu(ri.node_crc)) { 957 957 printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n", 958 - ref_offset(fn->raw), 958 + ref_offset(fn->raw), 959 959 je32_to_cpu(ri.node_crc), crc); 960 960 /* FIXME: We could possibly deal with this by writing new holes for each frag */ 961 - printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", 961 + printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", 962 962 start, end, f->inocache->ino); 963 963 goto fill; 964 964 } 965 965 if (ri.compr != JFFS2_COMPR_ZERO) { 966 966 printk(KERN_WARNING "jffs2_garbage_collect_hole: Node 0x%08x wasn't a hole node!\n", ref_offset(fn->raw)); 967 - printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", 967 + printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", 968 968 start, end, f->inocache->ino); 969 969 goto fill; 970 970 } ··· 982 982 ri.csize = cpu_to_je32(0); 983 983 ri.compr = JFFS2_COMPR_ZERO; 984 984 } 985 - 985 + 986 986 frag = frag_last(&f->fragtree); 987 987 if (frag) 988 988 /* Fetch the inode length from the fragtree rather then ··· 1024 1024 return 0; 1025 1025 } 1026 1026 1027 - /* 1027 + /* 1028 1028 * We should only get here in the case where the node we are 1029 1029 * replacing had more than one frag, so we kept the same version 1030 - * number as before. (Except in case of error -- see 'goto fill;' 1030 + * number as before. (Except in case of error -- see 'goto fill;' 1031 1031 * above.) 1032 1032 */ 1033 1033 D1(if(unlikely(fn->frags <= 1)) { ··· 1039 1039 /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ 1040 1040 mark_ref_normal(new_fn->raw); 1041 1041 1042 - for (frag = jffs2_lookup_node_frag(&f->fragtree, fn->ofs); 1042 + for (frag = jffs2_lookup_node_frag(&f->fragtree, fn->ofs); 1043 1043 frag; frag = frag_next(frag)) { 1044 1044 if (frag->ofs > fn->size + fn->ofs) 1045 1045 break; ··· 1057 1057 printk(KERN_WARNING "jffs2_garbage_collect_hole: New node has no frags!\n"); 1058 1058 BUG(); 1059 1059 } 1060 - 1060 + 1061 1061 jffs2_mark_node_obsolete(c, fn->raw); 1062 1062 jffs2_free_full_dnode(fn); 1063 - 1063 + 1064 1064 return 0; 1065 1065 } 1066 1066 ··· 1070 1070 { 1071 1071 struct jffs2_full_dnode *new_fn; 1072 1072 struct jffs2_raw_inode ri; 1073 - uint32_t alloclen, phys_ofs, offset, orig_end, orig_start; 1073 + uint32_t alloclen, phys_ofs, offset, orig_end, orig_start; 1074 1074 int ret = 0; 1075 1075 unsigned char *comprbuf = NULL, *writebuf; 1076 1076 unsigned long pg; 1077 1077 unsigned char *pg_ptr; 1078 - 1078 + 1079 1079 memset(&ri, 0, sizeof(ri)); 1080 1080 1081 1081 D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", ··· 1087 1087 if (c->nr_free_blocks + c->nr_erasing_blocks > c->resv_blocks_gcmerge) { 1088 1088 /* Attempt to do some merging. But only expand to cover logically 1089 1089 adjacent frags if the block containing them is already considered 1090 - to be dirty. Otherwise we end up with GC just going round in 1091 - circles dirtying the nodes it already wrote out, especially 1090 + to be dirty. Otherwise we end up with GC just going round in 1091 + circles dirtying the nodes it already wrote out, especially 1092 1092 on NAND where we have small eraseblocks and hence a much higher 1093 1093 chance of nodes having to be split to cross boundaries. */ 1094 1094 ··· 1122 1122 break; 1123 1123 } else { 1124 1124 1125 - /* OK, it's a frag which extends to the beginning of the page. Does it live 1125 + /* OK, it's a frag which extends to the beginning of the page. Does it live 1126 1126 in a block which is still considered clean? If so, don't obsolete it. 1127 1127 If not, cover it anyway. */ 1128 1128 ··· 1172 1172 break; 1173 1173 } else { 1174 1174 1175 - /* OK, it's a frag which extends to the beginning of the page. Does it live 1175 + /* OK, it's a frag which extends to the beginning of the page. Does it live 1176 1176 in a block which is still considered clean? If so, don't obsolete it. 1177 1177 If not, cover it anyway. */ 1178 1178 ··· 1199 1199 break; 1200 1200 } 1201 1201 } 1202 - D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", 1202 + D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", 1203 1203 orig_start, orig_end, start, end)); 1204 1204 1205 1205 D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); 1206 1206 BUG_ON(end < orig_end); 1207 1207 BUG_ON(start > orig_start); 1208 1208 } 1209 - 1209 + 1210 1210 /* First, use readpage() to read the appropriate page into the page cache */ 1211 1211 /* Q: What happens if we actually try to GC the _same_ page for which commit_write() 1212 1212 * triggered garbage collection in the first place? ··· 1263 1263 ri.usercompr = (comprtype >> 8) & 0xff; 1264 1264 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); 1265 1265 ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen)); 1266 - 1266 + 1267 1267 new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, phys_ofs, ALLOC_GC); 1268 1268 1269 1269 jffs2_free_comprbuf(comprbuf, writebuf);
+1 -1
fs/jffs2/histo.h
··· 1 1 /* This file provides the bit-probabilities for the input file */ 2 - #define BIT_DIVIDER 629 2 + #define BIT_DIVIDER 629 3 3 static int bits[9] = { 179,167,183,165,159,198,178,119,}; /* ia32 .so files */
+1 -1
fs/jffs2/histo_mips.h
··· 1 - #define BIT_DIVIDER_MIPS 1043 1 + #define BIT_DIVIDER_MIPS 1043 2 2 static int bits_mips[8] = { 277,249,290,267,229,341,212,241}; /* mips32 */
+3 -3
fs/jffs2/ioctl.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: ioctl.c,v 1.9 2004/11/16 20:36:11 dwmw2 Exp $ 10 + * $Id: ioctl.c,v 1.10 2005/11/07 11:14:40 gleixner Exp $ 11 11 * 12 12 */ 13 13 14 14 #include <linux/fs.h> 15 15 16 - int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 16 + int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 17 17 unsigned long arg) 18 18 { 19 19 /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which 20 20 will include compression support etc. */ 21 21 return -ENOTTY; 22 22 } 23 - 23 +
+2 -2
fs/jffs2/malloc.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: malloc.c,v 1.30 2005/09/20 14:27:34 dedekind Exp $ 10 + * $Id: malloc.c,v 1.31 2005/11/07 11:14:40 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 29 29 30 30 int __init jffs2_create_slab_caches(void) 31 31 { 32 - full_dnode_slab = kmem_cache_create("jffs2_full_dnode", 32 + full_dnode_slab = kmem_cache_create("jffs2_full_dnode", 33 33 sizeof(struct jffs2_full_dnode), 34 34 0, 0, NULL, NULL); 35 35 if (!full_dnode_slab)
+85 -85
fs/jffs2/nodelist.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: nodelist.c,v 1.114 2005/09/21 13:28:35 dedekind Exp $ 10 + * $Id: nodelist.c,v 1.115 2005/11/07 11:14:40 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 24 24 void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list) 25 25 { 26 26 struct jffs2_full_dirent **prev = list; 27 - 27 + 28 28 dbg_dentlist("add dirent \"%s\", ino #%u\n", new->name, new->ino); 29 29 30 30 while ((*prev) && (*prev)->nhash <= new->nhash) { ··· 75 75 if (size == 0) 76 76 return; 77 77 78 - /* 78 + /* 79 79 * If the last fragment starts at the RAM page boundary, it is 80 80 * REF_PRISTINE irrespective of its size. 81 81 */ 82 82 frag = frag_last(list); 83 83 if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) { 84 84 dbg_fragtree2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n", 85 - frag->ofs, frag->ofs + frag->size); 85 + frag->ofs, frag->ofs + frag->size); 86 86 frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE; 87 87 } 88 88 } ··· 102 102 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags); 103 103 mark_ref_normal(this->node->raw); 104 104 } 105 - 105 + 106 106 } 107 107 jffs2_free_node_frag(this); 108 108 } ··· 117 117 while (*link) { 118 118 parent = *link; 119 119 base = rb_entry(parent, struct jffs2_node_frag, rb); 120 - 120 + 121 121 if (newfrag->ofs > base->ofs) 122 122 link = &base->rb.rb_right; 123 123 else if (newfrag->ofs < base->ofs) ··· 137 137 static inline struct jffs2_node_frag * new_fragment(struct jffs2_full_dnode *fn, uint32_t ofs, uint32_t size) 138 138 { 139 139 struct jffs2_node_frag *newfrag; 140 - 140 + 141 141 newfrag = jffs2_alloc_node_frag(); 142 142 if (likely(newfrag)) { 143 143 newfrag->ofs = ofs; ··· 169 169 } 170 170 171 171 if (this) { 172 - /* By definition, the 'this' node has no right-hand child, 172 + /* By definition, the 'this' node has no right-hand child, 173 173 because there are no frags with offset greater than it. 174 174 So that's where we want to put the hole */ 175 175 dbg_fragtree2("add hole frag %#04x-%#04x on the right of the new frag.\n", ··· 183 183 rb_insert_color(&holefrag->rb, root); 184 184 this = holefrag; 185 185 } 186 - 186 + 187 187 if (this) { 188 - /* By definition, the 'this' node has no right-hand child, 188 + /* By definition, the 'this' node has no right-hand child, 189 189 because there are no frags with offset greater than it. 190 190 So that's where we want to put new fragment */ 191 191 dbg_fragtree2("add the new node at the right\n"); 192 - rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 192 + rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 193 193 } else { 194 194 dbg_fragtree2("insert the new node at the root of the tree\n"); 195 195 rb_link_node(&newfrag->rb, NULL, &root->rb_node); ··· 216 216 dbg_fragtree2("lookup gave no frag\n"); 217 217 lastend = 0; 218 218 } 219 - 219 + 220 220 /* See if we ran off the end of the fragtree */ 221 221 if (lastend <= newfrag->ofs) { 222 222 /* We did */ ··· 243 243 this->ofs, this->ofs + this->size); 244 244 245 245 /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes, 246 - * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs 246 + * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs 247 247 */ 248 248 if (newfrag->ofs > this->ofs) { 249 249 /* This node isn't completely obsoleted. The start of it remains valid */ ··· 261 261 if (this->node) 262 262 dbg_fragtree2("split old frag 0x%04x-0x%04x, phys 0x%08x\n", 263 263 this->ofs, this->ofs+this->size, ref_offset(this->node->raw)); 264 - else 264 + else 265 265 dbg_fragtree2("split old hole frag 0x%04x-0x%04x\n", 266 266 this->ofs, this->ofs+this->size); 267 - 267 + 268 268 /* New second frag pointing to this's node */ 269 269 newfrag2 = new_fragment(this->node, newfrag->ofs + newfrag->size, 270 270 this->ofs + this->size - newfrag->ofs - newfrag->size); ··· 284 284 from newfrag to insert newfrag2. */ 285 285 jffs2_fragtree_insert(newfrag, this); 286 286 rb_insert_color(&newfrag->rb, root); 287 - 287 + 288 288 jffs2_fragtree_insert(newfrag2, newfrag); 289 289 rb_insert_color(&newfrag2->rb, root); 290 - 290 + 291 291 return 0; 292 292 } 293 293 /* New node just reduces 'this' frag in size, doesn't split it */ ··· 297 297 jffs2_fragtree_insert(newfrag, this); 298 298 rb_insert_color(&newfrag->rb, root); 299 299 } else { 300 - /* New frag starts at the same point as 'this' used to. Replace 300 + /* New frag starts at the same point as 'this' used to. Replace 301 301 it in the tree without doing a delete and insertion */ 302 302 dbg_fragtree2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n", 303 303 newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size); 304 - 304 + 305 305 rb_replace_node(&this->rb, &newfrag->rb, root); 306 - 306 + 307 307 if (newfrag->ofs + newfrag->size >= this->ofs+this->size) { 308 308 dbg_fragtree2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size); 309 309 jffs2_obsolete_node_frag(c, this); ··· 317 317 } 318 318 } 319 319 /* OK, now we have newfrag added in the correct place in the tree, but 320 - frag_next(newfrag) may be a fragment which is overlapped by it 320 + frag_next(newfrag) may be a fragment which is overlapped by it 321 321 */ 322 322 while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) { 323 323 /* 'this' frag is obsoleted completely. */ ··· 326 326 rb_erase(&this->rb, root); 327 327 jffs2_obsolete_node_frag(c, this); 328 328 } 329 - /* Now we're pointing at the first frag which isn't totally obsoleted by 329 + /* Now we're pointing at the first frag which isn't totally obsoleted by 330 330 the new frag */ 331 331 332 332 if (!this || newfrag->ofs + newfrag->size == this->ofs) ··· 344 344 return 0; 345 345 } 346 346 347 - /* 347 + /* 348 348 * Given an inode, probably with existing tree of fragments, add the new node 349 349 * to the fragment tree. 350 350 */ ··· 363 363 364 364 dbg_fragtree("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n", 365 365 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag); 366 - 366 + 367 367 ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag); 368 368 if (unlikely(ret)) 369 369 return ret; ··· 374 374 struct jffs2_node_frag *prev = frag_prev(newfrag); 375 375 376 376 mark_ref_normal(fn->raw); 377 - /* If we don't start at zero there's _always_ a previous */ 377 + /* If we don't start at zero there's _always_ a previous */ 378 378 if (prev->node) 379 379 mark_ref_normal(prev->node->raw); 380 380 } 381 381 382 382 if ((newfrag->ofs+newfrag->size) & (PAGE_CACHE_SIZE-1)) { 383 383 struct jffs2_node_frag *next = frag_next(newfrag); 384 - 384 + 385 385 if (next) { 386 386 mark_ref_normal(fn->raw); 387 387 if (next->node) ··· 412 412 413 413 if (!jffs2_is_writebuffered(c)) 414 414 goto adj_acc; 415 - 415 + 416 416 /* Calculate how many bytes were already checked */ 417 417 ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); 418 418 len = ofs % c->wbuf_pagesize; ··· 424 424 ref_offset(ref), tn->csize, ofs); 425 425 goto adj_acc; 426 426 } 427 - 427 + 428 428 ofs += len; 429 429 len = tn->csize - len; 430 - 430 + 431 431 dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", 432 432 ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); 433 - 433 + 434 434 #ifndef __ECOS 435 435 /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(), 436 436 * adding and jffs2_flash_read_end() interface. */ ··· 445 445 pointed = 1; /* succefully pointed to device */ 446 446 } 447 447 #endif 448 - 448 + 449 449 if (!pointed) { 450 450 buffer = kmalloc(len, GFP_KERNEL); 451 451 if (unlikely(!buffer)) 452 452 return -ENOMEM; 453 - 453 + 454 454 /* TODO: this is very frequent pattern, make it a separate 455 455 * routine */ 456 456 err = jffs2_flash_read(c, ofs, len, &retlen, buffer); ··· 458 458 JFFS2_ERROR("can not read %d bytes from 0x%08x, error code: %d.\n", len, ofs, err); 459 459 goto free_out; 460 460 } 461 - 461 + 462 462 if (retlen != len) { 463 463 JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ofs, retlen, len); 464 464 err = -EIO; ··· 485 485 jeb = &c->blocks[ref->flash_offset / c->sector_size]; 486 486 len = ref_totlen(c, jeb, ref); 487 487 488 - /* 488 + /* 489 489 * Mark the node as having been checked and fix the 490 490 * accounting accordingly. 491 491 */ ··· 516 516 static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn) 517 517 { 518 518 int ret; 519 - 519 + 520 520 BUG_ON(ref_obsolete(tn->fn->raw)); 521 521 522 522 /* We only check the data CRC of unchecked nodes */ 523 523 if (ref_flags(tn->fn->raw) != REF_UNCHECKED) 524 524 return 0; 525 - 525 + 526 526 dbg_fragtree2("check node %#04x-%#04x, phys offs %#08x.\n", 527 527 tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw)); 528 528 ··· 538 538 return ret; 539 539 } 540 540 541 - /* 541 + /* 542 542 * Helper function for jffs2_add_older_frag_to_fragtree(). 543 543 * 544 544 * Called when the new fragment that is being inserted ··· 551 551 newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size); 552 552 553 553 if (hole->ofs == newfrag->ofs) { 554 - /* 554 + /* 555 555 * Well, the new fragment actually starts at the same offset as 556 556 * the hole. 557 557 */ 558 558 if (hole->ofs + hole->size > newfrag->ofs + newfrag->size) { 559 - /* 559 + /* 560 560 * We replace the overlapped left part of the hole by 561 561 * the new node. 562 562 */ 563 - 563 + 564 564 dbg_fragtree2("insert fragment %#04x-%#04x and cut the left part of the hole\n", 565 565 newfrag->ofs, newfrag->ofs + newfrag->size); 566 566 rb_replace_node(&hole->rb, &newfrag->rb, root); 567 - 567 + 568 568 hole->ofs += newfrag->size; 569 569 hole->size -= newfrag->size; 570 - 571 - /* 570 + 571 + /* 572 572 * We know that 'hole' should be the right hand 573 573 * fragment. 574 574 */ 575 575 jffs2_fragtree_insert(hole, newfrag); 576 576 rb_insert_color(&hole->rb, root); 577 577 } else { 578 - /* 578 + /* 579 579 * Ah, the new fragment is of the same size as the hole. 580 580 * Relace the hole by it. 581 581 */ ··· 586 586 } 587 587 } else { 588 588 /* The new fragment lefts some hole space at the left */ 589 - 589 + 590 590 struct jffs2_node_frag * newfrag2 = NULL; 591 591 592 592 if (hole->ofs + hole->size > newfrag->ofs + newfrag->size) { ··· 606 606 607 607 jffs2_fragtree_insert(newfrag, hole); 608 608 rb_insert_color(&newfrag->rb, root); 609 - 609 + 610 610 if (newfrag2) { 611 611 dbg_fragtree2("left the hole %#04x-%#04x at the right\n", 612 612 newfrag2->ofs, newfrag2->ofs + newfrag2->size); ··· 654 654 lastend = this->ofs + this->size; 655 655 else 656 656 lastend = 0; 657 - 657 + 658 658 /* Detect the preliminary type of node */ 659 659 if (fn->size >= PAGE_CACHE_SIZE) 660 660 ref_flag = REF_PRISTINE; 661 661 else 662 662 ref_flag = REF_NORMAL; 663 - 663 + 664 664 /* See if we ran off the end of the root */ 665 665 if (lastend <= fn_ofs) { 666 666 /* We did */ 667 - 668 - /* 667 + 668 + /* 669 669 * We are going to insert the new node into the 670 670 * fragment tree, so check it. 671 671 */ ··· 691 691 fn->frags = 0; 692 692 693 693 while (1) { 694 - /* 694 + /* 695 695 * Here we have: 696 696 * fn_ofs < this->ofs + this->size && fn_ofs >= this->ofs. 697 - * 697 + * 698 698 * Remember, 'this' has higher version, any non-hole node 699 699 * which is already in the fragtree is newer then the newly 700 700 * inserted. 701 701 */ 702 702 if (!this->node) { 703 - /* 703 + /* 704 704 * 'this' is the hole fragment, so at least the 705 705 * beginning of the new fragment is valid. 706 706 */ 707 - 708 - /* 707 + 708 + /* 709 709 * We are going to insert the new node into the 710 710 * fragment tree, so check it. 711 711 */ ··· 715 715 return err; 716 716 checked = 1; 717 717 } 718 - 718 + 719 719 if (this->ofs + this->size >= fn_ofs + fn_size) { 720 720 /* We split the hole on two parts */ 721 721 ··· 730 730 goto out_ok; 731 731 } 732 732 733 - /* 733 + /* 734 734 * The beginning of the new fragment is valid since it 735 735 * overlaps the hole node. 736 736 */ ··· 742 742 this->ofs + this->size - fn_ofs); 743 743 if (unlikely(!newfrag)) 744 744 return -ENOMEM; 745 - 745 + 746 746 if (fn_ofs == this->ofs) { 747 - /* 747 + /* 748 748 * The new node starts at the same offset as 749 749 * the hole and supersieds the hole. 750 750 */ ··· 754 754 rb_replace_node(&this->rb, &newfrag->rb, root); 755 755 jffs2_free_node_frag(this); 756 756 } else { 757 - /* 757 + /* 758 758 * The hole becomes shorter as its right part 759 759 * is supersieded by the new fragment. 760 760 */ 761 761 dbg_fragtree2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n", 762 762 this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size); 763 - 763 + 764 764 dbg_fragtree2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs, 765 765 fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); 766 - 766 + 767 767 this->size -= newfrag->size; 768 768 jffs2_fragtree_insert(newfrag, this); 769 769 rb_insert_color(&newfrag->rb, root); 770 770 } 771 - 771 + 772 772 fn_ofs += newfrag->size; 773 773 fn_size -= newfrag->size; 774 774 this = rb_entry(rb_next(&newfrag->rb), ··· 778 778 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); 779 779 } 780 780 781 - /* 781 + /* 782 782 * 'This' node is not the hole so it obsoletes the new fragment 783 783 * either fully or partially. 784 784 */ ··· 791 791 goto out_ok; 792 792 } else { 793 793 struct jffs2_node_frag *new_this; 794 - 794 + 795 795 /* 'This' node obsoletes the beginning of the new node */ 796 796 dbg_fragtree2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size); 797 797 798 798 ref_flag = REF_NORMAL; 799 - 799 + 800 800 fn_size -= this->ofs + this->size - fn_ofs; 801 801 fn_ofs = this->ofs + this->size; 802 802 dbg_fragtree2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size); 803 - 803 + 804 804 new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb); 805 805 if (!new_this) { 806 - /* 806 + /* 807 807 * There is no next fragment. Add the rest of 808 808 * the new node as the right-hand child. 809 809 */ ··· 813 813 return err; 814 814 checked = 1; 815 815 } 816 - 816 + 817 817 fn->frags += 1; 818 818 newfrag = new_fragment(fn, fn_ofs, fn_size); 819 819 if (unlikely(!newfrag)) ··· 821 821 822 822 dbg_fragtree2("there are no more fragments, insert %#04x-%#04x\n", 823 823 newfrag->ofs, newfrag->ofs + newfrag->size); 824 - rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 824 + rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 825 825 rb_insert_color(&newfrag->rb, root); 826 826 goto out_ok; 827 827 } else { ··· 862 862 863 863 /* During mount, this needs no locking. During normal operation, its 864 864 callers want to do other stuff while still holding the inocache_lock. 865 - Rather than introducing special case get_ino_cache functions or 865 + Rather than introducing special case get_ino_cache functions or 866 866 callbacks, we just let the caller do the locking itself. */ 867 - 867 + 868 868 struct jffs2_inode_cache *jffs2_get_ino_cache(struct jffs2_sb_info *c, uint32_t ino) 869 869 { 870 870 struct jffs2_inode_cache *ret; ··· 873 873 while (ret && ret->ino < ino) { 874 874 ret = ret->next; 875 875 } 876 - 876 + 877 877 if (ret && ret->ino != ino) 878 878 ret = NULL; 879 879 ··· 907 907 908 908 dbg_inocache("del %p (ino #%u)\n", old, old->ino); 909 909 spin_lock(&c->inocache_lock); 910 - 910 + 911 911 prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE]; 912 - 912 + 913 913 while ((*prev) && (*prev)->ino < old->ino) { 914 914 prev = &(*prev)->next; 915 915 } ··· 919 919 920 920 /* Free it now unless it's in READING or CLEARING state, which 921 921 are the transitions upon read_inode() and clear_inode(). The 922 - rest of the time we know nobody else is looking at it, and 922 + rest of the time we know nobody else is looking at it, and 923 923 if it's held by read_inode() or clear_inode() they'll free it 924 924 for themselves. */ 925 925 if (old->state != INO_STATE_READING && old->state != INO_STATE_CLEARING) ··· 932 932 { 933 933 int i; 934 934 struct jffs2_inode_cache *this, *next; 935 - 935 + 936 936 for (i=0; i<INOCACHE_HASHSIZE; i++) { 937 937 this = c->inocache_list[i]; 938 938 while (this) { ··· 959 959 c->blocks[i].first_node = c->blocks[i].last_node = NULL; 960 960 } 961 961 } 962 - 962 + 963 963 struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset) 964 964 { 965 - /* The common case in lookup is that there will be a node 965 + /* The common case in lookup is that there will be a node 966 966 which precisely matches. So we go looking for that first */ 967 967 struct rb_node *next; 968 968 struct jffs2_node_frag *prev = NULL; ··· 993 993 if (prev) 994 994 dbg_fragtree2("no match. Returning frag %#04x-%#04x, closest previous\n", 995 995 prev->ofs, prev->ofs+prev->size); 996 - else 996 + else 997 997 dbg_fragtree2("returning NULL, empty fragtree\n"); 998 - 998 + 999 999 return prev; 1000 1000 } 1001 1001 ··· 1010 1010 return; 1011 1011 1012 1012 dbg_fragtree("killing\n"); 1013 - 1013 + 1014 1014 frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb)); 1015 1015 while(frag) { 1016 1016 if (frag->rb.rb_left) { ··· 1023 1023 } 1024 1024 1025 1025 if (frag->node && !(--frag->node->frags)) { 1026 - /* Not a hole, and it's the final remaining frag 1026 + /* Not a hole, and it's the final remaining frag 1027 1027 of this node. Free the node */ 1028 1028 if (c) 1029 1029 jffs2_mark_node_obsolete(c, frag->node->raw); 1030 - 1030 + 1031 1031 jffs2_free_full_dnode(frag->node); 1032 1032 } 1033 1033 parent = frag_parent(frag); 1034 1034 if (parent) { 1035 1035 if (frag_left(parent) == frag) 1036 1036 parent->rb.rb_left = NULL; 1037 - else 1037 + else 1038 1038 parent->rb.rb_right = NULL; 1039 1039 } 1040 1040
+13 -13
fs/jffs2/nodelist.h
··· 58 58 #define je16_to_cpu(x) (le16_to_cpu(x.v16)) 59 59 #define je32_to_cpu(x) (le32_to_cpu(x.v32)) 60 60 #define jemode_to_cpu(x) (le32_to_cpu(jffs2_to_os_mode((x).m))) 61 - #else 61 + #else 62 62 #error wibble 63 63 #endif 64 64 ··· 68 68 /* 69 69 This is all we need to keep in-core for each raw node during normal 70 70 operation. As and when we do read_inode on a particular inode, we can 71 - scan the nodes which are listed for it and build up a proper map of 71 + scan the nodes which are listed for it and build up a proper map of 72 72 which nodes are currently valid. JFFSv1 always used to keep that whole 73 73 map in core for each inode. 74 74 */ ··· 85 85 86 86 /* flash_offset & 3 always has to be zero, because nodes are 87 87 always aligned at 4 bytes. So we have a couple of extra bits 88 - to play with, which indicate the node's status; see below: */ 88 + to play with, which indicate the node's status; see below: */ 89 89 #define REF_UNCHECKED 0 /* We haven't yet checked the CRC or built its inode */ 90 90 #define REF_OBSOLETE 1 /* Obsolete, can be completely ignored */ 91 91 #define REF_PRISTINE 2 /* Completely clean. GC without looking */ ··· 98 98 /* For each inode in the filesystem, we need to keep a record of 99 99 nlink, because it would be a PITA to scan the whole directory tree 100 100 at read_inode() time to calculate it, and to keep sufficient information 101 - in the raw_node_ref (basically both parent and child inode number for 101 + in the raw_node_ref (basically both parent and child inode number for 102 102 dirent nodes) would take more space than this does. We also keep 103 103 a pointer to the first physical node which is part of this inode, too. 104 104 */ ··· 128 128 #define INOCACHE_HASHSIZE 128 129 129 130 130 /* 131 - Larger representation of a raw node, kept in-core only when the 131 + Larger representation of a raw node, kept in-core only when the 132 132 struct inode for this particular ino is instantiated. 133 133 */ 134 134 ··· 138 138 uint32_t ofs; /* The offset to which the data of this node belongs */ 139 139 uint32_t size; 140 140 uint32_t frags; /* Number of fragments which currently refer 141 - to this node. When this reaches zero, 141 + to this node. When this reaches zero, 142 142 the node is obsolete. */ 143 143 }; 144 144 145 - /* 145 + /* 146 146 Even larger representation of a raw node, kept in-core only while 147 147 we're actually building up the original map of which nodes go where, 148 148 in read_inode() ··· 155 155 uint32_t data_crc; 156 156 uint32_t partial_crc; 157 157 uint32_t csize; 158 - }; 158 + }; 159 159 160 160 struct jffs2_full_dirent 161 161 { ··· 169 169 }; 170 170 171 171 /* 172 - Fragments - used to build a map of which raw node to obtain 172 + Fragments - used to build a map of which raw node to obtain 173 173 data from for each part of the ino 174 174 */ 175 175 struct jffs2_node_frag ··· 209 209 struct jffs2_raw_node_ref *ref) 210 210 { 211 211 uint32_t ref_end; 212 - 212 + 213 213 if (ref->next_phys) 214 214 ref_end = ref_offset(ref->next_phys); 215 215 else { ··· 264 264 #define VERYDIRTY(c, size) ((size) >= ((c)->sector_size / 2)) 265 265 266 266 /* check if dirty space is more than 255 Byte */ 267 - #define ISDIRTY(size) ((size) > sizeof (struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) 267 + #define ISDIRTY(size) ((size) > sizeof (struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) 268 268 269 269 #define PAD(x) (((x)+3)&~3) 270 270 ··· 341 341 struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode); 342 342 struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs, int alloc_mode); 343 343 int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 344 - struct jffs2_raw_inode *ri, unsigned char *buf, 344 + struct jffs2_raw_inode *ri, unsigned char *buf, 345 345 uint32_t offset, uint32_t writelen, uint32_t *retlen); 346 346 int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const char *name, int namelen); 347 347 int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name, int namelen, struct jffs2_inode_info *dead_f, uint32_t time); ··· 349 349 350 350 351 351 /* readinode.c */ 352 - int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 352 + int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 353 353 uint32_t ino, struct jffs2_raw_inode *latest_node); 354 354 int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); 355 355 void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f);
+29 -29
fs/jffs2/nodemgmt.c
··· 88 88 up(&c->alloc_sem); 89 89 return -ENOSPC; 90 90 } 91 - 91 + 92 92 /* Calc possibly available space. Possibly available means that we 93 93 * don't know, if unchecked size contains obsoleted nodes, which could give us some 94 94 * more usable space. This will affect the sum only once, as gc first finishes checking 95 95 * of nodes. 96 - + Return -ENOSPC, if the maximum possibly available space is less or equal than 96 + + Return -ENOSPC, if the maximum possibly available space is less or equal than 97 97 * blocksneeded * sector_size. 98 98 * This blocks endless gc looping on a filesystem, which is nearly full, even if 99 99 * the check above passes. ··· 118 118 c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, 119 119 c->free_size + c->dirty_size + c->wasted_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size)); 120 120 spin_unlock(&c->erase_completion_lock); 121 - 121 + 122 122 ret = jffs2_garbage_collect_pass(c); 123 123 if (ret) 124 124 return ret; ··· 183 183 jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); 184 184 list_add_tail(&jeb->list, &c->dirty_list); 185 185 } 186 - } else { 186 + } else { 187 187 D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", 188 188 jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); 189 189 list_add_tail(&jeb->list, &c->clean_list); ··· 197 197 static int jffs2_find_nextblock(struct jffs2_sb_info *c) 198 198 { 199 199 struct list_head *next; 200 - 200 + 201 201 /* Take the next block off the 'free' list */ 202 202 203 203 if (list_empty(&c->free_list)) { ··· 229 229 if (!c->nr_erasing_blocks) { 230 230 /* Ouch. We're in GC, or we wouldn't have got here. 231 231 And there's no space left. At all. */ 232 - printk(KERN_CRIT "Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n", 233 - c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no", 232 + printk(KERN_CRIT "Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n", 233 + c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no", 234 234 list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->erase_pending_list)?"yes":"no"); 235 235 return -ENOSPC; 236 236 } ··· 250 250 list_del(next); 251 251 c->nextblock = list_entry(next, struct jffs2_eraseblock, list); 252 252 c->nr_free_blocks--; 253 - 253 + 254 254 jffs2_sum_reset_collected(c->summary); /* reset collected summary */ 255 255 256 256 D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); ··· 354 354 355 355 if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size && 356 356 !jeb->first_node->next_in_ino) { 357 - /* Only node in it beforehand was a CLEANMARKER node (we think). 357 + /* Only node in it beforehand was a CLEANMARKER node (we think). 358 358 So mark it obsolete now that there's going to be another node 359 - in the block. This will reduce used_size to zero but We've 359 + in the block. This will reduce used_size to zero but We've 360 360 already set c->nextblock so that jffs2_mark_node_obsolete() 361 361 won't try to refile it to the dirty_list. 362 362 */ ··· 376 376 * @len: length of this physical node 377 377 * @dirty: dirty flag for new node 378 378 * 379 - * Should only be used to report nodes for which space has been allocated 379 + * Should only be used to report nodes for which space has been allocated 380 380 * by jffs2_reserve_space. 381 381 * 382 382 * Must be called with the alloc_sem held. 383 383 */ 384 - 384 + 385 385 int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new) 386 386 { 387 387 struct jffs2_eraseblock *jeb; ··· 488 488 489 489 if (jffs2_can_mark_obsolete(c) && !jffs2_is_readonly(c) && 490 490 !(c->flags & (JFFS2_SB_FLAG_SCANNING | JFFS2_SB_FLAG_BUILDING))) { 491 - /* Hm. This may confuse static lock analysis. If any of the above 492 - three conditions is false, we're going to return from this 491 + /* Hm. This may confuse static lock analysis. If any of the above 492 + three conditions is false, we're going to return from this 493 493 function without actually obliterating any nodes or freeing 494 494 any jffs2_raw_node_refs. So we don't need to stop erases from 495 495 happening, or protect against people holding an obsolete ··· 546 546 D1(printk(KERN_DEBUG "Wasting\n")); 547 547 addedsize = 0; 548 548 jeb->wasted_size += ref_totlen(c, jeb, ref); 549 - c->wasted_size += ref_totlen(c, jeb, ref); 549 + c->wasted_size += ref_totlen(c, jeb, ref); 550 550 } 551 551 ref->flash_offset = ref_offset(ref) | REF_OBSOLETE; 552 - 552 + 553 553 jffs2_dbg_acct_sanity_check_nolock(c, jeb); 554 554 jffs2_dbg_acct_paranoia_check_nolock(c, jeb); 555 555 556 556 if (c->flags & JFFS2_SB_FLAG_SCANNING) { 557 557 /* Flash scanning is in progress. Don't muck about with the block 558 558 lists because they're not ready yet, and don't actually 559 - obliterate nodes that look obsolete. If they weren't 559 + obliterate nodes that look obsolete. If they weren't 560 560 marked obsolete on the flash at the time they _became_ 561 561 obsolete, there was probably a reason for that. */ 562 562 spin_unlock(&c->erase_completion_lock); ··· 590 590 immediately reused, and we spread the load a bit. */ 591 591 D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); 592 592 list_add_tail(&jeb->list, &c->erasable_list); 593 - } 593 + } 594 594 } 595 595 D1(printk(KERN_DEBUG "Done OK\n")); 596 596 } else if (jeb == c->gcblock) { ··· 608 608 list_add_tail(&jeb->list, &c->very_dirty_list); 609 609 } else { 610 610 D1(printk(KERN_DEBUG "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n", 611 - jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); 612 - } 611 + jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); 612 + } 613 613 614 614 spin_unlock(&c->erase_completion_lock); 615 615 ··· 656 656 657 657 /* Nodes which have been marked obsolete no longer need to be 658 658 associated with any inode. Remove them from the per-inode list. 659 - 660 - Note we can't do this for NAND at the moment because we need 659 + 660 + Note we can't do this for NAND at the moment because we need 661 661 obsolete dirent nodes to stay on the lists, because of the 662 662 horridness in jffs2_garbage_collect_deletion_dirent(). Also 663 - because we delete the inocache, and on NAND we need that to 663 + because we delete the inocache, and on NAND we need that to 664 664 stay around until all the nodes are actually erased, in order 665 665 to stop us from giving the same inode number to another newly 666 666 created inode. */ ··· 689 689 if (ref->next_phys && ref_obsolete(ref->next_phys) && 690 690 !ref->next_phys->next_in_ino) { 691 691 struct jffs2_raw_node_ref *n = ref->next_phys; 692 - 692 + 693 693 spin_lock(&c->erase_completion_lock); 694 694 695 695 ref->__totlen += n->__totlen; ··· 703 703 704 704 jffs2_free_raw_node_ref(n); 705 705 } 706 - 706 + 707 707 /* Also merge with the previous node in the list, if there is one 708 708 and that one is obsolete */ 709 709 if (ref != jeb->first_node ) { ··· 713 713 714 714 while (p->next_phys != ref) 715 715 p = p->next_phys; 716 - 716 + 717 717 if (ref_obsolete(p) && !ref->next_in_ino) { 718 718 p->__totlen += ref->__totlen; 719 719 if (jeb->last_node == ref) { ··· 753 753 */ 754 754 dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size; 755 755 756 - if (c->nr_free_blocks + c->nr_erasing_blocks < c->resv_blocks_gctrigger && 757 - (dirty > c->nospc_dirty_size)) 756 + if (c->nr_free_blocks + c->nr_erasing_blocks < c->resv_blocks_gctrigger && 757 + (dirty > c->nospc_dirty_size)) 758 758 ret = 1; 759 759 760 - D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x: %s\n", 760 + D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x: %s\n", 761 761 c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, ret?"yes":"no")); 762 762 763 763 return ret;
+4 -4
fs/jffs2/os-linux.h
··· 191 191 struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, 192 192 int inum, int nlink); 193 193 194 - unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, 195 - struct jffs2_inode_info *f, 194 + unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, 195 + struct jffs2_inode_info *f, 196 196 unsigned long offset, 197 197 unsigned long *priv); 198 198 void jffs2_gc_release_page(struct jffs2_sb_info *c, 199 199 unsigned char *pg, 200 200 unsigned long *priv); 201 201 void jffs2_flash_cleanup(struct jffs2_sb_info *c); 202 - 202 + 203 203 204 204 /* writev.c */ 205 - int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, 205 + int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, 206 206 unsigned long count, loff_t to, size_t *retlen); 207 207 int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, 208 208 size_t *retlen, const u_char *buf);
+8 -8
fs/jffs2/read.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: read.c,v 1.41 2005/07/22 10:32:08 dedekind Exp $ 10 + * $Id: read.c,v 1.42 2005/11/07 11:14:41 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 43 43 } 44 44 if (readlen != sizeof(*ri)) { 45 45 jffs2_free_raw_inode(ri); 46 - printk(KERN_WARNING "Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", 46 + printk(KERN_WARNING "Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", 47 47 ref_offset(fd->raw), sizeof(*ri), readlen); 48 48 return -EIO; 49 49 } ··· 61 61 } 62 62 /* There was a bug where we wrote hole nodes out with csize/dsize 63 63 swapped. Deal with it */ 64 - if (ri->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(ri->dsize) && 64 + if (ri->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(ri->dsize) && 65 65 je32_to_cpu(ri->csize)) { 66 66 ri->dsize = ri->csize; 67 67 ri->csize = cpu_to_je32(0); ··· 74 74 goto out_ri; 75 75 }); 76 76 77 - 77 + 78 78 if (ri->compr == JFFS2_COMPR_ZERO) { 79 79 memset(buf, 0, len); 80 80 goto out_ri; ··· 82 82 83 83 /* Cases: 84 84 Reading whole node and it's uncompressed - read directly to buffer provided, check CRC. 85 - Reading whole node and it's compressed - read into comprbuf, check CRC and decompress to buffer provided 86 - Reading partial node and it's uncompressed - read into readbuf, check CRC, and copy 85 + Reading whole node and it's compressed - read into comprbuf, check CRC and decompress to buffer provided 86 + Reading partial node and it's uncompressed - read into readbuf, check CRC, and copy 87 87 Reading partial node and it's compressed - read into readbuf, check checksum, decompress to decomprbuf and copy 88 88 */ 89 89 if (ri->compr == JFFS2_COMPR_NONE && len == je32_to_cpu(ri->dsize)) { ··· 129 129 D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc)); 130 130 if (ri->compr != JFFS2_COMPR_NONE) { 131 131 D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n", 132 - je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); 132 + je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); 133 133 ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize)); 134 134 if (ret) { 135 135 printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret); ··· 191 191 } else { 192 192 uint32_t readlen; 193 193 uint32_t fragofs; /* offset within the frag to start reading */ 194 - 194 + 195 195 fragofs = offset - frag->ofs; 196 196 readlen = min(frag->size - fragofs, end - offset); 197 197 D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%08x (%d)\n",
+42 -42
fs/jffs2/readinode.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: readinode.c,v 1.142 2005/09/20 14:27:34 dedekind Exp $ 10 + * $Id: readinode.c,v 1.143 2005/11/07 11:14:41 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 116 116 uint32_t *latest_mctime, uint32_t *mctime_ver) 117 117 { 118 118 struct jffs2_full_dirent *fd; 119 - 119 + 120 120 /* The direntry nodes are checked during the flash scanning */ 121 121 BUG_ON(ref_flags(ref) == REF_UNCHECKED); 122 122 /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */ 123 123 BUG_ON(ref_obsolete(ref)); 124 - 124 + 125 125 /* Sanity check */ 126 126 if (unlikely(PAD((rd->nsize + sizeof(*rd))) != PAD(je32_to_cpu(rd->totlen)))) { 127 127 JFFS2_ERROR("illegal nsize in node at %#08x: nsize %#02x, totlen %#04x\n", 128 128 ref_offset(ref), rd->nsize, je32_to_cpu(rd->totlen)); 129 129 return 1; 130 130 } 131 - 131 + 132 132 fd = jffs2_alloc_full_dirent(rd->nsize + 1); 133 133 if (unlikely(!fd)) 134 134 return -ENOMEM; ··· 144 144 *latest_mctime = je32_to_cpu(rd->mctime); 145 145 } 146 146 147 - /* 147 + /* 148 148 * Copy as much of the name as possible from the raw 149 149 * dirent we've already read from the flash. 150 150 */ 151 151 if (read > sizeof(*rd)) 152 152 memcpy(&fd->name[0], &rd->name[0], 153 153 min_t(uint32_t, rd->nsize, (read - sizeof(*rd)) )); 154 - 154 + 155 155 /* Do we need to copy any more of the name directly from the flash? */ 156 156 if (rd->nsize + sizeof(*rd) > read) { 157 157 /* FIXME: point() */ 158 158 int err; 159 159 int already = read - sizeof(*rd); 160 - 161 - err = jffs2_flash_read(c, (ref_offset(ref)) + read, 160 + 161 + err = jffs2_flash_read(c, (ref_offset(ref)) + read, 162 162 rd->nsize - already, &read, &fd->name[already]); 163 163 if (unlikely(read != rd->nsize - already) && likely(!err)) 164 164 return -EIO; 165 - 165 + 166 166 if (unlikely(err)) { 167 167 JFFS2_ERROR("read remainder of name: error %d\n", err); 168 168 jffs2_free_full_dirent(fd); 169 169 return -EIO; 170 170 } 171 171 } 172 - 172 + 173 173 fd->nhash = full_name_hash(fd->name, rd->nsize); 174 174 fd->next = NULL; 175 175 fd->name[rd->nsize] = '\0'; 176 - 176 + 177 177 /* 178 178 * Wheee. We now have a complete jffs2_full_dirent structure, with 179 - * the name in it and everything. Link it into the list 179 + * the name in it and everything. Link it into the list 180 180 */ 181 181 jffs2_add_fd_to_list(c, fd, fdp); 182 182 ··· 198 198 struct jffs2_tmp_dnode_info *tn; 199 199 uint32_t len, csize; 200 200 int ret = 1; 201 - 201 + 202 202 /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */ 203 203 BUG_ON(ref_obsolete(ref)); 204 204 ··· 210 210 211 211 tn->partial_crc = 0; 212 212 csize = je32_to_cpu(rd->csize); 213 - 213 + 214 214 /* If we've never checked the CRCs on this node, check them now */ 215 215 if (ref_flags(ref) == REF_UNCHECKED) { 216 216 uint32_t crc; ··· 221 221 ref_offset(ref), je32_to_cpu(rd->node_crc), crc); 222 222 goto free_out; 223 223 } 224 - 224 + 225 225 /* Sanity checks */ 226 226 if (unlikely(je32_to_cpu(rd->offset) > je32_to_cpu(rd->isize)) || 227 227 unlikely(PAD(je32_to_cpu(rd->csize) + sizeof(*rd)) != PAD(je32_to_cpu(rd->totlen)))) { ··· 313 313 ret = -ENOMEM; 314 314 goto free_out; 315 315 } 316 - 316 + 317 317 tn->version = je32_to_cpu(rd->version); 318 318 tn->fn->ofs = je32_to_cpu(rd->offset); 319 319 tn->data_crc = je32_to_cpu(rd->data_crc); 320 320 tn->csize = csize; 321 321 tn->fn->raw = ref; 322 - 322 + 323 323 /* There was a bug where we wrote hole nodes out with 324 324 csize/dsize swapped. Deal with it */ 325 325 if (rd->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(rd->dsize) && csize) ··· 329 329 330 330 dbg_readinode("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n", 331 331 ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize); 332 - 332 + 333 333 jffs2_add_tn_to_tree(tn, tnp); 334 334 335 335 return 0; ··· 351 351 { 352 352 /* We don't mark unknown nodes as REF_UNCHECKED */ 353 353 BUG_ON(ref_flags(ref) == REF_UNCHECKED); 354 - 354 + 355 355 un->nodetype = cpu_to_je16(JFFS2_NODE_ACCURATE | je16_to_cpu(un->nodetype)); 356 356 357 357 if (crc32(0, un, sizeof(struct jffs2_unknown_node) - 4) != je32_to_cpu(un->hdr_crc)) { ··· 423 423 bufstart = buf + *rdlen; 424 424 len = right_size - *rdlen; 425 425 } 426 - 426 + 427 427 dbg_readinode("read more %d bytes\n", len); 428 428 429 429 err = jffs2_flash_read(c, offs, len, &retlen, bufstart); ··· 432 432 "error code: %d.\n", len, offs, err); 433 433 return err; 434 434 } 435 - 435 + 436 436 if (retlen < len) { 437 437 JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", 438 438 offs, retlen, len); ··· 460 460 int len, err; 461 461 462 462 *mctime_ver = 0; 463 - 463 + 464 464 dbg_readinode("ino #%u\n", f->inocache->ino); 465 465 466 466 if (jffs2_is_writebuffered(c)) { ··· 487 487 buf = kmalloc(len, GFP_KERNEL); 488 488 if (!buf) 489 489 return -ENOMEM; 490 - 490 + 491 491 spin_lock(&c->erase_completion_lock); 492 492 valid_ref = jffs2_first_valid_node(f->inocache->nodes); 493 493 if (!valid_ref && f->inocache->ino != 1) ··· 514 514 * size = JFFS2_MIN_NODE_HEADER. 515 515 */ 516 516 if (jffs2_is_writebuffered(c)) { 517 - /* 517 + /* 518 518 * We treat 'buf' as 2 adjacent wbufs. We want to 519 519 * adjust bufstart such as it points to the 520 520 * beginning of the node within this wbuf. ··· 540 540 JFFS2_ERROR("can not read %d bytes from 0x%08x, " "error code: %d.\n", len, ref_offset(ref), err); 541 541 goto free_out; 542 542 } 543 - 543 + 544 544 if (retlen < len) { 545 545 JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ref_offset(ref), retlen, len); 546 546 err = -EIO; 547 547 goto free_out; 548 548 } 549 - 549 + 550 550 node = (union jffs2_node_union *)bufstart; 551 - 551 + 552 552 switch (je16_to_cpu(node->u.nodetype)) { 553 - 553 + 554 554 case JFFS2_NODETYPE_DIRENT: 555 555 556 556 if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_dirent)) { ··· 558 558 if (unlikely(err)) 559 559 goto free_out; 560 560 } 561 - 561 + 562 562 err = read_direntry(c, ref, &node->d, retlen, &ret_fd, latest_mctime, mctime_ver); 563 563 if (err == 1) { 564 564 jffs2_mark_node_obsolete(c, ref); 565 565 break; 566 566 } else if (unlikely(err)) 567 567 goto free_out; 568 - 568 + 569 569 if (je32_to_cpu(node->d.version) > *highest_version) 570 570 *highest_version = je32_to_cpu(node->d.version); 571 571 572 572 break; 573 573 574 574 case JFFS2_NODETYPE_INODE: 575 - 575 + 576 576 if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_inode)) { 577 577 err = read_more(c, ref, sizeof(struct jffs2_raw_inode), &len, buf, bufstart); 578 578 if (unlikely(err)) ··· 588 588 589 589 if (je32_to_cpu(node->i.version) > *highest_version) 590 590 *highest_version = je32_to_cpu(node->i.version); 591 - 591 + 592 592 break; 593 593 594 594 default: ··· 597 597 if (unlikely(err)) 598 598 goto free_out; 599 599 } 600 - 600 + 601 601 err = read_unknown(c, ref, &node->u); 602 602 if (err == 1) { 603 603 jffs2_mark_node_obsolete(c, ref); ··· 625 625 return err; 626 626 } 627 627 628 - static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, 628 + static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, 629 629 struct jffs2_inode_info *f, 630 630 struct jffs2_raw_inode *latest_node) 631 631 { ··· 677 677 ret = 0; /* Prevent freeing the metadata update node */ 678 678 } else 679 679 jffs2_mark_node_obsolete(c, fn->raw); 680 - 680 + 681 681 BUG_ON(rb->rb_left); 682 682 if (rb->rb_parent && rb->rb_parent->rb_left == rb) { 683 683 /* We were then left-hand child of our parent. We need ··· 763 763 } 764 764 break; 765 765 766 - 766 + 767 767 case S_IFREG: 768 768 /* If it was a regular file, truncate it to the latest node's isize */ 769 769 jffs2_truncate_fragtree(c, &f->fragtree, je32_to_cpu(latest_node->isize)); ··· 788 788 jffs2_do_clear_inode(c, f); 789 789 return -ENOMEM; 790 790 } 791 - 791 + 792 792 ret = jffs2_flash_read(c, ref_offset(fn->raw) + sizeof(*latest_node), 793 793 je32_to_cpu(latest_node->csize), &retlen, (char *)f->target); 794 - 794 + 795 795 if (ret || retlen != je32_to_cpu(latest_node->csize)) { 796 796 if (retlen != je32_to_cpu(latest_node->csize)) 797 797 ret = -EIO; ··· 805 805 f->target[je32_to_cpu(latest_node->csize)] = '\0'; 806 806 dbg_readinode("symlink's target '%s' cached\n", f->target); 807 807 } 808 - 808 + 809 809 /* fall through... */ 810 810 811 811 case S_IFBLK: ··· 848 848 } 849 849 850 850 /* Scan the list of all nodes present for this ino, build map of versions, etc. */ 851 - int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 851 + int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 852 852 uint32_t ino, struct jffs2_raw_inode *latest_node) 853 853 { 854 854 dbg_readinode("read inode #%u\n", ino); ··· 864 864 case INO_STATE_CHECKEDABSENT: 865 865 f->inocache->state = INO_STATE_READING; 866 866 break; 867 - 867 + 868 868 case INO_STATE_CHECKING: 869 869 case INO_STATE_GC: 870 870 /* If it's in either of these states, we need ··· 957 957 kfree(f->target); 958 958 f->target = NULL; 959 959 } 960 - 960 + 961 961 fds = f->dents; 962 962 while(fds) { 963 963 fd = fds;
+26 -26
fs/jffs2/scan.c
··· 38 38 static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 39 39 unsigned char *buf, uint32_t buf_size, struct jffs2_summary *s); 40 40 41 - /* These helper functions _must_ increase ofs and also do the dirty/used space accounting. 41 + /* These helper functions _must_ increase ofs and also do the dirty/used space accounting. 42 42 * Returning an error will abort the mount - bad checksums etc. should just mark the space 43 43 * as dirty. 44 44 */ 45 - static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 45 + static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 46 46 struct jffs2_raw_inode *ri, uint32_t ofs, struct jffs2_summary *s); 47 47 static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 48 48 struct jffs2_raw_dirent *rd, uint32_t ofs, struct jffs2_summary *s); ··· 131 131 /* Now decide which list to put it on */ 132 132 switch(ret) { 133 133 case BLK_STATE_ALLFF: 134 - /* 135 - * Empty block. Since we can't be sure it 134 + /* 135 + * Empty block. Since we can't be sure it 136 136 * was entirely erased, we just queue it for erase 137 137 * again. It will be marked as such when the erase 138 138 * is complete. Meanwhile we still count it as empty ··· 234 234 } 235 235 #ifdef CONFIG_JFFS2_FS_WRITEBUFFER 236 236 if (!jffs2_can_mark_obsolete(c) && c->nextblock && (c->nextblock->free_size % c->wbuf_pagesize)) { 237 - /* If we're going to start writing into a block which already 237 + /* If we're going to start writing into a block which already 238 238 contains data, and the end of the data isn't page-aligned, 239 239 skip a little and align it. */ 240 240 ··· 250 250 } 251 251 #endif 252 252 if (c->nr_erasing_blocks) { 253 - if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { 253 + if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { 254 254 printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); 255 255 printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks); 256 256 ret = -EIO; ··· 263 263 if (buf_size) 264 264 kfree(flashbuf); 265 265 #ifndef __ECOS 266 - else 266 + else 267 267 c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size); 268 268 #endif 269 269 return ret; ··· 391 391 if (err) 392 392 return err; 393 393 } 394 - 394 + 395 395 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */ 396 396 ofs = 0; 397 397 ··· 431 431 432 432 dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset); 433 433 434 - scan_more: 434 + scan_more: 435 435 while(ofs < jeb->offset + c->sector_size) { 436 436 437 437 jffs2_dbg_acct_paranoia_check_nolock(c, jeb); ··· 496 496 497 497 /* If we're only checking the beginning of a block with a cleanmarker, 498 498 bail now */ 499 - if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && 499 + if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && 500 500 c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_phys) { 501 501 D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); 502 502 return BLK_STATE_CLEANMARKER; ··· 505 505 /* See how much more there is to read in this eraseblock... */ 506 506 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); 507 507 if (!buf_len) { 508 - /* No more to read. Break out of main loop without marking 508 + /* No more to read. Break out of main loop without marking 509 509 this range of empty space as dirty (because it's not) */ 510 510 D1(printk(KERN_DEBUG "Empty flash at %08x runs to end of block. Treating as free_space\n", 511 511 empty_start)); ··· 540 540 } 541 541 if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) { 542 542 /* OK. We're out of possibilities. Whinge and move on */ 543 - noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", 544 - JFFS2_MAGIC_BITMASK, ofs, 543 + noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", 544 + JFFS2_MAGIC_BITMASK, ofs, 545 545 je16_to_cpu(node->magic)); 546 546 DIRTY_SPACE(4); 547 547 ofs += 4; ··· 556 556 if (hdr_crc != je32_to_cpu(node->hdr_crc)) { 557 557 noisy_printk(&noise, "jffs2_scan_eraseblock(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n", 558 558 ofs, je16_to_cpu(node->magic), 559 - je16_to_cpu(node->nodetype), 559 + je16_to_cpu(node->nodetype), 560 560 je32_to_cpu(node->totlen), 561 561 je32_to_cpu(node->hdr_crc), 562 562 hdr_crc); ··· 565 565 continue; 566 566 } 567 567 568 - if (ofs + je32_to_cpu(node->totlen) > 568 + if (ofs + je32_to_cpu(node->totlen) > 569 569 jeb->offset + c->sector_size) { 570 570 /* Eep. Node goes over the end of the erase block. */ 571 571 printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", ··· 600 600 if (err) return err; 601 601 ofs += PAD(je32_to_cpu(node->totlen)); 602 602 break; 603 - 603 + 604 604 case JFFS2_NODETYPE_DIRENT: 605 605 if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { 606 606 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); ··· 620 620 case JFFS2_NODETYPE_CLEANMARKER: 621 621 D1(printk(KERN_DEBUG "CLEANMARKER node found at 0x%08x\n", ofs)); 622 622 if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { 623 - printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", 623 + printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", 624 624 ofs, je32_to_cpu(node->totlen), c->cleanmarker_size); 625 625 DIRTY_SPACE(PAD(sizeof(struct jffs2_unknown_node))); 626 626 ofs += PAD(sizeof(struct jffs2_unknown_node)); ··· 639 639 marker_ref->flash_offset = ofs | REF_NORMAL; 640 640 marker_ref->__totlen = c->cleanmarker_size; 641 641 jeb->first_node = jeb->last_node = marker_ref; 642 - 642 + 643 643 USED_SPACE(PAD(c->cleanmarker_size)); 644 644 ofs += PAD(c->cleanmarker_size); 645 645 } ··· 690 690 } 691 691 } 692 692 693 - D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x\n", jeb->offset, 693 + D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x\n", jeb->offset, 694 694 jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size)); 695 695 696 696 /* mark_node_obsolete can add to wasted !! */ ··· 730 730 return ic; 731 731 } 732 732 733 - static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 733 + static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 734 734 struct jffs2_raw_inode *ri, uint32_t ofs, struct jffs2_summary *s) 735 735 { 736 736 struct jffs2_raw_node_ref *raw; ··· 740 740 D1(printk(KERN_DEBUG "jffs2_scan_inode_node(): Node at 0x%08x\n", ofs)); 741 741 742 742 /* We do very little here now. Just check the ino# to which we should attribute 743 - this node; we can do all the CRC checking etc. later. There's a tradeoff here -- 743 + this node; we can do all the CRC checking etc. later. There's a tradeoff here -- 744 744 we used to scan the flash once only, reading everything we want from it into 745 745 memory, then building all our in-core data structures and freeing the extra 746 746 information. Now we allow the first part of the mount to complete a lot quicker, 747 - but we have to go _back_ to the flash in order to finish the CRC checking, etc. 747 + but we have to go _back_ to the flash in order to finish the CRC checking, etc. 748 748 Which means that the _full_ amount of time to get to proper write mode with GC 749 749 operational may actually be _longer_ than before. Sucks to be me. */ 750 750 ··· 790 790 jeb->last_node->next_phys = raw; 791 791 jeb->last_node = raw; 792 792 793 - D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", 793 + D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", 794 794 je32_to_cpu(ri->ino), je32_to_cpu(ri->version), 795 795 je32_to_cpu(ri->offset), 796 796 je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize))); ··· 806 806 return 0; 807 807 } 808 808 809 - static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 809 + static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 810 810 struct jffs2_raw_dirent *rd, uint32_t ofs, struct jffs2_summary *s) 811 811 { 812 812 struct jffs2_raw_node_ref *raw; ··· 840 840 crc = crc32(0, fd->name, rd->nsize); 841 841 if (crc != je32_to_cpu(rd->name_crc)) { 842 842 printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", 843 - ofs, je32_to_cpu(rd->name_crc), crc); 843 + ofs, je32_to_cpu(rd->name_crc), crc); 844 844 D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino))); 845 845 jffs2_free_full_dirent(fd); 846 846 /* FIXME: Why do we believe totlen? */ ··· 860 860 jffs2_free_raw_node_ref(raw); 861 861 return -ENOMEM; 862 862 } 863 - 863 + 864 864 raw->__totlen = PAD(je32_to_cpu(rd->totlen)); 865 865 raw->flash_offset = ofs | REF_PRISTINE; 866 866 raw->next_phys = NULL;
+4 -4
fs/jffs2/summary.c
··· 82 82 je32_to_cpu(item->d.ino)); 83 83 break; 84 84 default: 85 - JFFS2_WARNING("UNKNOWN node type %u\n", 85 + JFFS2_WARNING("UNKNOWN node type %u\n", 86 86 je16_to_cpu(item->u.nodetype)); 87 87 return 1; 88 88 } ··· 174 174 s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; 175 175 } 176 176 177 - int jffs2_sum_is_disabled(struct jffs2_summary *s) 177 + int jffs2_sum_is_disabled(struct jffs2_summary *s) 178 178 { 179 179 return (s->sum_size == JFFS2_SUMMARY_NOSUM_SIZE); 180 180 } ··· 609 609 sdrnt_ptr->nsize = c->summary->sum_list_head->d.nsize; 610 610 sdrnt_ptr->type = c->summary->sum_list_head->d.type; 611 611 612 - memcpy(sdrnt_ptr->name, c->summary->sum_list_head->d.name, 612 + memcpy(sdrnt_ptr->name, c->summary->sum_list_head->d.name, 613 613 c->summary->sum_list_head->d.nsize); 614 614 615 615 wpage += JFFS2_SUMMARY_DIRENT_SIZE(c->summary->sum_list_head->d.nsize); ··· 687 687 datasize = c->summary->sum_size + sizeof(struct jffs2_sum_marker); 688 688 infosize = sizeof(struct jffs2_raw_summary) + datasize; 689 689 padsize = jeb->free_size - infosize; 690 - infosize += padsize; 690 + infosize += padsize; 691 691 datasize += padsize; 692 692 693 693 /* Is there enough space for summary? */
+8 -8
fs/jffs2/super.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: super.c,v 1.109 2005/09/07 08:34:55 havasi Exp $ 10 + * $Id: super.c,v 1.110 2005/11/07 11:14:42 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 62 62 63 63 down(&c->alloc_sem); 64 64 jffs2_flush_wbuf_pad(c); 65 - up(&c->alloc_sem); 65 + up(&c->alloc_sem); 66 66 return 0; 67 67 } 68 68 ··· 112 112 } 113 113 114 114 static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type, 115 - int flags, const char *dev_name, 115 + int flags, const char *dev_name, 116 116 void *data, struct mtd_info *mtd) 117 117 { 118 118 struct super_block *sb; ··· 172 172 } 173 173 174 174 static struct super_block *jffs2_get_sb_mtdnr(struct file_system_type *fs_type, 175 - int flags, const char *dev_name, 175 + int flags, const char *dev_name, 176 176 void *data, int mtdnr) 177 177 { 178 178 struct mtd_info *mtd; ··· 201 201 202 202 /* The preferred way of mounting in future; especially when 203 203 CONFIG_BLK_DEV is implemented - we specify the underlying 204 - MTD device by number or by name, so that we don't require 204 + MTD device by number or by name, so that we don't require 205 205 block device support to be present in the kernel. */ 206 206 207 207 /* FIXME: How to do the root fs this way? */ ··· 225 225 } else if (isdigit(dev_name[3])) { 226 226 /* Mount by MTD device number name */ 227 227 char *endptr; 228 - 228 + 229 229 mtdnr = simple_strtoul(dev_name+3, &endptr, 0); 230 230 if (!*endptr) { 231 231 /* It was a valid number */ ··· 235 235 } 236 236 } 237 237 238 - /* Try the old way - the hack where we allowed users to mount 238 + /* Try the old way - the hack where we allowed users to mount 239 239 /dev/mtdblock$(n) but didn't actually _use_ the blkdev */ 240 240 241 241 err = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); ··· 376 376 377 377 MODULE_DESCRIPTION("The Journalling Flash File System, v2"); 378 378 MODULE_AUTHOR("Red Hat, Inc."); 379 - MODULE_LICENSE("GPL"); // Actually dual-licensed, but it doesn't matter for 379 + MODULE_LICENSE("GPL"); // Actually dual-licensed, but it doesn't matter for 380 380 // the sake of this tag. It's Free Software.
+4 -4
fs/jffs2/symlink.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: symlink.c,v 1.18 2005/11/06 11:03:27 gleixner Exp $ 10 + * $Id: symlink.c,v 1.19 2005/11/07 11:14:42 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 21 21 static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd); 22 22 23 23 struct inode_operations jffs2_symlink_inode_operations = 24 - { 24 + { 25 25 .readlink = generic_readlink, 26 26 .follow_link = jffs2_follow_link, 27 27 .setattr = jffs2_setattr ··· 44 44 * stopped using our f->target string which we provide by means of 45 45 * nd_set_link() call. 46 46 */ 47 - 47 + 48 48 if (!p) { 49 49 printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n"); 50 50 p = ERR_PTR(-EIO); ··· 52 52 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target)); 53 53 54 54 nd_set_link(nd, p); 55 - 55 + 56 56 /* 57 57 * We will unlock the f->sem mutex but VFS will use the f->target string. This is safe 58 58 * since the only way that may cause f->target to be changed is iput() operation.
+64 -64
fs/jffs2/wbuf.c
··· 188 188 /* Find the first node to be recovered, by skipping over every 189 189 node which ends before the wbuf starts, or which is obsolete. */ 190 190 first_raw = &jeb->first_node; 191 - while (*first_raw && 191 + while (*first_raw && 192 192 (ref_obsolete(*first_raw) || 193 193 (ref_offset(*first_raw)+ref_totlen(c, jeb, *first_raw)) < c->wbuf_ofs)) { 194 194 D1(printk(KERN_DEBUG "Skipping node at 0x%08x(%d)-0x%08x which is either before 0x%08x or obsolete\n", ··· 237 237 ret = c->mtd->read_ecc(c->mtd, start, c->wbuf_ofs - start, &retlen, buf, NULL, c->oobinfo); 238 238 else 239 239 ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf); 240 - 240 + 241 241 if (ret == -EBADMSG && retlen == c->wbuf_ofs - start) { 242 242 /* ECC recovered */ 243 243 ret = 0; ··· 274 274 if (end-start >= c->wbuf_pagesize) { 275 275 /* Need to do another write immediately, but it's possible 276 276 that this is just because the wbuf itself is completely 277 - full, and there's nothing earlier read back from the 278 - flash. Hence 'buf' isn't necessarily what we're writing 277 + full, and there's nothing earlier read back from the 278 + flash. Hence 'buf' isn't necessarily what we're writing 279 279 from. */ 280 280 unsigned char *rewrite_buf = buf?:c->wbuf; 281 281 uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); 282 282 283 283 D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", 284 284 towrite, ofs)); 285 - 285 + 286 286 #ifdef BREAKMEHEADER 287 287 static int breakme; 288 288 if (breakme++ == 20) { ··· 434 434 this happens, if we have a change to a new block, 435 435 or if fsync forces us to flush the writebuffer. 436 436 if we have a switch to next page, we will not have 437 - enough remaining space for this. 437 + enough remaining space for this. 438 438 */ 439 439 if (pad ) { 440 440 c->wbuf_len = PAD(c->wbuf_len); ··· 442 442 /* Pad with JFFS2_DIRTY_BITMASK initially. this helps out ECC'd NOR 443 443 with 8 byte page size */ 444 444 memset(c->wbuf + c->wbuf_len, 0, c->wbuf_pagesize - c->wbuf_len); 445 - 445 + 446 446 if ( c->wbuf_len + sizeof(struct jffs2_unknown_node) < c->wbuf_pagesize) { 447 447 struct jffs2_unknown_node *padnode = (void *)(c->wbuf + c->wbuf_len); 448 448 padnode->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); ··· 453 453 } 454 454 /* else jffs2_flash_writev has actually filled in the rest of the 455 455 buffer for us, and will deal with the node refs etc. later. */ 456 - 456 + 457 457 #ifdef BREAKME 458 458 static int breakme; 459 459 if (breakme++ == 20) { ··· 462 462 c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, 463 463 &retlen, brokenbuf, NULL, c->oobinfo); 464 464 ret = -EIO; 465 - } else 465 + } else 466 466 #endif 467 - 467 + 468 468 if (jffs2_cleanmarker_oob(c)) 469 469 ret = c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf, NULL, c->oobinfo); 470 470 else ··· 485 485 } 486 486 487 487 spin_lock(&c->erase_completion_lock); 488 - 488 + 489 489 /* Adjust free size of the block if we padded. */ 490 490 if (pad) { 491 491 struct jffs2_eraseblock *jeb; ··· 495 495 D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", 496 496 (jeb==c->nextblock)?"next":"", jeb->offset)); 497 497 498 - /* wbuf_pagesize - wbuf_len is the amount of space that's to be 498 + /* wbuf_pagesize - wbuf_len is the amount of space that's to be 499 499 padded. If there is less free space in the block than that, 500 500 something screwed up */ 501 501 if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) { ··· 523 523 return 0; 524 524 } 525 525 526 - /* Trigger garbage collection to flush the write-buffer. 526 + /* Trigger garbage collection to flush the write-buffer. 527 527 If ino arg is zero, do it if _any_ real (i.e. not GC) writes are 528 - outstanding. If ino arg non-zero, do it only if a write for the 528 + outstanding. If ino arg non-zero, do it only if a write for the 529 529 given inode is outstanding. */ 530 530 int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) 531 531 { ··· 620 620 /* If not NAND flash, don't bother */ 621 621 if (!jffs2_is_writebuffered(c)) 622 622 return jffs2_flash_direct_writev(c, invecs, count, to, retlen); 623 - 623 + 624 624 down_write(&c->wbuf_sem); 625 625 626 626 /* If wbuf_ofs is not initialized, set it to target address */ 627 627 if (c->wbuf_ofs == 0xFFFFFFFF) { 628 628 c->wbuf_ofs = PAGE_DIV(to); 629 - c->wbuf_len = PAGE_MOD(to); 629 + c->wbuf_len = PAGE_MOD(to); 630 630 memset(c->wbuf,0xff,c->wbuf_pagesize); 631 631 } 632 632 ··· 640 640 memset(c->wbuf,0xff,c->wbuf_pagesize); 641 641 } 642 642 } 643 - 644 - /* Sanity checks on target address. 645 - It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs), 646 - and it's permitted to write at the beginning of a new 643 + 644 + /* Sanity checks on target address. 645 + It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs), 646 + and it's permitted to write at the beginning of a new 647 647 erase block. Anything else, and you die. 648 648 New block starts at xxx000c (0-b = block header) 649 649 */ ··· 661 661 } 662 662 /* set pointer to new block */ 663 663 c->wbuf_ofs = PAGE_DIV(to); 664 - c->wbuf_len = PAGE_MOD(to); 665 - } 664 + c->wbuf_len = PAGE_MOD(to); 665 + } 666 666 667 667 if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { 668 668 /* We're not writing immediately after the writebuffer. Bad. */ ··· 682 682 invec = 0; 683 683 outvec = 0; 684 684 685 - /* Fill writebuffer first, if already in use */ 685 + /* Fill writebuffer first, if already in use */ 686 686 if (c->wbuf_len) { 687 687 uint32_t invec_ofs = 0; 688 688 689 - /* adjust alignment offset */ 689 + /* adjust alignment offset */ 690 690 if (c->wbuf_len != PAGE_MOD(to)) { 691 691 c->wbuf_len = PAGE_MOD(to); 692 692 /* take care of alignment to next page */ 693 693 if (!c->wbuf_len) 694 694 c->wbuf_len = c->wbuf_pagesize; 695 695 } 696 - 696 + 697 697 while(c->wbuf_len < c->wbuf_pagesize) { 698 698 uint32_t thislen; 699 - 699 + 700 700 if (invec == count) 701 701 goto alldone; 702 702 ··· 704 704 705 705 if (thislen >= invecs[invec].iov_len) 706 706 thislen = invecs[invec].iov_len; 707 - 707 + 708 708 invec_ofs = thislen; 709 709 710 710 memcpy(c->wbuf + c->wbuf_len, invecs[invec].iov_base, thislen); 711 711 c->wbuf_len += thislen; 712 712 donelen += thislen; 713 713 /* Get next invec, if actual did not fill the buffer */ 714 - if (c->wbuf_len < c->wbuf_pagesize) 714 + if (c->wbuf_len < c->wbuf_pagesize) 715 715 invec++; 716 - } 717 - 716 + } 717 + 718 718 /* write buffer is full, flush buffer */ 719 719 ret = __jffs2_flush_wbuf(c, NOPAD); 720 720 if (ret) { ··· 773 773 774 774 /* We did cross a page boundary, so we write some now */ 775 775 if (jffs2_cleanmarker_oob(c)) 776 - ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, c->oobinfo); 776 + ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, c->oobinfo); 777 777 else 778 778 ret = jffs2_flash_direct_writev(c, outvecs, splitvec+1, outvec_to, &wbuf_retlen); 779 - 779 + 780 780 if (ret < 0 || wbuf_retlen != PAGE_DIV(totlen)) { 781 781 /* At this point we have no problem, 782 782 c->wbuf is empty. However refile nextblock to avoid ··· 793 793 spin_unlock(&c->erase_completion_lock); 794 794 goto exit; 795 795 } 796 - 796 + 797 797 donelen += wbuf_retlen; 798 798 c->wbuf_ofs = PAGE_DIV(outvec_to) + PAGE_DIV(totlen); 799 799 ··· 837 837 jffs2_wbuf_dirties_inode(c, ino); 838 838 839 839 ret = 0; 840 - 840 + 841 841 exit: 842 842 up_write(&c->wbuf_sem); 843 843 return ret; ··· 880 880 if ( (ret == -EBADMSG) && (*retlen == len) ) { 881 881 printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", 882 882 len, ofs); 883 - /* 884 - * We have the raw data without ECC correction in the buffer, maybe 883 + /* 884 + * We have the raw data without ECC correction in the buffer, maybe 885 885 * we are lucky and all data or parts are correct. We check the node. 886 886 * If data are corrupted node check will sort it out. 887 887 * We keep this block, it will fail on write or erase and the we 888 888 * mark it bad. Or should we do that now? But we should give him a chance. 889 - * Maybe we had a system crash or power loss before the ecc write or 889 + * Maybe we had a system crash or power loss before the ecc write or 890 890 * a erase was completed. 891 891 * So we return success. :) 892 892 */ 893 893 ret = 0; 894 - } 894 + } 895 895 896 896 /* if no writebuffer available or write buffer empty, return */ 897 897 if (!c->wbuf_pagesize || !c->wbuf_len) ··· 906 906 if (owbf > c->wbuf_len) /* is read beyond write buffer ? */ 907 907 goto exit; 908 908 lwbf = c->wbuf_len - owbf; /* number of bytes to copy */ 909 - if (lwbf > len) 909 + if (lwbf > len) 910 910 lwbf = len; 911 - } else { 911 + } else { 912 912 orbf = (c->wbuf_ofs - ofs); /* offset in read buffer */ 913 913 if (orbf > len) /* is write beyond write buffer ? */ 914 914 goto exit; 915 915 lwbf = len - orbf; /* number of bytes to copy */ 916 - if (lwbf > c->wbuf_len) 916 + if (lwbf > c->wbuf_len) 917 917 lwbf = c->wbuf_len; 918 - } 918 + } 919 919 if (lwbf > 0) 920 920 memcpy(buf+orbf,c->wbuf+owbf,lwbf); 921 921 ··· 943 943 printk(KERN_NOTICE "jffs2_check_oob_empty(): allocation of temporary data buffer for oob check failed\n"); 944 944 return -ENOMEM; 945 945 } 946 - /* 946 + /* 947 947 * if mode = 0, we scan for a total empty oob area, else we have 948 948 * to take care of the cleanmarker in the first page of the block 949 949 */ ··· 952 952 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB failed %d for block at %08x\n", ret, jeb->offset)); 953 953 goto out; 954 954 } 955 - 955 + 956 956 if (retlen < len) { 957 957 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB return short read " 958 958 "(%zd bytes not %d) for block at %08x\n", retlen, len, jeb->offset)); 959 959 ret = -EIO; 960 960 goto out; 961 961 } 962 - 962 + 963 963 /* Special check for first page */ 964 964 for(i = 0; i < oob_size ; i++) { 965 965 /* Yeah, we know about the cleanmarker. */ 966 - if (mode && i >= c->fsdata_pos && 966 + if (mode && i >= c->fsdata_pos && 967 967 i < c->fsdata_pos + c->fsdata_len) 968 968 continue; 969 969 970 970 if (buf[i] != 0xFF) { 971 971 D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n", 972 972 buf[i], i, jeb->offset)); 973 - ret = 1; 973 + ret = 1; 974 974 goto out; 975 975 } 976 976 } 977 977 978 - /* we know, we are aligned :) */ 978 + /* we know, we are aligned :) */ 979 979 for (page = oob_size; page < len; page += sizeof(long)) { 980 980 unsigned long dat = *(unsigned long *)(&buf[page]); 981 981 if(dat != -1) { 982 - ret = 1; 982 + ret = 1; 983 983 goto out; 984 984 } 985 985 } 986 986 987 987 out: 988 - kfree(buf); 989 - 988 + kfree(buf); 989 + 990 990 return ret; 991 991 } 992 992 ··· 1068 1068 n.totlen = cpu_to_je32(8); 1069 1069 1070 1070 ret = jffs2_flash_write_oob(c, jeb->offset + c->fsdata_pos, c->fsdata_len, &retlen, (unsigned char *)&n); 1071 - 1071 + 1072 1072 if (ret) { 1073 1073 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); 1074 1074 return ret; ··· 1080 1080 return 0; 1081 1081 } 1082 1082 1083 - /* 1083 + /* 1084 1084 * On NAND we try to mark this block bad. If the block was erased more 1085 1085 * than MAX_ERASE_FAILURES we mark it finaly bad. 1086 1086 * Don't care about failures. This block remains on the erase-pending ··· 1101 1101 1102 1102 D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Marking bad block at %08x\n", bad_offset)); 1103 1103 ret = c->mtd->block_markbad(c->mtd, bad_offset); 1104 - 1104 + 1105 1105 if (ret) { 1106 1106 D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); 1107 1107 return ret; ··· 1125 1125 /* Do this only, if we have an oob buffer */ 1126 1126 if (!c->mtd->oobsize) 1127 1127 return 0; 1128 - 1128 + 1129 1129 /* Cleanmarker is out-of-band, so inline size zero */ 1130 1130 c->cleanmarker_size = 0; 1131 1131 ··· 1151 1151 c->fsdata_len = NAND_JFFS2_OOB16_FSDALEN; 1152 1152 c->badblock_pos = 15; 1153 1153 break; 1154 - 1154 + 1155 1155 default: 1156 1156 D1(printk(KERN_DEBUG "JFFS2 on NAND. No autoplacment info found\n")); 1157 1157 return -EINVAL; ··· 1168 1168 init_rwsem(&c->wbuf_sem); 1169 1169 c->wbuf_pagesize = c->mtd->oobblock; 1170 1170 c->wbuf_ofs = 0xFFFFFFFF; 1171 - 1171 + 1172 1172 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); 1173 1173 if (!c->wbuf) 1174 1174 return -ENOMEM; ··· 1194 1194 1195 1195 int jffs2_dataflash_setup(struct jffs2_sb_info *c) { 1196 1196 c->cleanmarker_size = 0; /* No cleanmarkers needed */ 1197 - 1197 + 1198 1198 /* Initialize write buffer */ 1199 1199 init_rwsem(&c->wbuf_sem); 1200 - 1201 - 1200 + 1201 + 1202 1202 c->wbuf_pagesize = c->mtd->erasesize; 1203 - 1203 + 1204 1204 /* Find a suitable c->sector_size 1205 1205 * - Not too much sectors 1206 1206 * - Sectors have to be at least 4 K + some bytes ··· 1210 1210 */ 1211 1211 1212 1212 c->sector_size = 8 * c->mtd->erasesize; 1213 - 1213 + 1214 1214 while (c->sector_size < 8192) { 1215 1215 c->sector_size *= 2; 1216 1216 } 1217 - 1217 + 1218 1218 /* It may be necessary to adjust the flash size */ 1219 1219 c->flash_size = c->mtd->size; 1220 1220 ··· 1222 1222 c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; 1223 1223 printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size); 1224 1224 }; 1225 - 1225 + 1226 1226 c->wbuf_ofs = 0xFFFFFFFF; 1227 1227 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); 1228 1228 if (!c->wbuf)
+34 -34
fs/jffs2/write.c
··· 7 7 * 8 8 * For licensing information, see the file 'LICENCE' in this directory. 9 9 * 10 - * $Id: write.c,v 1.96 2005/09/07 08:34:55 havasi Exp $ 10 + * $Id: write.c,v 1.97 2005/11/07 11:14:42 gleixner Exp $ 11 11 * 12 12 */ 13 13 ··· 54 54 return 0; 55 55 } 56 56 57 - /* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it, 57 + /* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it, 58 58 write it to the flash, link it into the existing inode/fragment list */ 59 59 60 60 struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode) ··· 86 86 raw = jffs2_alloc_raw_node_ref(); 87 87 if (!raw) 88 88 return ERR_PTR(-ENOMEM); 89 - 89 + 90 90 fn = jffs2_alloc_full_dnode(); 91 91 if (!fn) { 92 92 jffs2_free_raw_node_ref(raw); ··· 110 110 if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { 111 111 BUG_ON(!retried); 112 112 D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " 113 - "highest version %d -> updating dnode\n", 113 + "highest version %d -> updating dnode\n", 114 114 je32_to_cpu(ri->version), f->highest_version)); 115 115 ri->version = cpu_to_je32(++f->highest_version); 116 116 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); ··· 120 120 (alloc_mode==ALLOC_GC)?0:f->inocache->ino); 121 121 122 122 if (ret || (retlen != sizeof(*ri) + datalen)) { 123 - printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", 123 + printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", 124 124 sizeof(*ri)+datalen, flash_ofs, ret, retlen); 125 125 126 126 /* Mark the space as dirtied */ ··· 128 128 /* Doesn't belong to any inode */ 129 129 raw->next_in_ino = NULL; 130 130 131 - /* Don't change raw->size to match retlen. We may have 131 + /* Don't change raw->size to match retlen. We may have 132 132 written the node header already, and only the data will 133 133 seem corrupted, in which case the scan would skip over 134 - any node we write before the original intended end of 134 + any node we write before the original intended end of 135 135 this node */ 136 136 raw->flash_offset |= REF_OBSOLETE; 137 137 jffs2_add_physical_node_ref(c, raw); ··· 148 148 retried = 1; 149 149 150 150 D1(printk(KERN_DEBUG "Retrying failed write.\n")); 151 - 151 + 152 152 jffs2_dbg_acct_sanity_check(c,jeb); 153 153 jffs2_dbg_acct_paranoia_check(c, jeb); 154 154 ··· 159 159 /* Locking pain */ 160 160 up(&f->sem); 161 161 jffs2_complete_reservation(c); 162 - 162 + 163 163 ret = jffs2_reserve_space(c, sizeof(*ri) + datalen, &flash_ofs, 164 164 &dummy, alloc_mode, JFFS2_SUMMARY_INODE_SIZE); 165 165 down(&f->sem); ··· 181 181 return ERR_PTR(ret?ret:-EIO); 182 182 } 183 183 /* Mark the space used */ 184 - /* If node covers at least a whole page, or if it starts at the 185 - beginning of a page and runs to the end of the file, or if 186 - it's a hole node, mark it REF_PRISTINE, else REF_NORMAL. 184 + /* If node covers at least a whole page, or if it starts at the 185 + beginning of a page and runs to the end of the file, or if 186 + it's a hole node, mark it REF_PRISTINE, else REF_NORMAL. 187 187 */ 188 188 if ((je32_to_cpu(ri->dsize) >= PAGE_CACHE_SIZE) || 189 189 ( ((je32_to_cpu(ri->offset)&(PAGE_CACHE_SIZE-1))==0) && ··· 201 201 spin_unlock(&c->erase_completion_lock); 202 202 203 203 D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", 204 - flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize), 204 + flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize), 205 205 je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), 206 206 je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen))); 207 207 ··· 221 221 int retried = 0; 222 222 int ret; 223 223 224 - D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", 224 + D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", 225 225 je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), 226 226 je32_to_cpu(rd->name_crc))); 227 227 ··· 235 235 vecs[0].iov_len = sizeof(*rd); 236 236 vecs[1].iov_base = (unsigned char *)name; 237 237 vecs[1].iov_len = namelen; 238 - 238 + 239 239 jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len); 240 240 241 241 raw = jffs2_alloc_raw_node_ref(); ··· 276 276 ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, 277 277 (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); 278 278 if (ret || (retlen != sizeof(*rd) + namelen)) { 279 - printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", 279 + printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", 280 280 sizeof(*rd)+namelen, flash_ofs, ret, retlen); 281 281 /* Mark the space as dirtied */ 282 282 if (retlen) { ··· 307 307 /* Locking pain */ 308 308 up(&f->sem); 309 309 jffs2_complete_reservation(c); 310 - 310 + 311 311 ret = jffs2_reserve_space(c, sizeof(*rd) + namelen, &flash_ofs, 312 312 &dummy, alloc_mode, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 313 313 down(&f->sem); ··· 346 346 we don't have to go digging in struct inode or its equivalent. It should set: 347 347 mode, uid, gid, (starting)isize, atime, ctime, mtime */ 348 348 int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 349 - struct jffs2_raw_inode *ri, unsigned char *buf, 349 + struct jffs2_raw_inode *ri, unsigned char *buf, 350 350 uint32_t offset, uint32_t writelen, uint32_t *retlen) 351 351 { 352 352 int ret = 0; ··· 354 354 355 355 D1(printk(KERN_DEBUG "jffs2_write_inode_range(): Ino #%u, ofs 0x%x, len 0x%x\n", 356 356 f->inocache->ino, offset, writelen)); 357 - 357 + 358 358 while(writelen) { 359 359 struct jffs2_full_dnode *fn; 360 360 unsigned char *comprbuf = NULL; ··· 451 451 uint32_t alloclen, phys_ofs; 452 452 int ret; 453 453 454 - /* Try to reserve enough space for both node and dirent. 455 - * Just the node will do for now, though 454 + /* Try to reserve enough space for both node and dirent. 455 + * Just the node will do for now, though 456 456 */ 457 457 ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL, 458 458 JFFS2_SUMMARY_INODE_SIZE); ··· 477 477 jffs2_complete_reservation(c); 478 478 return PTR_ERR(fn); 479 479 } 480 - /* No data here. Only a metadata node, which will be 480 + /* No data here. Only a metadata node, which will be 481 481 obsoleted by the first data write 482 482 */ 483 483 f->metadata = fn; ··· 486 486 jffs2_complete_reservation(c); 487 487 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, 488 488 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 489 - 489 + 490 490 if (ret) { 491 491 /* Eep. */ 492 492 D1(printk(KERN_DEBUG "jffs2_reserve_space() for dirent failed\n")); ··· 519 519 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL); 520 520 521 521 jffs2_free_raw_dirent(rd); 522 - 522 + 523 523 if (IS_ERR(fd)) { 524 - /* dirent failed to write. Delete the inode normally 524 + /* dirent failed to write. Delete the inode normally 525 525 as if it were the final unlink() */ 526 526 jffs2_complete_reservation(c); 527 527 up(&dir_f->sem); ··· 548 548 uint32_t alloclen, phys_ofs; 549 549 int ret; 550 550 551 - if (1 /* alternative branch needs testing */ || 551 + if (1 /* alternative branch needs testing */ || 552 552 !jffs2_can_mark_obsolete(c)) { 553 553 /* We can't mark stuff obsolete on the medium. We need to write a deletion dirent */ 554 554 ··· 570 570 rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); 571 571 rd->totlen = cpu_to_je32(sizeof(*rd) + namelen); 572 572 rd->hdr_crc = cpu_to_je32(crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)); 573 - 573 + 574 574 rd->pino = cpu_to_je32(dir_f->inocache->ino); 575 575 rd->version = cpu_to_je32(++dir_f->highest_version); 576 576 rd->ino = cpu_to_je32(0); ··· 581 581 rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); 582 582 583 583 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_DELETION); 584 - 584 + 585 585 jffs2_free_raw_dirent(rd); 586 586 587 587 if (IS_ERR(fd)) { ··· 600 600 down(&dir_f->sem); 601 601 602 602 while ((*prev) && (*prev)->nhash <= nhash) { 603 - if ((*prev)->nhash == nhash && 603 + if ((*prev)->nhash == nhash && 604 604 !memcmp((*prev)->name, name, namelen) && 605 605 !(*prev)->name[namelen]) { 606 606 struct jffs2_full_dirent *this = *prev; ··· 621 621 /* dead_f is NULL if this was a rename not a real unlink */ 622 622 /* Also catch the !f->inocache case, where there was a dirent 623 623 pointing to an inode which didn't exist. */ 624 - if (dead_f && dead_f->inocache) { 624 + if (dead_f && dead_f->inocache) { 625 625 626 626 down(&dead_f->sem); 627 627 ··· 629 629 while (dead_f->dents) { 630 630 /* There can be only deleted ones */ 631 631 fd = dead_f->dents; 632 - 632 + 633 633 dead_f->dents = fd->next; 634 - 634 + 635 635 if (fd->ino) { 636 636 printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", 637 637 dead_f->inocache->ino, fd->name, fd->ino); ··· 672 672 jffs2_free_raw_dirent(rd); 673 673 return ret; 674 674 } 675 - 675 + 676 676 down(&dir_f->sem); 677 677 678 678 /* Build a deletion node */ ··· 693 693 rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); 694 694 695 695 fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL); 696 - 696 + 697 697 jffs2_free_raw_dirent(rd); 698 698 699 699 if (IS_ERR(fd)) {
+6 -6
include/linux/jffs2.h
··· 5 5 * 6 6 * Created by David Woodhouse <dwmw2@infradead.org> 7 7 * 8 - * For licensing information, see the file 'LICENCE' in the 8 + * For licensing information, see the file 'LICENCE' in the 9 9 * jffs2 directory. 10 10 * 11 11 * $Id: jffs2.h,v 1.38 2005/09/26 11:37:23 havasi Exp $ ··· 70 70 //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4) 71 71 72 72 73 - #define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at 74 - mount time, don't wait for it to 73 + #define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at 74 + mount time, don't wait for it to 75 75 happen later */ 76 - #define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific 76 + #define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific 77 77 compression type */ 78 78 79 79 ··· 120 120 } __attribute__((packed)); 121 121 122 122 /* The JFFS2 raw inode structure: Used for storage on physical media. */ 123 - /* The uid, gid, atime, mtime and ctime members could be longer, but 123 + /* The uid, gid, atime, mtime and ctime members could be longer, but 124 124 are left like this for space efficiency. If and when people decide 125 125 they really need them extended, it's simple enough to add support for 126 126 a new type of raw node. ··· 165 165 jint32_t sum[0]; /* inode summary info */ 166 166 } __attribute__((packed)); 167 167 168 - union jffs2_node_union 168 + union jffs2_node_union 169 169 { 170 170 struct jffs2_raw_inode i; 171 171 struct jffs2_raw_dirent d;
+2 -2
include/linux/jffs2_fs_i.h
··· 1 - /* $Id: jffs2_fs_i.h,v 1.18 2005/07/17 11:13:48 dedekind Exp $ */ 1 + /* $Id: jffs2_fs_i.h,v 1.19 2005/11/07 11:14:52 gleixner Exp $ */ 2 2 3 3 #ifndef _JFFS2_FS_I 4 4 #define _JFFS2_FS_I ··· 25 25 /* There may be one datanode which isn't referenced by any of the 26 26 above fragments, if it contains a metadata update but no actual 27 27 data - or if this is a directory inode */ 28 - /* This also holds the _only_ dnode for symlinks/device nodes, 28 + /* This also holds the _only_ dnode for symlinks/device nodes, 29 29 etc. */ 30 30 struct jffs2_full_dnode *metadata; 31 31
+7 -7
include/linux/jffs2_fs_sb.h
··· 20 20 struct jffs2_inodirty; 21 21 22 22 /* A struct for the overall file system control. Pointers to 23 - jffs2_sb_info structs are named `c' in the source code. 23 + jffs2_sb_info structs are named `c' in the source code. 24 24 Nee jffs_control 25 25 */ 26 26 struct jffs2_sb_info { ··· 35 35 struct completion gc_thread_start; /* GC thread start completion */ 36 36 struct completion gc_thread_exit; /* GC thread exit completion port */ 37 37 38 - struct semaphore alloc_sem; /* Used to protect all the following 38 + struct semaphore alloc_sem; /* Used to protect all the following 39 39 fields, and also to protect against 40 40 out-of-order writing of nodes. And GC. */ 41 41 uint32_t cleanmarker_size; /* Size of an _inline_ CLEANMARKER ··· 64 64 uint32_t nospc_dirty_size; 65 65 66 66 uint32_t nr_blocks; 67 - struct jffs2_eraseblock *blocks; /* The whole array of blocks. Used for getting blocks 67 + struct jffs2_eraseblock *blocks; /* The whole array of blocks. Used for getting blocks 68 68 * from the offset (blocks[ofs / sector_size]) */ 69 69 struct jffs2_eraseblock *nextblock; /* The block we're currently filling */ 70 70 ··· 82 82 struct list_head bad_list; /* Bad blocks. */ 83 83 struct list_head bad_used_list; /* Bad blocks with valid data in. */ 84 84 85 - spinlock_t erase_completion_lock; /* Protect free_list and erasing_list 85 + spinlock_t erase_completion_lock; /* Protect free_list and erasing_list 86 86 against erase completion handler */ 87 87 wait_queue_head_t erase_wait; /* For waiting for erases to complete */ 88 88 89 89 wait_queue_head_t inocache_wq; 90 90 struct jffs2_inode_cache **inocache_list; 91 91 spinlock_t inocache_lock; 92 - 92 + 93 93 /* Sem to allow jffs2_garbage_collect_deletion_dirent to 94 - drop the erase_completion_lock while it's holding a pointer 94 + drop the erase_completion_lock while it's holding a pointer 95 95 to an obsoleted node. I don't like this. Alternatives welcomed. */ 96 96 struct semaphore erase_free_sem; 97 97 98 98 uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */ 99 - 99 + 100 100 #ifdef CONFIG_JFFS2_FS_WRITEBUFFER 101 101 /* Write-behind buffer for NAND flash */ 102 102 unsigned char *wbuf;