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